2021-05-07 09:20:55 -04:00
|
|
|
import { useTranslation } from 'react-i18next'
|
2021-03-18 05:52:36 -04:00
|
|
|
import FileTreeCreateNewDoc from './modes/file-tree-create-new-doc'
|
|
|
|
import FileTreeImportFromUrl from './modes/file-tree-import-from-url'
|
|
|
|
import FileTreeImportFromProject from './modes/file-tree-import-from-project'
|
|
|
|
import FileTreeModalCreateFileMode from './file-tree-modal-create-file-mode'
|
|
|
|
import FileTreeCreateNameProvider from '../../contexts/file-tree-create-name'
|
|
|
|
import { useFileTreeActionable } from '../../contexts/file-tree-actionable'
|
2022-01-10 10:47:01 -05:00
|
|
|
import { useFileTreeData } from '../../../../shared/context/file-tree-data-context'
|
2021-03-18 05:52:36 -04:00
|
|
|
|
|
|
|
import importOverleafModules from '../../../../../macros/import-overleaf-module.macro'
|
2023-10-17 04:41:40 -04:00
|
|
|
import { lazy, Suspense } from 'react'
|
|
|
|
import { FullSizeLoadingSpinner } from '@/shared/components/loading-spinner'
|
2024-06-18 06:01:37 -04:00
|
|
|
import getMeta from '@/utils/meta'
|
2024-09-25 09:46:02 -04:00
|
|
|
import { bsVersion } from '@/features/utils/bootstrap-5'
|
2021-03-18 05:52:36 -04:00
|
|
|
|
|
|
|
const createFileModeModules = importOverleafModules('createFileModes')
|
|
|
|
|
2023-10-17 04:41:40 -04:00
|
|
|
const FileTreeUploadDoc = lazy(() => import('./modes/file-tree-upload-doc'))
|
|
|
|
|
2021-03-18 05:52:36 -04:00
|
|
|
export default function FileTreeModalCreateFileBody() {
|
2021-05-07 09:20:55 -04:00
|
|
|
const { t } = useTranslation()
|
|
|
|
|
2021-03-18 05:52:36 -04:00
|
|
|
const { newFileCreateMode } = useFileTreeActionable()
|
2022-01-10 10:47:01 -05:00
|
|
|
const { fileCount } = useFileTreeData()
|
2024-06-18 06:01:37 -04:00
|
|
|
const {
|
|
|
|
hasLinkedProjectFileFeature,
|
|
|
|
hasLinkedProjectOutputFileFeature,
|
|
|
|
hasLinkUrlFeature,
|
|
|
|
} = getMeta('ol-ExposedSettings')
|
2021-03-18 05:52:36 -04:00
|
|
|
|
|
|
|
if (!fileCount || fileCount.status === 'error') {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
2024-09-25 09:46:02 -04:00
|
|
|
<td className="modal-new-file-list">
|
2021-03-18 05:52:36 -04:00
|
|
|
<ul className="list-unstyled">
|
|
|
|
<FileTreeModalCreateFileMode
|
|
|
|
mode="doc"
|
2024-09-25 09:46:02 -04:00
|
|
|
icon={bsVersion({ bs5: 'description', bs3: 'file' })}
|
2021-05-07 09:20:55 -04:00
|
|
|
label={t('new_file')}
|
2021-03-18 05:52:36 -04:00
|
|
|
/>
|
|
|
|
|
|
|
|
<FileTreeModalCreateFileMode
|
|
|
|
mode="upload"
|
|
|
|
icon="upload"
|
2021-05-07 09:20:55 -04:00
|
|
|
label={t('upload')}
|
2021-03-18 05:52:36 -04:00
|
|
|
/>
|
|
|
|
|
2024-06-18 06:01:37 -04:00
|
|
|
{(hasLinkedProjectFileFeature ||
|
|
|
|
hasLinkedProjectOutputFileFeature) && (
|
2021-07-30 04:57:41 -04:00
|
|
|
<FileTreeModalCreateFileMode
|
|
|
|
mode="project"
|
2024-09-25 09:46:02 -04:00
|
|
|
icon={bsVersion({ bs5: 'folder_open', bs3: 'folder-open' })}
|
2021-07-30 04:57:41 -04:00
|
|
|
label={t('from_another_project')}
|
|
|
|
/>
|
|
|
|
)}
|
2021-03-18 05:52:36 -04:00
|
|
|
|
2024-06-18 06:01:37 -04:00
|
|
|
{hasLinkUrlFeature && (
|
2021-03-18 05:52:36 -04:00
|
|
|
<FileTreeModalCreateFileMode
|
|
|
|
mode="url"
|
|
|
|
icon="globe"
|
2021-05-07 09:20:55 -04:00
|
|
|
label={t('from_external_url')}
|
2021-03-18 05:52:36 -04:00
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{createFileModeModules.map(
|
|
|
|
({ import: { CreateFileMode }, path }) => (
|
|
|
|
<CreateFileMode key={path} />
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
</ul>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td
|
2024-09-25 09:46:02 -04:00
|
|
|
className={`modal-new-file-body modal-new-file-body-${newFileCreateMode}`}
|
2021-03-18 05:52:36 -04:00
|
|
|
>
|
|
|
|
{newFileCreateMode === 'doc' && (
|
|
|
|
<FileTreeCreateNameProvider initialName="name.tex">
|
|
|
|
<FileTreeCreateNewDoc />
|
|
|
|
</FileTreeCreateNameProvider>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{newFileCreateMode === 'url' && (
|
|
|
|
<FileTreeCreateNameProvider>
|
|
|
|
<FileTreeImportFromUrl />
|
|
|
|
</FileTreeCreateNameProvider>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{newFileCreateMode === 'project' && (
|
|
|
|
<FileTreeCreateNameProvider>
|
|
|
|
<FileTreeImportFromProject />
|
|
|
|
</FileTreeCreateNameProvider>
|
|
|
|
)}
|
|
|
|
|
2023-10-17 04:41:40 -04:00
|
|
|
{newFileCreateMode === 'upload' && (
|
|
|
|
<Suspense fallback={<FullSizeLoadingSpinner delay={500} />}>
|
|
|
|
<FileTreeUploadDoc />
|
|
|
|
</Suspense>
|
|
|
|
)}
|
2021-03-18 05:52:36 -04:00
|
|
|
|
|
|
|
{createFileModeModules.map(
|
|
|
|
({ import: { CreateFilePane }, path }) => (
|
|
|
|
<CreateFilePane key={path} />
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
)
|
|
|
|
}
|