Skip to content

Commit

Permalink
#1489 show warning toast message if is defined on target load
Browse files Browse the repository at this point in the history
  • Loading branch information
matej-vavrek committed Aug 27, 2024
1 parent 8817d77 commit 6af83d0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion js/components/preview/TASPreview.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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';
import { setCurrentProject, setOpenPickProjectModal } from '../target/redux/actions';
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();
Expand All @@ -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 (
Expand Down Expand Up @@ -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 <Preview isStateLoaded={false} hideProjects={true} {...props} />;
});

0 comments on commit 6af83d0

Please sign in to comment.