note.stories.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import {useState} from 'react';
  2. import {action} from '@storybook/addon-actions';
  3. import Note from 'sentry/components/activity/note';
  4. import ConfigStore from 'sentry/stores/configStore';
  5. import MemberListStore from 'sentry/stores/memberListStore';
  6. import ProjectsStore from 'sentry/stores/projectsStore';
  7. const user = {
  8. username: 'billy@sentry.io',
  9. identities: [],
  10. id: '1',
  11. name: 'billy',
  12. dateJoined: '2019-03-09T06:52:42.836Z',
  13. avatar: {avatarUuid: null, avatarType: 'letter_avatar'},
  14. email: 'billy@sentry.io',
  15. };
  16. const activity = {id: '123', data: {text: 'hello'}, dateCreated: new Date()};
  17. ConfigStore.set('user', {...user, isSuperuser: true, options: {}});
  18. ProjectsStore.loadInitialData([
  19. {
  20. id: '2',
  21. slug: 'project-slug',
  22. name: 'project-slug',
  23. hasAccess: true,
  24. isMember: true,
  25. isBookmarked: false,
  26. teams: [
  27. {
  28. id: '1',
  29. slug: 'team-slug',
  30. name: 'Team Name',
  31. isMember: true,
  32. memberCount: 0,
  33. },
  34. ],
  35. },
  36. ]);
  37. MemberListStore.loadInitialData([
  38. {
  39. username: 'doug@sentry.io',
  40. id: '2',
  41. name: 'doug',
  42. dateJoined: '2019-03-09T06:52:42.836Z',
  43. avatar: {avatarUuid: null, avatarType: 'letter_avatar'},
  44. email: 'doug@sentry.io',
  45. },
  46. ]);
  47. export default {
  48. title: 'Views/Activity/Activity Note',
  49. component: Note,
  50. };
  51. export const Default = () => {
  52. const [text, setText] = useState(activity.data.text);
  53. return (
  54. <Note
  55. showTime
  56. authorName={user.name}
  57. user={user}
  58. text={text}
  59. modelId={activity.id}
  60. dateCreated={activity.dateCreated}
  61. projectSlugs={['project-slug']}
  62. minHeight={200}
  63. onUpdate={(...props) => {
  64. action('Updated item', props);
  65. setText(props[0].text);
  66. }}
  67. onDelete={action('Deleted item')}
  68. />
  69. );
  70. };
  71. Default.storyName = 'Note';
  72. Default.parameters = {
  73. docs: {
  74. description: {
  75. story:
  76. 'A `<Note>` is an `<ActivityItem>` that can be edited with an editor. The editor has an input mode and a preview mode.',
  77. },
  78. },
  79. };