12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import {createStore} from 'reflux';
- import type {SidebarPanelKey} from 'sentry/components/sidebar/types';
- import type {CommonStoreDefinition} from './types';
- type ActivePanelType = SidebarPanelKey | '';
- interface SidebarPanelStoreDefinition extends CommonStoreDefinition<ActivePanelType> {
- activatePanel(panel: SidebarPanelKey): void;
- activePanel: ActivePanelType;
- hidePanel(hash?: string): 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(hash?: string) {
- this.activePanel = '';
- if (hash) {
- window.location.hash = window.location.hash.replace(`#${hash}`, '');
- }
- this.trigger(this.activePanel);
- },
- getState() {
- return this.activePanel;
- },
- };
- const SidebarPanelStore = createStore(storeConfig);
- export default SidebarPanelStore;
|