-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Only show activation panel when needed (#18541)
- Loading branch information
1 parent
e3cb9cd
commit 8a6444b
Showing
10 changed files
with
133 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
frontend/src/layout/navigation-3000/sidepanel/panels/SidePanelSupport.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 3 additions & 2 deletions
5
frontend/src/layout/navigation-3000/sidepanel/panels/sidePanelDocsLogic.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 5 additions & 4 deletions
9
frontend/src/layout/navigation-3000/sidepanel/panels/sidePanelSettingsLogic.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
frontend/src/layout/navigation-3000/sidepanel/sidePanelStateLogic.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { actions, kea, listeners, path, reducers } from 'kea' | ||
import { SidePanelTab } from '~/types' | ||
|
||
import type { sidePanelStateLogicType } from './sidePanelStateLogicType' | ||
|
||
// The side panel imports a lot of other components so this allows us to avoid circular dependencies | ||
|
||
export const sidePanelStateLogic = kea<sidePanelStateLogicType>([ | ||
path(['scenes', 'navigation', 'sidepanel', 'sidePanelStateLogic']), | ||
actions({ | ||
openSidePanel: (tab: SidePanelTab) => ({ tab }), | ||
closeSidePanel: (tab?: SidePanelTab) => ({ tab }), | ||
setSidePanelOpen: (open: boolean) => ({ open }), | ||
}), | ||
|
||
reducers(() => ({ | ||
selectedTab: [ | ||
null as SidePanelTab | null, | ||
{ persist: true }, | ||
{ | ||
openSidePanel: (_, { tab }) => tab, | ||
}, | ||
], | ||
sidePanelOpen: [ | ||
false, | ||
{ persist: true }, | ||
{ | ||
setSidePanelOpen: (_, { open }) => open, | ||
}, | ||
], | ||
})), | ||
listeners(({ actions, values }) => ({ | ||
// NOTE: We explicitly reference the actions instead of connecting so that people don't accidentally | ||
// use this logic instead of sidePanelStateLogic | ||
openSidePanel: () => { | ||
actions.setSidePanelOpen(true) | ||
}, | ||
closeSidePanel: ({ tab }) => { | ||
if (!tab) { | ||
// If we aren't specifiying the tab we always close | ||
actions.setSidePanelOpen(false) | ||
} else if (values.selectedTab === tab) { | ||
// Otherwise we only close it if the tab is the currently open one | ||
actions.setSidePanelOpen(false) | ||
} | ||
}, | ||
})), | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters