sentryAppInstallationsStore.tsx 986 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import {createStore, StoreDefinition} from 'reflux';
  2. import {SentryAppInstallation} from 'sentry/types';
  3. interface SentryAppInstallationStoreDefinition extends StoreDefinition {
  4. getInitialState(): SentryAppInstallation[];
  5. load(items: SentryAppInstallation[]): void;
  6. }
  7. const storeConfig: SentryAppInstallationStoreDefinition = {
  8. init() {
  9. // XXX: Do not use `this.listenTo` in this store. We avoid usage of reflux
  10. // listeners due to their leaky nature in tests.
  11. this.items = [];
  12. },
  13. getInitialState(): SentryAppInstallation[] {
  14. return this.items;
  15. },
  16. load(items: SentryAppInstallation[]) {
  17. this.items = items;
  18. this.trigger(items);
  19. },
  20. get(uuid: string) {
  21. const items: SentryAppInstallation[] = this.items;
  22. return items.find(item => item.uuid === uuid);
  23. },
  24. getAll(): SentryAppInstallation[] {
  25. return this.items;
  26. },
  27. };
  28. const SentryAppInstallationStore = createStore(storeConfig);
  29. export default SentryAppInstallationStore;