loading.stories.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import type { Meta, StoryObj } from '@storybook/react'
  2. import { LoadingUI } from '@/features/ide-react/components/loading'
  3. import { EditorProviders } from '../../../test/frontend/helpers/editor-providers'
  4. import { PartialMeta } from '@/utils/meta'
  5. const meta: Meta<typeof LoadingUI> = {
  6. title: 'Loading Page / Loading',
  7. component: LoadingUI,
  8. argTypes: {
  9. errorCode: {
  10. control: 'select',
  11. options: [
  12. '',
  13. 'io-not-loaded',
  14. 'unable-to-join',
  15. 'i18n-error',
  16. 'unhandled-error-code',
  17. ],
  18. },
  19. progress: { control: { type: 'range', min: 0, max: 100 } },
  20. },
  21. }
  22. export default meta
  23. type Story = StoryObj<typeof LoadingUI>
  24. const errorMessages = {
  25. translationIoNotLoaded: 'Could not connect to the WebSocket server',
  26. translationLoadErrorMessage: 'Could not load translations',
  27. translationUnableToJoin: 'Could not connect to collaboration server',
  28. }
  29. export const LoadingPage: Story = {
  30. render: args => {
  31. for (const [key, value] of Object.entries(errorMessages)) {
  32. window.metaAttributesCache.set(`ol-${key}` as keyof PartialMeta, value)
  33. }
  34. return (
  35. <EditorProviders>
  36. <LoadingUI {...args} />
  37. </EditorProviders>
  38. )
  39. },
  40. }