diff --git a/js/components/projects/legacySnapshotModal/index.js b/js/components/projects/legacySnapshotModal/index.js new file mode 100644 index 000000000..7ce0dc984 --- /dev/null +++ b/js/components/projects/legacySnapshotModal/index.js @@ -0,0 +1,22 @@ +import React, { Fragment, useState } from 'react'; +import { Modal } from '../../common'; +import { DJANGO_CONTEXT } from '../../../utils/djangoContext'; + +export const LegacySnapshotModal = ({ open, project, snapshot }) => { + const [legacyLink, setLegacyLink] = useState(''); + + if (DJANGO_CONTEXT['legacy_url'] && DJANGO_CONTEXT['legacy_url'] !== '' && legacyLink === '') { + setLegacyLink(`${DJANGO_CONTEXT['legacy_url']}/viewer/react/projects/${project}/${snapshot}`); + } + + return ( + +

+ Snapshot is not recognized. Maybe it is available in the legacy system. Please try link below.
+

+ + Legacy link + +
+ ); +}; diff --git a/js/components/projects/projectPreview/index.js b/js/components/projects/projectPreview/index.js index 287ffebf0..bfe1c7064 100644 --- a/js/components/projects/projectPreview/index.js +++ b/js/components/projects/projectPreview/index.js @@ -8,8 +8,9 @@ import { restoreCurrentActionsList } from '../../../reducers/tracking/dispatchAc import { setIsSnapshotDirty } from '../../../reducers/tracking/actions'; import { setDownloadStructuresDialogOpen } from '../../snapshot/redux/actions'; import { ToastContext } from '../../toast'; +import { LegacySnapshotModal } from '../legacySnapshotModal'; -export const ProjectPreview = memo(({ }) => { +export const ProjectPreview = memo(({}) => { const { toast } = useContext(ToastContext); const [canShow, setCanShow] = useState(undefined); const isSnapshotLoaded = useRef(undefined); @@ -23,6 +24,8 @@ export const ProjectPreview = memo(({ }) => { const isActionRestoring = useSelector(state => state.trackingReducers.isActionRestoring); const isActionRestored = useSelector(state => state.trackingReducers.isActionRestored); + const [showLegacySnapshotModal, setShowLegacySnapshotModal] = useState(false); + useEffect(() => { if (!snapshotId && currentSnapshotID === null) { dispatch(loadSnapshotByProjectID(projectId)) @@ -49,6 +52,7 @@ export const ProjectPreview = memo(({ }) => { setCanShow(true); } else { setCanShow(false); + setShowLegacySnapshotModal(true); } if (response.data) { const dataObj = JSON.parse(response.data); @@ -59,6 +63,7 @@ export const ProjectPreview = memo(({ }) => { } else { isSnapshotLoaded.current = response; setCanShow(false); + setShowLegacySnapshotModal(true); } } }) @@ -96,5 +101,7 @@ export const ProjectPreview = memo(({ }) => { (currentSessionProject.projectID === null || currentSessionProject.authorID === null)) } /> - ) : null; + ) : ( + + ); });