Skip to content

Commit b1c64ea

Browse files
authored
ORV2-3453 - BVT bug: Enforcement Officer has no access to Bridge Calc Tool (#1818)
Co-authored-by: GlenAOT <[email protected]>
1 parent e6e0b13 commit b1c64ea

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

frontend/src/common/authentication/PermissionMatrix.ts

+3
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,9 @@ const STICKY_SIDE_BAR = {
347347
MANAGE_PPC_USERS_BUTTON: {
348348
allowedIDIRRoles: [SA],
349349
},
350+
BRIDGE_FORMULA_CALCULATION_TOOL_BUTTON: {
351+
allowedIDIRRoles: [HQA, SA, PC, CTPO, EO],
352+
},
350353
} as const;
351354

352355
const MANAGE_PPC_USERS = {

frontend/src/common/components/naviconsidebar/NavIconBFCTButton.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { NAV_BUTTON_TYPES } from "./types/NavButtonType";
1212
export const NavIconBFCTButton = () => {
1313
const navigate = useNavigate();
1414
const { pathname } = useLocation();
15-
const isActive = pathname === IDIR_ROUTES.WELCOME;
15+
const isActive = pathname === IDIR_ROUTES.BRIDGE_FORMULA_CALCULATION_TOOL;
1616
const { clearCompanyContext } = useContext(OnRouteBCContext);
1717

1818
return (
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { useAuth } from "react-oidc-context";
2-
import React, { useContext } from "react";
2+
import { useContext } from "react";
33

44
import { IDPS } from "../../types/idp";
55
import "./NavIconSideBar.scss";
66
import OnRouteBCContext from "../../../common/authentication/OnRouteBCContext";
7-
import { USER_ROLE } from "../../../common/authentication/types";
87
import { NavIconHomeButton } from "./NavIconHomeButton";
98
import { NavIconReportButton } from "./NavIconReportButton";
109
import { NavIconBFCTButton } from "./NavIconBFCTButton";
1110
import { useFeatureFlagsQuery } from "../../hooks/hooks";
11+
import { usePermissionMatrix } from "../../authentication/PermissionMatrix";
1212

1313
/**
1414
* Displays a sidebar with NavIcon buttons as children
@@ -17,22 +17,35 @@ export const NavIconSideBar = () => {
1717
const { isAuthenticated, user } = useAuth();
1818
const { idirUserDetails } = useContext(OnRouteBCContext);
1919
const isIdir = user?.profile?.identity_provider === IDPS.IDIR;
20-
const isEofficer =
21-
idirUserDetails?.userRole === USER_ROLE.ENFORCEMENT_OFFICER;
2220

2321
const shouldShowSideBar =
24-
isAuthenticated && isIdir && idirUserDetails?.userName && !isEofficer;
22+
isAuthenticated && isIdir && idirUserDetails?.userName;
2523

2624
// Determine when to hide the BridgeFormulaCalculationTool button based on its corresponding feature flag
2725
const { data: featureFlags } = useFeatureFlagsQuery();
28-
const enableBFCT =
26+
27+
const BFCTFeatureFlagEnabled =
2928
featureFlags?.["BRIDGE-FORMULA-CALCULATION-TOOL"] === "ENABLED";
3029

30+
const shouldShowBFCTButton = usePermissionMatrix({
31+
permissionMatrixKeys: {
32+
permissionMatrixFeatureKey: "STICKY_SIDE_BAR",
33+
permissionMatrixFunctionKey: "BRIDGE_FORMULA_CALCULATION_TOOL_BUTTON",
34+
},
35+
});
36+
37+
const shouldShowReportsButton = usePermissionMatrix({
38+
permissionMatrixKeys: {
39+
permissionMatrixFeatureKey: "STICKY_SIDE_BAR",
40+
permissionMatrixFunctionKey: "REPORTS_BUTTON",
41+
},
42+
});
43+
3144
return shouldShowSideBar ? (
3245
<div className="nav-icon-side-bar">
3346
<NavIconHomeButton />
34-
<NavIconReportButton />
35-
{enableBFCT && <NavIconBFCTButton />}
47+
{shouldShowReportsButton && <NavIconReportButton />}
48+
{BFCTFeatureFlagEnabled && shouldShowBFCTButton && <NavIconBFCTButton />}
3649
</div>
3750
) : null;
3851
};

0 commit comments

Comments
 (0)