@@ -291,7 +291,6 @@ export const handleSharedDashboardsThunk = () => (dispatch: any) => {
291291 if ( skipConfirmation === true ) {
292292 dispatch ( onConfirmLoadSharedDashboardThunk ( ) ) ;
293293 }
294-
295294 window . history . pushState ( { } , document . title , window . location . pathname ) ;
296295 } else {
297296 dispatch ( setConnectionModalOpen ( false ) ) ;
@@ -358,7 +357,6 @@ export const onConfirmLoadSharedDashboardThunk = () => (dispatch: any, getState:
358357 }
359358 if ( shareDetails . standalone == true ) {
360359 dispatch ( setStandaloneMode ( true ) ) ;
361- localStorage . setItem ( 'standaloneShared' , 'true' ) ; // EDGE CASE: redirect SSO removes the shareDetails when redirecting
362360 }
363361 dispatch ( resetShareDetails ( ) ) ;
364362 } catch ( e ) {
@@ -410,29 +408,33 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
410408
411409 try {
412410 // Parse the URL parameters to see if there's any deep linking of parameters.
411+ const state = getState ( ) ;
413412 const queryString = window . location . search ;
414413 const urlParams = new URLSearchParams ( queryString ) ;
414+ if ( state . application . waitForSSO ) {
415+ const paramsBeforeSSO = JSON . parse ( sessionStorage . getItem ( 'SSO_PARAMS_BEFORE_REDIRECT' ) || '{}' ) ;
416+ Object . entries ( paramsBeforeSSO ) . forEach ( ( [ key , value ] ) => {
417+ urlParams . set ( key , value ) ;
418+ } ) ;
419+ }
415420 const paramsToSetAfterConnecting = { } ;
416421 Array . from ( urlParams . entries ( ) ) . forEach ( ( [ key , value ] ) => {
417422 if ( key . startsWith ( 'neodash_' ) ) {
418423 paramsToSetAfterConnecting [ key ] = value ;
419424 }
420425 } ) ;
421-
426+ sessionStorage . getItem ( 'SSO_PARAMS_BEFORE_REDIRECT' ) ;
422427 const page = urlParams . get ( 'page' ) ;
423428 if ( page !== '' && page !== null ) {
424429 if ( ! isNaN ( page ) ) {
425430 dispatch ( setPageNumberThunk ( parseInt ( page ) ) ) ;
426431 }
427432 }
428- const state = getState ( ) ;
429433 dispatch ( setSSOEnabled ( config . ssoEnabled , state . application . cachedSSODiscoveryUrl ) ) ;
430434 dispatch ( setSSOProviders ( config . ssoProviders ) ) ;
431435
432436 // Check if we are in standalone mode
433- // const standaloneShared = localStorage.getItem('standaloneShared') == 'true'; // EDGE case: from url param it could happen that we lose the value due to SSO redirect
434- const { standalone } = config ;
435- // || standaloneShared;
437+ const standalone = config . standalone || urlParams . get ( 'standalone' ) == 'Yes' ;
436438
437439 // if a dashboard database was previously set, remember to use it.
438440 const dashboardDatabase = state . application . standaloneDashboardDatabase ;
@@ -455,7 +457,6 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
455457 config . standaloneDatabaseList
456458 )
457459 ) ;
458- localStorage . removeItem ( 'standaloneShared' ) ;
459460
460461 dispatch ( setLoggingMode ( config . loggingMode ) ) ;
461462 dispatch ( setLoggingDatabase ( config . loggingDatabase ) ) ;
@@ -530,14 +531,18 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
530531 }
531532
532533 if ( standalone ) {
533- if ( config . standaloneDashboardURL !== undefined && config . standaloneDashboardURL . length > 0 ) {
534+ if ( urlParams . get ( 'id' ) ) {
535+ dispatch ( setDashboardToLoadAfterConnecting ( urlParams . get ( 'id' ) ) ) ;
536+ } else if ( config . standaloneDashboardURL !== undefined && config . standaloneDashboardURL . length > 0 ) {
534537 dispatch ( setDashboardToLoadAfterConnecting ( config . standaloneDashboardURL ) ) ;
535538 } else {
536539 dispatch ( setDashboardToLoadAfterConnecting ( `name:${ config . standaloneDashboardName } ` ) ) ;
537540 }
538541 dispatch ( setParametersToLoadAfterConnecting ( paramsToSetAfterConnecting ) ) ;
539542 }
543+ sessionStorage . removeItem ( 'SSO_PARAMS_BEFORE_REDIRECT' ) ;
540544 } ) ;
545+
541546 dispatch ( setWaitForSSO ( false ) ) ;
542547 if ( ! success ) {
543548 alert ( 'Unable to connect using SSO. See the browser console for more details.' ) ;
@@ -550,6 +555,12 @@ export const loadApplicationConfigThunk = () => async (dispatch: any, getState:
550555 } else {
551556 return ;
552557 }
558+ } else if ( state . application . ssoEnabled && ! state . application . waitForSSO && urlParams ) {
559+ let paramsToStore = { } ;
560+ urlParams . forEach ( ( value , key ) => {
561+ paramsToStore [ key ] = value ;
562+ } ) ;
563+ sessionStorage . setItem ( 'SSO_PARAMS_BEFORE_REDIRECT' , JSON . stringify ( paramsToStore ) ) ;
553564 }
554565
555566 if ( standalone ) {
0 commit comments