demoWalkthroughStore.tsx 1.3 KB

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