diff --git a/frontend/src/components/header/index.js b/frontend/src/components/header/index.js index 61f013b42b..940fb4674f 100644 --- a/frontend/src/components/header/index.js +++ b/frontend/src/components/header/index.js @@ -3,6 +3,7 @@ import { useSelector, useDispatch } from 'react-redux'; import { Link, useNavigate, useLocation } from 'react-router-dom'; import Popup from 'reactjs-popup'; import { FormattedMessage } from 'react-intl'; +import { useProjectSummaryQuery } from '../../api/projects'; import messages from './messages'; import { ORG_URL, ORG_NAME, ORG_LOGO, SERVICE_DESK } from '../../config'; @@ -35,6 +36,13 @@ export const Header = () => { const organisations = useSelector((state) => state.auth.organisations); const showOrgBar = useSelector((state) => state.orgBarVisibility.isVisible); + // Matches URLs containing '/projects/' followed by digits (the project ID), like '/projects/130' or '/manage/projects/130' + const match = location.pathname.match(/\/projects\/(\d+)/); + const projectId = match ? match[1] : null; + const { data: project } = useProjectSummaryQuery(projectId, { + enabled: !!projectId, + }); + const linkCombo = 'link mh3 barlow-condensed blue-dark f4 ttu lh-solid nowrap pv2'; const isActive = ({ isPartiallyCurrent }) => { @@ -125,6 +133,11 @@ export const Header = () => { /> Tasking Manager + {project && project.sandbox && ( +