loading.stories.tsx 1.3 KB

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