Skip to content

Commit a3dc819

Browse files
- first implementation of #1354
1 parent 4121519 commit a3dc819

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React, { Fragment, useState } from 'react';
2+
import { Modal } from '../../common';
3+
import { DJANGO_CONTEXT } from '../../../utils/djangoContext';
4+
5+
export const LegacySnapshotModal = ({ open, project, snapshot }) => {
6+
const [legacyLink, setLegacyLink] = useState('');
7+
8+
if (DJANGO_CONTEXT['legacy_url'] && DJANGO_CONTEXT['legacy_url'] !== '' && legacyLink === '') {
9+
setLegacyLink(`${DJANGO_CONTEXT['legacy_url']}/viewer/react/projects/${project}/${snapshot}`);
10+
}
11+
12+
return (
13+
<Modal open={open}>
14+
<h3>
15+
Snapshot is not recognized. Maybe it is available in the legacy system. Please try link below. <br />
16+
</h3>
17+
<a href={legacyLink} target="_blank">
18+
Legacy link
19+
</a>
20+
</Modal>
21+
);
22+
};

js/components/projects/projectPreview/index.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ import { restoreCurrentActionsList } from '../../../reducers/tracking/dispatchAc
88
import { setIsSnapshotDirty } from '../../../reducers/tracking/actions';
99
import { setDownloadStructuresDialogOpen } from '../../snapshot/redux/actions';
1010
import { ToastContext } from '../../toast';
11+
import { LegacySnapshotModal } from '../legacySnapshotModal';
1112

12-
export const ProjectPreview = memo(({ }) => {
13+
export const ProjectPreview = memo(({}) => {
1314
const { toast } = useContext(ToastContext);
1415
const [canShow, setCanShow] = useState(undefined);
1516
const isSnapshotLoaded = useRef(undefined);
@@ -23,6 +24,8 @@ export const ProjectPreview = memo(({ }) => {
2324
const isActionRestoring = useSelector(state => state.trackingReducers.isActionRestoring);
2425
const isActionRestored = useSelector(state => state.trackingReducers.isActionRestored);
2526

27+
const [showLegacySnapshotModal, setShowLegacySnapshotModal] = useState(false);
28+
2629
useEffect(() => {
2730
if (!snapshotId && currentSnapshotID === null) {
2831
dispatch(loadSnapshotByProjectID(projectId))
@@ -49,6 +52,7 @@ export const ProjectPreview = memo(({ }) => {
4952
setCanShow(true);
5053
} else {
5154
setCanShow(false);
55+
setShowLegacySnapshotModal(true);
5256
}
5357
if (response.data) {
5458
const dataObj = JSON.parse(response.data);
@@ -59,6 +63,7 @@ export const ProjectPreview = memo(({ }) => {
5963
} else {
6064
isSnapshotLoaded.current = response;
6165
setCanShow(false);
66+
setShowLegacySnapshotModal(true);
6267
}
6368
}
6469
})
@@ -96,5 +101,7 @@ export const ProjectPreview = memo(({ }) => {
96101
(currentSessionProject.projectID === null || currentSessionProject.authorID === null))
97102
}
98103
/>
99-
) : null;
104+
) : (
105+
<LegacySnapshotModal open={showLegacySnapshotModal} project={projectId} snapshot={snapshotId} />
106+
);
100107
});

0 commit comments

Comments
 (0)