loading.stories.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 { bsVersionDecorator } from '../../../.storybook/utils/with-bootstrap-switcher'
  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. ...bsVersionDecorator.argTypes,
  21. },
  22. }
  23. export default meta
  24. type Story = StoryObj<typeof LoadingUI>
  25. const errorMessages = {
  26. translationIoNotLoaded: 'Could not connect to the WebSocket server',
  27. translationLoadErrorMessage: 'Could not load translations',
  28. translationUnableToJoin: 'Could not connect to collaboration server',
  29. }
  30. export const LoadingPage: Story = {
  31. render: args => {
  32. for (const [key, value] of Object.entries(errorMessages)) {
  33. window.metaAttributesCache.set(`ol-${key}`, value)
  34. }
  35. return (
  36. <EditorProviders>
  37. <LoadingUI {...args} />
  38. </EditorProviders>
  39. )
  40. },
  41. }