Skip to content

Commit

Permalink
Navigate to help page according to work type (#2119)
Browse files Browse the repository at this point in the history
* Navigate to help page according to work type

* use prod help page links
  • Loading branch information
jadmsaadaot authored Apr 15, 2024
1 parent e10bfbc commit eec121a
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 23 deletions.
83 changes: 76 additions & 7 deletions epictrack-web/src/components/AppHelpButton/HelpPageMap.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,103 @@
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/intranet/content?id=A35C49D2D60144F594F8C1DDB5F0EA10#workplan",
"tags": ["workplan"]
"tags": ["Workplan"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/intranet/content?id=A35C49D2D60144F594F8C1DDB5F0EA10#status",
"tags": ["status"]
"tags": ["Status"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/intranet/content?id=A35C49D2D60144F594F8C1DDB5F0EA10#issues",
"tags": ["issues"]
"tags": ["Issues"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/intranet/content?id=A35C49D2D60144F594F8C1DDB5F0EA10#about",
"tags": ["about"]
"tags": ["About"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/intranet/content?id=A35C49D2D60144F594F8C1DDB5F0EA10#teams",
"tags": ["team"]
"tags": ["Team"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/intranet/content?id=A35C49D2D60144F594F8C1DDB5F0EA10#firstnations",
"tags": ["firstnations"]
"tags": ["First Nations"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/project-notification",
"tags": ["Project Notification"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/minister-s-designation",
"tags": ["Minister's Designation"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/ceao-s-designation",
"tags": ["CEAO's Designation"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "",
"tags": ["Intake (Pre-EA)"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/exemption-request",
"tags": ["Exemption Order"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/eac-assessment",
"tags": ["Assessment"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/amendment-complex",
"tags": ["Amendment"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/document-review",
"tags": ["Post-EAC Document Review"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/eac-extension",
"tags": ["EAC Extension"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/substantial-start-decision",
"tags": ["Substantial Start Decision"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/eac-order-transfer",
"tags": ["EAC/Order Transfer"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/eac-order-suspension",
"tags": ["EAC/Order Suspension"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/eac-order-cancellation",
"tags": ["EAC/Order Cancellation"]
},
{
"epicTrackPath": "/work-plan",
"helpPage": "https://intranet.gov.bc.ca/eao/digital-services/support-for-epic-system/support-for-epic-track/milestone-definitions/other",
"tags": ["Other"]
},

{
"epicTrackPath": "/reports/referral-schedule",
"helpPage": "https://intranet.gov.bc.ca/intranet/content?id=FE54F5EFE92B4CF0AC74490E2D03FD4A"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,14 @@ const SupportCenterMenuItem = () => {

const findLinkWithTagsOrAny = (matchingLinks: HelpPageLink[]) => {
const helpPageTags = location.state?.helpPageTags || [];
console.log("helpPageTags", helpPageTags);
console.log("matchingLinks", matchingLinks);
if (helpPageTags.length === 0) {
return matchingLinks[0];
}

return matchingLinks.find((link: HelpPageLink) => {
const linkTags = new Set(link.tags);
return helpPageTags.every((tag: string) => {
const formattedTag = tag.toLocaleLowerCase().replace(" ", "");
return link.tags?.includes(formattedTag);
return linkTags.has(tag);
});
});
};
Expand Down
1 change: 0 additions & 1 deletion epictrack-web/src/components/user/UserList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ const UserList = () => {
.filter((p) => userDetails.groups.includes(p.path))
.sort((a, b) => b.level - a.level)[0];
}, [userDetails, groups]);
console.log(currentUserGroup);
const columns = React.useMemo<MRT_ColumnDef<User>[]>(
() => [
{
Expand Down
9 changes: 1 addition & 8 deletions epictrack-web/src/components/workPlan/WorkPlanContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useContext, useEffect } from "react";
import React, { useContext } from "react";
import { ETCaption3, ETHeading2, ETPageContainer } from "../shared";
import { Palette } from "../../styles/theme";
import { Box } from "@mui/system";
Expand Down Expand Up @@ -43,13 +43,6 @@ const WorkPlanContainer = () => {
setSelectedTabIndex(index);
};

useRouterLocationStateForHelpPage(() => {
const currentSelectedTabLabel = Object.values(WORKPLAN_TAB).find(
(tab) => tab.index === selectedTabIndex
)?.label;
return currentSelectedTabLabel;
}, [selectedTabIndex]);

if (ctx.loading) {
return <WorkPlanSkeleton />;
}
Expand Down
3 changes: 3 additions & 0 deletions epictrack-web/src/components/workPlan/about/AboutContext.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from "react";
import useRouterLocationStateForHelpPage from "hooks/useRouterLocationStateForHelpPage";
import { createContext } from "react";
import { WORKPLAN_TAB } from "../constants";

// eslint-disable-next-line @typescript-eslint/no-empty-interface
interface AboutContextProps {}
Expand All @@ -11,5 +13,6 @@ export const AboutProvider = ({
}: {
children: JSX.Element | JSX.Element[];
}) => {
useRouterLocationStateForHelpPage(() => WORKPLAN_TAB.ABOUT.label, []);
return <AboutContext.Provider value={{}}>{children}</AboutContext.Provider>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import debounce from "lodash/debounce";
import workService from "../../../services/workService/workService";
import { Work } from "../../../models/work";
import { showNotification } from "../../shared/notificationProvider";
import useRouterLocationStateForHelpPage from "hooks/useRouterLocationStateForHelpPage";
import { WORKPLAN_TAB } from "../constants";

const LinkIcon: React.FC<IconProps> = Icons["LinkIcon"];

Expand Down Expand Up @@ -74,6 +76,8 @@ const FirstNationContainer = () => {
}
};

useRouterLocationStateForHelpPage(() => WORKPLAN_TAB.FIRST_NATIONS.label, []);

return (
<Grid container columnSpacing={1.5}>
<Grid item xs={8}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { WorkIssue, WorkIssueUpdate } from "../../../models/Issue";
import { CloneForm, CreateIssueForm, EditIssueForm } from "./types";
import { showNotification } from "components/shared/notificationProvider";
import { getErrorMessage } from "utils/axiosUtils";
import useRouterLocationStateForHelpPage from "hooks/useRouterLocationStateForHelpPage";
import { WORKPLAN_TAB } from "../constants";

interface IssuesContextProps {
isIssuesLoading: boolean;
Expand Down Expand Up @@ -246,6 +248,8 @@ export const IssuesProvider = ({
}
};

useRouterLocationStateForHelpPage(() => WORKPLAN_TAB.ISSUES.label, []);

return (
<IssuesContext.Provider
value={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { CustomSwitch } from "../../shared/CustomSwitch";
import { Palette } from "../../../styles/theme";
import { WorkPhaseAdditionalInfo } from "../../../models/work";
import { When } from "react-if";
import useRouterLocationStateForHelpPage from "hooks/useRouterLocationStateForHelpPage";
import { WORKPLAN_TAB } from "../constants";

const PhaseContainer = () => {
const ctx = useContext(WorkplanContext);
Expand Down Expand Up @@ -42,6 +44,11 @@ const PhaseContainer = () => {
setCompletedPhases(completedPhases);
setCurrentAndFuturePhases(currentAndFuturePhases);
}, [showCompletedPhases, ctx.workPhases]);

useRouterLocationStateForHelpPage(() => {
return ctx.work?.work_type?.name ?? undefined;
}, [ctx.work?.work_type_id]);

if (ctx.workPhases.length === 0) {
return (
<Box sx={{ display: "flex", flexDirection: "column", gap: "1rem" }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import statusService from "../../../services/statusService/statusService";
import { useSearchParams } from "../../../hooks/useSearchParams";
import { WorkplanContext } from "../WorkPlanContext";
import { getErrorMessage } from "../../../utils/axiosUtils";
import useRouterLocationStateForHelpPage from "hooks/useRouterLocationStateForHelpPage";
import { WORKPLAN_TAB } from "../constants";

interface StatusContextProps {
setShowStatusForm: Dispatch<SetStateAction<boolean>>;
Expand Down Expand Up @@ -126,6 +128,8 @@ export const StatusProvider = ({
}
};

useRouterLocationStateForHelpPage(() => WORKPLAN_TAB.STATUS.label, []);

return (
<StatusContext.Provider
value={{
Expand Down
3 changes: 3 additions & 0 deletions epictrack-web/src/components/workPlan/team/TeamContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import { ETHeading3 } from "../../shared";
import { Palette } from "../../../styles/theme";
import TeamList from "./TeamList";
import TeamInfo from "./TeamInfo";
import useRouterLocationStateForHelpPage from "hooks/useRouterLocationStateForHelpPage";
import { WORKPLAN_TAB } from "../constants";

const title: SxProps = {
borderBottom: `2px solid ${Palette.primary.main}`,
paddingBottom: "0.5rem",
};

const TeamContainer = () => {
useRouterLocationStateForHelpPage(() => WORKPLAN_TAB.TEAM.label, []);
return (
<Grid container columnSpacing={1.5}>
<Grid item xs={8}>
Expand Down
3 changes: 0 additions & 3 deletions epictrack-web/src/hooks/useRouterLocationStateForHelpPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const useRouterLocationStateForHelpPage = (
const location = useLocation();

useEffect(() => {
console.log("ran");
const callBackValue = callback();

let newtags: string[] = [];
Expand All @@ -19,8 +18,6 @@ const useRouterLocationStateForHelpPage = (
newtags = [callBackValue];
}

console.log(newtags);

navigate(`${location.pathname}${location.search}`, {
state: { helpPageTags: newtags },
});
Expand Down

0 comments on commit eec121a

Please sign in to comment.