From 34e7f3182be30c748fdcd95b580ec3461bf12f83 Mon Sep 17 00:00:00 2001 From: Alexandre Bourdin Date: Mon, 5 Aug 2024 14:35:56 +0200 Subject: [PATCH] Merge pull request #19747 from overleaf/ab-v1-project-import-module [web] Extract code to v1-projects module GitOrigin-RevId: 8f8a99891d3a1505aafca08f06fb439d4b596899 --- services/web/config/settings.defaults.js | 1 + .../components/token-access-root.tsx | 22 +++-- .../components/v1-import-data-screen.tsx | 84 ------------------- 3 files changed, 17 insertions(+), 90 deletions(-) delete mode 100644 services/web/frontend/js/features/token-access/components/v1-import-data-screen.tsx diff --git a/services/web/config/settings.defaults.js b/services/web/config/settings.defaults.js index 2bd74880ac..d587d683d1 100644 --- a/services/web/config/settings.defaults.js +++ b/services/web/config/settings.defaults.js @@ -900,6 +900,7 @@ module.exports = { userNotifications: [], managedGroupEnrollmentInvite: [], ssoCertificateInfo: [], + v1ImportDataScreen: [], }, moduleImportSequence: [ diff --git a/services/web/frontend/js/features/token-access/components/token-access-root.tsx b/services/web/frontend/js/features/token-access/components/token-access-root.tsx index 6cef2f3be2..1e8865c90f 100644 --- a/services/web/frontend/js/features/token-access/components/token-access-root.tsx +++ b/services/web/frontend/js/features/token-access/components/token-access-root.tsx @@ -1,24 +1,34 @@ import useWaitForI18n from '@/shared/hooks/use-wait-for-i18n' import withErrorBoundary from '@/infrastructure/error-boundary' import { GenericErrorBoundaryFallback } from '@/shared/components/generic-error-boundary-fallback' -import { useCallback, useEffect, useRef, useState } from 'react' +import { ElementType, useCallback, useEffect, useRef, useState } from 'react' import getMeta from '@/utils/meta' import { postJSON } from '@/infrastructure/fetch-json' import { debugConsole } from '@/utils/debugging' import { useLocation } from '@/shared/hooks/use-location' -import { - V1ImportData, - V1ImportDataScreen, -} from '@/features/token-access/components/v1-import-data-screen' import { AccessAttemptScreen } from '@/features/token-access/components/access-attempt-screen' import { RequireAcceptData, RequireAcceptScreen, } from '@/features/token-access/components/require-accept-screen' import Icon from '@/shared/components/icon' +import importOverleafModules from '../../../../macros/import-overleaf-module.macro' type Mode = 'access-attempt' | 'v1Import' | 'requireAccept' +const [v1ImportDataScreenModule] = importOverleafModules( + 'v1ImportDataScreen' +) as { + import: { default: ElementType } +}[] +const V1ImportDataScreen = v1ImportDataScreenModule?.import.default + +export type V1ImportData = { + name?: string + status: string + projectId: string +} + function TokenAccessRoot() { const [mode, setMode] = useState('access-attempt') const [inflight, setInflight] = useState(false) @@ -124,7 +134,7 @@ function TokenAccessRoot() { /> )} - {mode === 'v1Import' && v1ImportData && ( + {V1ImportDataScreen && mode === 'v1Import' && v1ImportData && ( )} diff --git a/services/web/frontend/js/features/token-access/components/v1-import-data-screen.tsx b/services/web/frontend/js/features/token-access/components/v1-import-data-screen.tsx deleted file mode 100644 index 947f041d53..0000000000 --- a/services/web/frontend/js/features/token-access/components/v1-import-data-screen.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { FC } from 'react' - -export type V1ImportData = { - name?: string - status: string - projectId: string -} -export const V1ImportDataScreen: FC<{ v1ImportData: V1ImportData }> = ({ - v1ImportData, -}) => { - return ( -
-
-
-
-

- {v1ImportData.status === 'mustLogin' - ? 'Please log in' - : 'Overleaf v1 Project'} -

- - The new V2 editor. - - {v1ImportData.status === 'cannotImport' && ( -
-

- Cannot Access Overleaf v1 Project -

- -

- Please contact the project owner or{' '} - contact support for assistance. -

-
- )} - - {v1ImportData.status === 'mustLogin' && ( -
-

- You will need to log in to access this project. -

- - -
- )} - - {v1ImportData.status === 'canDownloadZip' && ( -
-

- {v1ImportData.name || 'This project'} has not - yet been moved into the new version of Overleaf. This project - was created anonymously and therefore cannot be automatically - imported. Please download a zip file of the project and upload - that to continue editing it. If you would like to delete this - project after you have made a copy, please contact support. -

- - -
- )} -
-
-
-
- ) -}