mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 02:48:47 -05:00
7c97f8ab6e
* Use new JSX runtime and update Babel Node target * Update .eslintrc * Remove React imports GitOrigin-RevId: 559de0267f8f2934c56a860ea8701bb522aa861a
101 lines
2.5 KiB
JavaScript
101 lines
2.5 KiB
JavaScript
import { useEffect } from 'react'
|
|
import {
|
|
createFileModalDecorator,
|
|
mockCreateFileModalFetch,
|
|
} from './create-file-modal-decorator'
|
|
import FileTreeModalCreateFile from '../../../js/features/file-tree/components/modals/file-tree-modal-create-file'
|
|
import useFetchMock from '../../hooks/use-fetch-mock'
|
|
|
|
export const MinimalFeatures = args => {
|
|
useFetchMock(mockCreateFileModalFetch)
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
}
|
|
MinimalFeatures.decorators = [
|
|
createFileModalDecorator({
|
|
userHasFeature: () => false,
|
|
}),
|
|
]
|
|
|
|
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)
|
|
|
|
return <FileTreeModalCreateFile {...args} />
|
|
}
|
|
FileLimitReached.decorators = [
|
|
createFileModalDecorator({
|
|
rootFolder: [
|
|
{
|
|
docs: Array.from({ length: 10 }, (_, index) => ({
|
|
_id: `entity-${index}`,
|
|
})),
|
|
fileRefs: [],
|
|
folders: [],
|
|
},
|
|
],
|
|
}),
|
|
]
|
|
|
|
export default {
|
|
title: 'Modals / Create File',
|
|
component: FileTreeModalCreateFile,
|
|
}
|