|
@@ -3,19 +3,21 @@ import Reflux from 'reflux';
|
|
|
|
|
|
import PageFiltersActions from 'sentry/actions/pageFiltersActions';
|
|
|
import {getDefaultSelection} from 'sentry/components/organizations/pageFilters/utils';
|
|
|
-import {Organization, PageFilters} from 'sentry/types';
|
|
|
+import {Organization, PageFilters, PinnedPageFilter} from 'sentry/types';
|
|
|
import {isEqualWithDates} from 'sentry/utils/isEqualWithDates';
|
|
|
|
|
|
import {CommonStoreInterface} from './types';
|
|
|
|
|
|
type State = {
|
|
|
selection: PageFilters;
|
|
|
+ pinnedFilters: Set<PinnedPageFilter>;
|
|
|
organization: Organization | null;
|
|
|
isReady: boolean;
|
|
|
};
|
|
|
|
|
|
type Internals = {
|
|
|
selection: PageFilters;
|
|
|
+ pinnedFilters: Set<PinnedPageFilter>;
|
|
|
hasInitialState: boolean;
|
|
|
organization: Organization | null;
|
|
|
};
|
|
@@ -28,10 +30,12 @@ type PageFiltersStoreInterface = CommonStoreInterface<State> & {
|
|
|
updateProjects(projects: PageFilters['projects'], environments: null | string[]): void;
|
|
|
updateDateTime(datetime: PageFilters['datetime']): void;
|
|
|
updateEnvironments(environments: string[]): void;
|
|
|
+ pin(filter: PinnedPageFilter, pin: boolean): void;
|
|
|
};
|
|
|
|
|
|
const storeConfig: Reflux.StoreDefinition & Internals & PageFiltersStoreInterface = {
|
|
|
selection: getDefaultSelection(),
|
|
|
+ pinnedFilters: new Set(),
|
|
|
hasInitialState: false,
|
|
|
organization: null,
|
|
|
|
|
@@ -43,6 +47,7 @@ const storeConfig: Reflux.StoreDefinition & Internals & PageFiltersStoreInterfac
|
|
|
this.listenTo(PageFiltersActions.updateProjects, this.updateProjects);
|
|
|
this.listenTo(PageFiltersActions.updateDateTime, this.updateDateTime);
|
|
|
this.listenTo(PageFiltersActions.updateEnvironments, this.updateEnvironments);
|
|
|
+ this.listenTo(PageFiltersActions.pin, this.pin);
|
|
|
},
|
|
|
|
|
|
reset(selection) {
|
|
@@ -65,9 +70,9 @@ const storeConfig: Reflux.StoreDefinition & Internals & PageFiltersStoreInterfac
|
|
|
|
|
|
getState() {
|
|
|
const isReady = this._hasInitialState;
|
|
|
- const {selection, organization} = this;
|
|
|
+ const {selection, pinnedFilters, organization} = this;
|
|
|
|
|
|
- return {selection, isReady, organization};
|
|
|
+ return {selection, pinnedFilters, isReady, organization};
|
|
|
},
|
|
|
|
|
|
onReset() {
|
|
@@ -111,6 +116,16 @@ const storeConfig: Reflux.StoreDefinition & Internals & PageFiltersStoreInterfac
|
|
|
};
|
|
|
this.trigger(this.getState());
|
|
|
},
|
|
|
+
|
|
|
+ pin(filter, pin) {
|
|
|
+ if (pin) {
|
|
|
+ this.pinnedFilters.add(filter);
|
|
|
+ } else {
|
|
|
+ this.pinnedFilters.delete(filter);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.trigger(this.getState());
|
|
|
+ },
|
|
|
};
|
|
|
|
|
|
const PageFiltersStore = Reflux.createStore(storeConfig) as Reflux.Store &
|