ChatModerationActionMenu.stories.tsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import React from 'react';
  2. import { ComponentStory, ComponentMeta } from '@storybook/react';
  3. import { RecoilRoot } from 'recoil';
  4. import { ChatModerationActionMenu } from './ChatModerationActionMenu';
  5. const mocks = {
  6. mocks: [
  7. {
  8. // The "matcher" determines if this
  9. // mock should respond to the current
  10. // call to fetch().
  11. matcher: {
  12. name: 'response',
  13. url: 'glob:/api/moderation/chat/user/*',
  14. },
  15. // If the "matcher" matches the current
  16. // fetch() call, the fetch response is
  17. // built using this "response".
  18. response: {
  19. status: 200,
  20. body: {
  21. user: {
  22. id: 'hjFPU967R',
  23. displayName: 'focused-snyder',
  24. displayColor: 2,
  25. createdAt: '2022-07-12T13:08:31.406505322-07:00',
  26. previousNames: ['focused-snyder'],
  27. scopes: ['MODERATOR'],
  28. isBot: false,
  29. authenticated: false,
  30. },
  31. connectedClients: [
  32. {
  33. messageCount: 3,
  34. userAgent:
  35. 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36',
  36. connectedAt: '2022-07-20T16:45:07.796685618-07:00',
  37. geo: 'N/A',
  38. },
  39. ],
  40. messages: [
  41. {
  42. id: 'bQp8UJR4R',
  43. timestamp: '2022-07-20T16:53:41.938083228-07:00',
  44. user: null,
  45. body: 'test message 3',
  46. },
  47. {
  48. id: 'ubK88Jg4R',
  49. timestamp: '2022-07-20T16:53:39.675531279-07:00',
  50. user: null,
  51. body: 'test message 2',
  52. },
  53. {
  54. id: '20v8UJRVR',
  55. timestamp: '2022-07-20T16:53:37.551084121-07:00',
  56. user: null,
  57. body: 'test message 1',
  58. },
  59. ],
  60. },
  61. },
  62. },
  63. ],
  64. };
  65. export default {
  66. title: 'owncast/Chat/Moderation menu',
  67. component: ChatModerationActionMenu,
  68. parameters: {
  69. fetchMock: mocks,
  70. docs: {
  71. description: {
  72. component: `This should be a popup that is activated from a user's chat message. It should have actions to:
  73. - Remove single message
  74. - Ban user completely
  75. - Open modal to see user details
  76. `,
  77. },
  78. },
  79. },
  80. } as ComponentMeta<typeof ChatModerationActionMenu>;
  81. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  82. const Template: ComponentStory<typeof ChatModerationActionMenu> = () => (
  83. <RecoilRoot>
  84. <ChatModerationActionMenu
  85. accessToken="abc123"
  86. messageID="xxx"
  87. userDisplayName="Fake-User"
  88. userID="abc123"
  89. />
  90. </RecoilRoot>
  91. );
  92. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  93. export const Basic = Template.bind({});