2024-07-15 09:12:58 +00:00
|
|
|
import type { Meta, StoryObj } from '@storybook/react'
|
2024-10-10 07:38:08 +00:00
|
|
|
import { LoadingUI } from '@/features/ide-react/components/loading'
|
2024-07-15 09:12:58 +00:00
|
|
|
import { EditorProviders } from '../../../test/frontend/helpers/editor-providers'
|
2024-10-10 07:26:18 +00:00
|
|
|
import { bsVersionDecorator } from '../../../.storybook/utils/with-bootstrap-switcher'
|
2024-07-15 09:12:58 +00:00
|
|
|
|
2024-10-10 07:38:08 +00:00
|
|
|
const meta: Meta<typeof LoadingUI> = {
|
2024-07-15 09:12:58 +00:00
|
|
|
title: 'Loading Page / Loading',
|
2024-10-10 07:38:08 +00:00
|
|
|
component: LoadingUI,
|
2024-07-15 09:12:58 +00:00
|
|
|
argTypes: {
|
2024-10-10 07:38:08 +00:00
|
|
|
errorCode: {
|
|
|
|
control: 'select',
|
|
|
|
options: [
|
|
|
|
'',
|
|
|
|
'io-not-loaded',
|
|
|
|
'unable-to-join',
|
|
|
|
'i18n-error',
|
|
|
|
'unhandled-error-code',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
progress: { control: { type: 'range', min: 0, max: 100 } },
|
2024-10-10 07:26:18 +00:00
|
|
|
...bsVersionDecorator.argTypes,
|
2024-07-15 09:12:58 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
export default meta
|
|
|
|
|
2024-10-10 07:38:08 +00:00
|
|
|
type Story = StoryObj<typeof LoadingUI>
|
|
|
|
|
|
|
|
const errorMessages = {
|
|
|
|
translationIoNotLoaded: 'Could not connect to the WebSocket server',
|
|
|
|
translationLoadErrorMessage: 'Could not load translations',
|
|
|
|
translationUnableToJoin: 'Could not connect to collaboration server',
|
|
|
|
}
|
2024-07-15 09:12:58 +00:00
|
|
|
|
|
|
|
export const LoadingPage: Story = {
|
2024-10-10 07:38:08 +00:00
|
|
|
render: args => {
|
|
|
|
for (const [key, value] of Object.entries(errorMessages)) {
|
|
|
|
window.metaAttributesCache.set(`ol-${key}`, value)
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<EditorProviders>
|
|
|
|
<LoadingUI {...args} />
|
|
|
|
</EditorProviders>
|
|
|
|
)
|
|
|
|
},
|
2024-07-15 09:12:58 +00:00
|
|
|
}
|