From 5887a4293968696b055af48dae561c0b731f0364 Mon Sep 17 00:00:00 2001 From: Idan Amit Date: Wed, 16 May 2018 14:32:01 +0300 Subject: Fixing bug with router state change Fixing a bug on state change to "welcome" page and "previousState" state param. Change-Id: I12be09166809c862766973be8fc3b567d47f955f Issue-ID: SDC-1328 Signed-off-by: Idan Amit --- catalog-ui/src/app/app.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'catalog-ui') diff --git a/catalog-ui/src/app/app.ts b/catalog-ui/src/app/app.ts index e2240ed18a..723f244dc6 100644 --- a/catalog-ui/src/app/app.ts +++ b/catalog-ui/src/app/app.ts @@ -768,7 +768,9 @@ ng1appModule.run([ console.info('$stateChangeStart', toState.name); if (toState.name !== 'error-403' && !userService.getLoggedinUser()) { - event.preventDefault(); + if (toState.name !== 'welcome') { + event.preventDefault(); + } userService.authorize().subscribe((userInfo:IUserProperties) => { if (!doesUserHasAccess(toState, userInfo)) { @@ -824,18 +826,20 @@ ng1appModule.run([ } } + // if enetering workspace, set the previousState param + if (toState.name.indexOf('workspace') !== -1) { + if (!toParams.previousState) { + const tmpPreviousState1 = fromParams && fromParams.previousState; + const tmpPreviousState2 = (['dashboard', 'catalog'].indexOf(fromState.name) !== -1) ? fromState.name : 'catalog'; + toParams.previousState = tmpPreviousState1 || tmpPreviousState2; + } + } + }; let onStateChangeSuccess:Function = (event, toState, toParams, fromState, fromParams):void => { console.info('$stateChangeSuccess', toState.name); - //saving last state to params , for breadcrumbs - if (['dashboard', 'catalog', 'onboardVendor'].indexOf(fromState.name) > -1) { - toParams.previousState = fromState.name; - } else { - toParams.previousState = fromParams.previousState; - } - // Workaround in case we are entering other state then workspace (user move to catalog) // remove the changeComponentCsarVersion, user should open again the VSP list and select one for update. if (toState.name.indexOf('workspace') === -1) { -- cgit 1.2.3-korg