sentryAppInstallationsStore.tsx 890 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import Reflux from 'reflux';
  2. import {SentryAppInstallation} from 'sentry/types';
  3. type SentryAppInstallationStoreInterface = {
  4. load(items: SentryAppInstallation[]): void;
  5. getInitialState(): SentryAppInstallation[];
  6. };
  7. const storeConfig: Reflux.StoreDefinition & SentryAppInstallationStoreInterface = {
  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 = Reflux.createStore(storeConfig) as Reflux.Store &
  27. SentryAppInstallationStoreInterface;
  28. export default SentryAppInstallationStore;