1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- import {createStore} from 'reflux';
- import {SidebarPanelKey} from 'sentry/components/sidebar/types';
- import {CommonStoreDefinition} from './types';
- type ActivePanelType = SidebarPanelKey | '';
- interface SidebarPanelStoreDefinition extends CommonStoreDefinition<ActivePanelType> {
- activatePanel(panel: SidebarPanelKey): void;
- activePanel: ActivePanelType;
- hidePanel(): void;
- togglePanel(panel: SidebarPanelKey): void;
- }
- const storeConfig: SidebarPanelStoreDefinition = {
- activePanel: '',
- init() {
-
-
- },
- activatePanel(panel: SidebarPanelKey) {
- this.activePanel = panel;
- this.trigger(this.activePanel);
- },
- togglePanel(panel: SidebarPanelKey) {
- if (this.activePanel === panel) {
- this.hidePanel();
- } else {
- this.activatePanel(panel);
- }
- },
- hidePanel() {
- this.activePanel = '';
- this.trigger(this.activePanel);
- },
- getState() {
- return this.activePanel;
- },
- };
- const SidebarPanelStore = createStore(storeConfig);
- export default SidebarPanelStore;
|