sentryAppInstallationsStore.tsx 944 B

123456789101112131415161718192021222324252627282930313233343536
  1. import {createStore, StoreDefinition} from 'reflux';
  2. import {SentryAppInstallation} from 'sentry/types';
  3. import {makeSafeRefluxStore} from 'sentry/utils/makeSafeRefluxStore';
  4. interface SentryAppInstallationStoreDefinition extends StoreDefinition {
  5. getInitialState(): SentryAppInstallation[];
  6. load(items: SentryAppInstallation[]): void;
  7. }
  8. const storeConfig: SentryAppInstallationStoreDefinition = {
  9. init() {
  10. this.items = [];
  11. },
  12. getInitialState(): SentryAppInstallation[] {
  13. return this.items;
  14. },
  15. load(items: SentryAppInstallation[]) {
  16. this.items = items;
  17. this.trigger(items);
  18. },
  19. get(uuid: string) {
  20. const items: SentryAppInstallation[] = this.items;
  21. return items.find(item => item.uuid === uuid);
  22. },
  23. getAll(): SentryAppInstallation[] {
  24. return this.items;
  25. },
  26. };
  27. const SentryAppInstallationStore = createStore(makeSafeRefluxStore(storeConfig));
  28. export default SentryAppInstallationStore;