2021-06-23 05:37:08 -04:00
|
|
|
import { useEffect } from 'react'
|
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'
|
2021-03-18 05:52:36 -04:00
|
|
|
|
2021-06-10 07:27:27 -04:00
|
|
|
export const MinimalFeatures = args => {
|
|
|
|
useFetchMock(mockCreateFileModalFetch)
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const originalValue = window.ExposedSettings.hasLinkUrlFeature
|
|
|
|
window.ExposedSettings.hasLinkUrlFeature = true
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
window.ExposedSettings.hasLinkUrlFeature = originalValue
|
|
|
|
}
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
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,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const originalValue = window.ExposedSettings.hasLinkUrlFeature
|
|
|
|
window.ExposedSettings.hasLinkUrlFeature = true
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
window.ExposedSettings.hasLinkUrlFeature = originalValue
|
|
|
|
}
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
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],
|
2021-03-18 05:52:36 -04:00
|
|
|
}
|