From 77c66866affe622ed321e8eabcd1aefb76e57b48 Mon Sep 17 00:00:00 2001 From: boriskovar-m2ms Date: Tue, 27 Aug 2024 13:51:17 +0200 Subject: [PATCH] #1489 (#443) * Squashed commit of the following: commit e61321646b0f62c6ba81ca8dbbb8a328405819c4 Author: Boris Kovar Date: Wed Jul 31 13:57:02 2024 +0200 - implemented #1251 * #1482 added TagName and CentroidRes columns for expanded view of observation dialog * #1489 show warning toast message if is defined on target load --------- Co-authored-by: matej --- js/components/preview/TASPreview.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/js/components/preview/TASPreview.js b/js/components/preview/TASPreview.js index f70dba420..ca6b15fc8 100644 --- a/js/components/preview/TASPreview.js +++ b/js/components/preview/TASPreview.js @@ -1,4 +1,4 @@ -import React, { memo, useEffect } from 'react'; +import React, { memo, useContext, useEffect } from 'react'; import { useDispatch, useSelector } from 'react-redux'; import { useHistory, useRouteMatch } from 'react-router-dom'; import { URLS } from '../routes/constants'; @@ -6,6 +6,8 @@ import { setCurrentProject, setOpenPickProjectModal } from '../target/redux/acti import Preview from './Preview'; import { getProjectForProjectName, getProjectsForSelectedTarget } from './redux/dispatchActions'; import { extractProjectFromURLParam } from './utils'; +import { ToastContext } from '../toast'; +import { DJANGO_CONTEXT } from '../../utils/djangoContext'; export const TASPreview = memo(props => { let match = useRouteMatch(); @@ -17,6 +19,8 @@ export const TASPreview = memo(props => { const targetList = useSelector(state => state.apiReducers.target_id_list); const projectsLoaded = useSelector(state => state.targetReducers.projectsLoaded); + const { toastWarning } = useContext(ToastContext); + useEffect(() => { let project = null; if ( @@ -49,5 +53,11 @@ export const TASPreview = memo(props => { } }, [dispatch, currentPorject, match, history, currentTarget, targetList, projectsLoaded]); + useEffect(() => { + if (DJANGO_CONTEXT.target_warning_message && DJANGO_CONTEXT.target_warning_message.length > 0) { + toastWarning(DJANGO_CONTEXT.target_warning_message); + } + }, [toastWarning]); + return ; });