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 FileTreeUploadDoc from './modes/file-tree-upload-doc'
|
|
|
|
import FileTreeModalCreateFileMode from './file-tree-modal-create-file-mode'
|
|
|
|
import FileTreeCreateNameProvider from '../../contexts/file-tree-create-name'
|
|
|
|
import { useFileTreeActionable } from '../../contexts/file-tree-actionable'
|
|
|
|
import { useFileTreeMutable } from '../../contexts/file-tree-mutable'
|
|
|
|
|
|
|
|
import importOverleafModules from '../../../../../macros/import-overleaf-module.macro'
|
|
|
|
|
|
|
|
const createFileModeModules = importOverleafModules('createFileModes')
|
|
|
|
|
|
|
|
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()
|
|
|
|
const { fileCount } = useFileTreeMutable()
|
|
|
|
|
|
|
|
if (!fileCount || fileCount.status === 'error') {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<table>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td className="modal-new-file--list">
|
|
|
|
<ul className="list-unstyled">
|
|
|
|
<FileTreeModalCreateFileMode
|
|
|
|
mode="doc"
|
|
|
|
icon="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
|
|
|
/>
|
|
|
|
|
2021-07-30 04:57:41 -04:00
|
|
|
{(window.ExposedSettings.hasLinkedProjectFileFeature ||
|
|
|
|
window.ExposedSettings.hasLinkedProjectOutputFileFeature) && (
|
|
|
|
<FileTreeModalCreateFileMode
|
|
|
|
mode="project"
|
|
|
|
icon="folder-open"
|
|
|
|
label={t('from_another_project')}
|
|
|
|
/>
|
|
|
|
)}
|
2021-03-18 05:52:36 -04:00
|
|
|
|
|
|
|
{window.ExposedSettings.hasLinkUrlFeature && (
|
|
|
|
<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
|
|
|
|
className={`modal-new-file--body modal-new-file--body-${newFileCreateMode}`}
|
|
|
|
>
|
|
|
|
{newFileCreateMode === 'doc' && (
|
|
|
|
<FileTreeCreateNameProvider initialName="name.tex">
|
|
|
|
<FileTreeCreateNewDoc />
|
|
|
|
</FileTreeCreateNameProvider>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{newFileCreateMode === 'url' && (
|
|
|
|
<FileTreeCreateNameProvider>
|
|
|
|
<FileTreeImportFromUrl />
|
|
|
|
</FileTreeCreateNameProvider>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{newFileCreateMode === 'project' && (
|
|
|
|
<FileTreeCreateNameProvider>
|
|
|
|
<FileTreeImportFromProject />
|
|
|
|
</FileTreeCreateNameProvider>
|
|
|
|
)}
|
|
|
|
|
|
|
|
{newFileCreateMode === 'upload' && <FileTreeUploadDoc />}
|
|
|
|
|
|
|
|
{createFileModeModules.map(
|
|
|
|
({ import: { CreateFilePane }, path }) => (
|
|
|
|
<CreateFilePane key={path} />
|
|
|
|
)
|
|
|
|
)}
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
)
|
|
|
|
}
|