2021-06-10 07:27:27 -04:00
|
|
|
import {
|
|
|
|
createFileModalDecorator,
|
|
|
|
mockCreateFileModalFetch,
|
|
|
|
} from './create-file-modal-decorator'
|
2021-03-18 05:52:36 -04:00
|
|
|
import FileTreeModalCreateFile from '../../../js/features/file-tree/components/modals/file-tree-modal-create-file'
|
2021-06-10 07:27:27 -04:00
|
|
|
import useFetchMock from '../../hooks/use-fetch-mock'
|
2022-05-16 05:38:20 -04:00
|
|
|
import { ScopeDecorator } from '../../decorators/scope'
|
|
|
|
import { useScope } from '../../hooks/use-scope'
|
2024-06-18 06:01:37 -04:00
|
|
|
import getMeta from '@/utils/meta'
|
2024-10-10 03:26:18 -04:00
|
|
|
import { bsVersionDecorator } from '../../../../.storybook/utils/with-bootstrap-switcher'
|
2021-03-18 05:52:36 -04:00
|
|
|
|
2021-06-10 07:27:27 -04:00
|
|
|
export const MinimalFeatures = args => {
|
|
|
|
useFetchMock(mockCreateFileModalFetch)
|
2024-06-18 06:01:37 -04:00
|
|
|
Object.assign(getMeta('ol-ExposedSettings'), {
|
|
|
|
hasLinkUrlFeature: false,
|
|
|
|
hasLinkedProjectFileFeature: false,
|
|
|
|
hasLinkedProjectOutputFileFeature: false,
|
|
|
|
})
|
2021-06-10 07:27:27 -04:00
|
|
|
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
|
|
}
|
2022-01-10 10:46:46 -05:00
|
|
|
MinimalFeatures.decorators = [createFileModalDecorator()]
|
2021-03-18 05:52:36 -04:00
|
|
|
|
2021-06-10 07:27:27 -04:00
|
|
|
export const WithExtraFeatures = args => {
|
|
|
|
useFetchMock(mockCreateFileModalFetch)
|
|
|
|
|
2024-06-18 06:01:37 -04:00
|
|
|
getMeta('ol-ExposedSettings').hasLinkUrlFeature = true
|
2021-06-10 07:27:27 -04:00
|
|
|
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
|
|
}
|
|
|
|
WithExtraFeatures.decorators = [
|
|
|
|
createFileModalDecorator({
|
|
|
|
refProviders: { mendeley: true, zotero: true },
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
|
|
|
|
export const ErrorImportingFileFromExternalURL = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
mockCreateFileModalFetch(fetchMock)
|
|
|
|
|
|
|
|
fetchMock.post('express:/project/:projectId/linked_file', 500, {
|
|
|
|
overwriteRoutes: true,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2024-06-18 06:01:37 -04:00
|
|
|
getMeta('ol-ExposedSettings').hasLinkUrlFeature = true
|
2021-06-10 07:27:27 -04:00
|
|
|
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
|
|
}
|
|
|
|
ErrorImportingFileFromExternalURL.decorators = [createFileModalDecorator()]
|
|
|
|
|
|
|
|
export const ErrorImportingFileFromReferenceProvider = args => {
|
|
|
|
useFetchMock(fetchMock => {
|
|
|
|
mockCreateFileModalFetch(fetchMock)
|
|
|
|
|
|
|
|
fetchMock.post('express:/project/:projectId/linked_file', 500, {
|
|
|
|
overwriteRoutes: true,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
|
|
}
|
|
|
|
ErrorImportingFileFromReferenceProvider.decorators = [
|
|
|
|
createFileModalDecorator({
|
|
|
|
refProviders: { mendeley: true, zotero: true },
|
|
|
|
}),
|
|
|
|
]
|
|
|
|
|
|
|
|
export const FileLimitReached = args => {
|
|
|
|
useFetchMock(mockCreateFileModalFetch)
|
2021-03-18 05:52:36 -04:00
|
|
|
|
2022-05-16 05:38:20 -04:00
|
|
|
useScope({
|
|
|
|
project: {
|
|
|
|
rootFolder: {
|
|
|
|
_id: 'root-folder-id',
|
|
|
|
name: 'rootFolder',
|
|
|
|
docs: Array.from({ length: 10 }, (_, index) => ({
|
|
|
|
_id: `entity-${index}`,
|
|
|
|
})),
|
|
|
|
fileRefs: [],
|
|
|
|
folders: [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2021-06-10 07:27:27 -04:00
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
|
|
}
|
2022-05-16 05:38:20 -04:00
|
|
|
FileLimitReached.decorators = [createFileModalDecorator()]
|
2021-03-18 05:52:36 -04:00
|
|
|
|
|
|
|
export default {
|
2022-03-28 06:23:21 -04:00
|
|
|
title: 'Editor / Modals / Create File',
|
2021-04-27 03:52:58 -04:00
|
|
|
component: FileTreeModalCreateFile,
|
2022-05-16 05:38:20 -04:00
|
|
|
decorators: [ScopeDecorator],
|
2024-10-10 03:26:18 -04:00
|
|
|
argTypes: {
|
|
|
|
...bsVersionDecorator.argTypes,
|
|
|
|
},
|
2021-03-18 05:52:36 -04:00
|
|
|
}
|