sentryAppInstallationsStore.tsx 787 B

12345678910111213141516171819202122232425262728293031323334
  1. import Reflux from 'reflux';
  2. import {SentryAppInstallation} from 'app/types';
  3. const SentryAppInstallationStore = Reflux.createStore({
  4. init() {
  5. this.items = [];
  6. },
  7. getInitialState(): SentryAppInstallation[] {
  8. return this.items;
  9. },
  10. load(items: SentryAppInstallation[]) {
  11. this.items = items;
  12. this.trigger(items);
  13. },
  14. get(uuid: string) {
  15. const items: SentryAppInstallation[] = this.items;
  16. return items.find(item => item.uuid === uuid);
  17. },
  18. getAll(): SentryAppInstallation[] {
  19. return this.items;
  20. },
  21. });
  22. type SentryAppInstallationStoreType = Reflux.Store & {
  23. load: (items: SentryAppInstallation[]) => void;
  24. getInitialState: () => SentryAppInstallation[];
  25. };
  26. export default SentryAppInstallationStore as SentryAppInstallationStoreType;