demoWalkthroughStore.tsx 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import type {StoreDefinition} from 'reflux';
  2. import {createStore} from 'reflux';
  3. import {OnboardingTaskKey} from 'sentry/types';
  4. interface DemoWalkthroughStoreDefinition extends StoreDefinition {
  5. activateGuideAnchor(guide: string): void;
  6. get(guide: string): boolean;
  7. }
  8. const storeConfig: DemoWalkthroughStoreDefinition = {
  9. issueGuideAnchor: false,
  10. sidebarGuideAnchor: false,
  11. init() {
  12. // XXX: Do not use `this.listenTo` in this store. We avoid usage of reflux
  13. // listeners due to their leaky nature in tests.
  14. },
  15. activateGuideAnchor(task: OnboardingTaskKey) {
  16. switch (task) {
  17. case OnboardingTaskKey.ISSUE_GUIDE:
  18. this.issueGuideAnchor = true;
  19. this.trigger(this.issueGuideAnchor);
  20. break;
  21. case OnboardingTaskKey.SIDEBAR_GUIDE:
  22. this.sidebarGuideAnchor = true;
  23. this.trigger(this.sidebarGuideAnchor);
  24. break;
  25. default:
  26. }
  27. },
  28. get(guide: string) {
  29. switch (guide) {
  30. case 'issue':
  31. return this.issueGuideAnchor;
  32. case 'sidebar':
  33. return this.sidebarGuideAnchor;
  34. default:
  35. return false;
  36. }
  37. },
  38. };
  39. /**
  40. * This store is used to hold local user preferences
  41. * Side-effects (like reading/writing to cookies) are done in associated actionCreators
  42. */
  43. const DemoWalkthroughStore = createStore(storeConfig);
  44. export default DemoWalkthroughStore;