sentryAppInstallationsStore.tsx 853 B

1234567891011121314151617181920212223242526272829303132333435
  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. this.items = [];
  10. },
  11. getInitialState(): SentryAppInstallation[] {
  12. return this.items;
  13. },
  14. load(items: SentryAppInstallation[]) {
  15. this.items = items;
  16. this.trigger(items);
  17. },
  18. get(uuid: string) {
  19. const items: SentryAppInstallation[] = this.items;
  20. return items.find(item => item.uuid === uuid);
  21. },
  22. getAll(): SentryAppInstallation[] {
  23. return this.items;
  24. },
  25. };
  26. const SentryAppInstallationStore = createStore(storeConfig);
  27. export default SentryAppInstallationStore;