Skip to content

Commit 39023a7

Browse files
committed
- Update so that digit cannot see alerts tab
1 parent b4bfd92 commit 39023a7

File tree

3 files changed

+38
-29
lines changed

3 files changed

+38
-29
lines changed

tdrs-frontend/src/components/Header/Header.jsx

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import {
77
accountStatusIsApproved,
88
accountIsInReview,
99
accountCanViewAdmin,
10-
accountCanViewPlg,
10+
accountCanViewGrafana,
11+
accountCanViewAlerts,
1112
} from '../../selectors/auth'
1213

1314
import NavItem from '../NavItem/NavItem'
@@ -30,7 +31,8 @@ function Header() {
3031
const userAccessRequestPending = useSelector(accountIsInReview)
3132
const userAccessRequestApproved = useSelector(accountStatusIsApproved)
3233
const userIsAdmin = useSelector(accountCanViewAdmin)
33-
const userViewPlg = useSelector(accountCanViewPlg)
34+
const userViewGrafana = useSelector(accountCanViewGrafana)
35+
const userViewAlerts = useSelector(accountCanViewAlerts)
3436

3537
const menuRef = useRef()
3638

@@ -153,19 +155,19 @@ function Header() {
153155
href={`${process.env.REACT_APP_BACKEND_HOST}/admin/`}
154156
/>
155157
)}
156-
{userViewPlg && (
157-
<>
158-
<NavItem
159-
pathname={pathname}
160-
tabTitle="Grafana"
161-
href={`${process.env.REACT_APP_BACKEND_HOST}/grafana/`}
162-
/>
163-
<NavItem
164-
pathname={pathname}
165-
tabTitle="Alerts"
166-
href={`${process.env.REACT_APP_BACKEND_HOST}/alerts/`}
167-
/>
168-
</>
158+
{userViewGrafana && (
159+
<NavItem
160+
pathname={pathname}
161+
tabTitle="Grafana"
162+
href={`${process.env.REACT_APP_BACKEND_HOST}/grafana/`}
163+
/>
164+
)}
165+
{userViewAlerts && (
166+
<NavItem
167+
pathname={pathname}
168+
tabTitle="Alerts"
169+
href={`${process.env.REACT_APP_BACKEND_HOST}/alerts/`}
170+
/>
169171
)}
170172
</>
171173
)}

tdrs-frontend/src/components/SiteMap/SiteMap.jsx

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import { useSelector } from 'react-redux'
33
import {
44
accountStatusIsApproved,
55
accountCanViewAdmin,
6-
accountCanViewPlg,
76
selectUserPermissions,
7+
accountCanViewGrafana,
8+
accountCanViewAlerts,
89
} from '../../selectors/auth'
910

1011
const SiteMap = ({ user }) => {
1112
const userIsApproved = useSelector(accountStatusIsApproved)
1213
const userIsAdmin = useSelector(accountCanViewAdmin)
13-
const userViewPlg = useSelector(accountCanViewPlg)
14+
const userViewGrafana = useSelector(accountCanViewGrafana)
15+
const userViewAlerts = useSelector(accountCanViewAlerts)
1416

1517
const permissions = useSelector(selectUserPermissions)
1618
const userHasFra = userIsApproved && permissions.includes('has_fra_access')
@@ -43,17 +45,18 @@ const SiteMap = ({ user }) => {
4345
/>
4446
)}
4547

46-
{userViewPlg && (
47-
<>
48-
<SiteMap.Link
49-
text="Grafana"
50-
link={`${process.env.REACT_APP_BACKEND_HOST}/grafana/`}
51-
/>
52-
<SiteMap.Link
53-
text="Alerts"
54-
link={`${process.env.REACT_APP_BACKEND_HOST}/alerts/`}
55-
/>
56-
</>
48+
{userViewGrafana && (
49+
<SiteMap.Link
50+
text="Grafana"
51+
link={`${process.env.REACT_APP_BACKEND_HOST}/grafana/`}
52+
/>
53+
)}
54+
55+
{userViewAlerts && (
56+
<SiteMap.Link
57+
text="Alerts"
58+
link={`${process.env.REACT_APP_BACKEND_HOST}/alerts/`}
59+
/>
5760
)}
5861
</div>
5962
)

tdrs-frontend/src/selectors/auth.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,16 @@ export const accountCanViewAdmin = (state) =>
7272
'System Owner',
7373
].includes(selectPrimaryUserRole(state)?.name)
7474

75-
export const accountCanViewPlg = (state) =>
75+
export const accountCanViewGrafana = (state) =>
7676
accountStatusIsApproved(state) &&
7777
['OFA System Admin', 'Developer', 'DIGIT Team'].includes(
7878
selectPrimaryUserRole(state)?.name
7979
)
8080

81+
export const accountCanViewAlerts = (state) =>
82+
accountStatusIsApproved(state) &&
83+
['OFA System Admin', 'Developer'].includes(selectPrimaryUserRole(state)?.name)
84+
8185
export const accountIsRegionalStaff = (state) =>
8286
accountStatusIsApproved(state) &&
8387
selectPrimaryUserRole(state)?.name === 'OFA Regional Staff'

0 commit comments

Comments
 (0)