diff --git a/CHANGELOG-improve-redirect-toast.md b/CHANGELOG-improve-redirect-toast.md new file mode 100644 index 0000000000..c92bcc9bff --- /dev/null +++ b/CHANGELOG-improve-redirect-toast.md @@ -0,0 +1 @@ +- Update Unified View redirect toast to be more informative. \ No newline at end of file diff --git a/context/app/routes_browse.py b/context/app/routes_browse.py index e07006397e..eab35b8d87 100644 --- a/context/app/routes_browse.py +++ b/context/app/routes_browse.py @@ -78,7 +78,9 @@ def details(type, uuid): type='dataset', uuid=supported_entity[0]['uuid'], _anchor=anchor, - redirected=True)) + redirected=True, + redirectedFromId=entity.get('hubmap_id'), + redirectedFromPipeline=entity.get('pipeline'))) if type != actual_type: return redirect(url_for('routes_browse.details', type=actual_type, uuid=uuid)) @@ -89,6 +91,8 @@ def details(type, uuid): **get_default_flask_data(), 'entity': entity, 'redirected': redirected, + 'redirectedFromId': request.args.get('redirectedFromId'), + 'redirectedFromPipeline': request.args.get('redirectedFromPipeline') } if type == 'publication': diff --git a/context/app/static/js/components/Contexts.tsx b/context/app/static/js/components/Contexts.tsx index 2c32016779..4bc4e484d7 100644 --- a/context/app/static/js/components/Contexts.tsx +++ b/context/app/static/js/components/Contexts.tsx @@ -10,6 +10,8 @@ export interface FlaskDataContextType { title: string; // preview page title vis_lifted_uuid?: string; redirected?: boolean; + redirectedFromId?: string | null; + redirectedFromPipeline?: string | null; } export const FlaskDataContext = createContext('FlaskDataContext'); diff --git a/context/app/static/js/pages/Dataset/hooks.ts b/context/app/static/js/pages/Dataset/hooks.ts index 9fc0ed1a7f..285cf8cebe 100644 --- a/context/app/static/js/pages/Dataset/hooks.ts +++ b/context/app/static/js/pages/Dataset/hooks.ts @@ -177,13 +177,20 @@ function useProcessedDatasetsSections(): { sections: TableOfContentsItem | false } export function useRedirectAlert() { - const { redirected } = useFlaskDataContext(); + const { redirected, redirectedFromId, redirectedFromPipeline } = useFlaskDataContext(); const { toastInfo } = useSnackbarActions(); + useEffect(() => { if (redirected) { - toastInfo('You have been redirected to the unified view for this dataset.'); + if (redirectedFromId && redirectedFromPipeline) { + toastInfo( + `You have been redirected to the unified view for ${redirectedFromPipeline} dataset ${redirectedFromId}.`, + ); + } else { + toastInfo('You have been redirected to the unified view for this dataset.'); + } } - }, [redirected, toastInfo]); + }, [redirected, toastInfo, redirectedFromId, redirectedFromPipeline]); } export { useProcessedDatasets, useProcessedDatasetsSections };