From 437476edf3423be222f69b4798ccccddbcd5766e Mon Sep 17 00:00:00 2001 From: Maurizio Casimirri Date: Mon, 20 Nov 2023 13:35:40 +0100 Subject: [PATCH] feat(stage-wizard): wizard panel hidden by default (#5134) --- .../src/modules/side-panel.spec.ts | 14 +++++++------- packages/compass-aggregations/src/stores/store.ts | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/packages/compass-aggregations/src/modules/side-panel.spec.ts b/packages/compass-aggregations/src/modules/side-panel.spec.ts index 14ba9783518..f41e336577e 100644 --- a/packages/compass-aggregations/src/modules/side-panel.spec.ts +++ b/packages/compass-aggregations/src/modules/side-panel.spec.ts @@ -30,26 +30,26 @@ describe('side-panel module', function () { fakeLocalStorage.restore(); }); - it('starts with an open state', function () { - expect(store.getState().sidePanel.isPanelOpen).to.equal(true); + it('starts with an closed state', function () { + expect(store.getState().sidePanel.isPanelOpen).to.equal(false); }); it('toggles the side panel', function () { - store.dispatch(toggleSidePanel() as any); - expect(store.getState().sidePanel.isPanelOpen).to.equal(false); store.dispatch(toggleSidePanel() as any); expect(store.getState().sidePanel.isPanelOpen).to.equal(true); + store.dispatch(toggleSidePanel() as any); + expect(store.getState().sidePanel.isPanelOpen).to.equal(false); }); it('persists the last state', function () { const store1 = configureStore(); - expect(store1.getState().sidePanel.isPanelOpen).to.equal(true); + expect(store1.getState().sidePanel.isPanelOpen).to.equal(false); store1.dispatch(toggleSidePanel() as any); - expect(store1.getState().sidePanel.isPanelOpen).to.equal(false); + expect(store1.getState().sidePanel.isPanelOpen).to.equal(true); const store2 = configureStore(); - expect(store2.getState().sidePanel.isPanelOpen).to.equal(false); + expect(store2.getState().sidePanel.isPanelOpen).to.equal(true); }); }); }); diff --git a/packages/compass-aggregations/src/stores/store.ts b/packages/compass-aggregations/src/stores/store.ts index 476442d7b29..125c1a996ed 100644 --- a/packages/compass-aggregations/src/stores/store.ts +++ b/packages/compass-aggregations/src/stores/store.ts @@ -234,12 +234,12 @@ const configureStore = (options: ConfigureStoreOptions) => { // side panel) sidePanel: { isPanelOpen: - // The panel is shown by default if THE FEATURE IS ENABLED IN - // PREFERENCES and initial state in localStorage is not set or - // `"true"` (not `"false"`) + // if the feature is enabled in preferences, the state of the + // panel is fetched and then kept in sync with a localStorage entry. + // The initial state, if the localStorage entry is not set, + // should be 'hidden'. preferencesAccess.getPreferences().enableStageWizard && - localStorage.getItem(INITIAL_PANEL_OPEN_LOCAL_STORAGE_KEY) !== - 'false', + localStorage.getItem(INITIAL_PANEL_OPEN_LOCAL_STORAGE_KEY) === 'true', }, }, applyMiddleware(