From 0deed1f1128f0563555e3d23cedcad1afead010c Mon Sep 17 00:00:00 2001 From: Luke Heath Date: Fri, 7 Apr 2023 18:17:09 -0500 Subject: [PATCH] Fix observers not being allowed access to policies (#11071) --- frontend/interfaces/user.ts | 7 ++++++- .../AgentOptionsPage/AgentOptionsPage.tsx | 1 + .../TeamDetailsWrapper/MembersPage/MembersPage.tsx | 1 + .../TeamDetailsWrapper/TeamDetailsWrapper.tsx | 1 + .../policies/ManagePoliciesPage/ManagePoliciesPage.tsx | 6 +++++- frontend/pages/policies/PolicyPage/PolicyPage.tsx | 3 ++- .../schedule/ManageSchedulePage/ManageSchedulePage.tsx | 1 + 7 files changed, 17 insertions(+), 3 deletions(-) diff --git a/frontend/interfaces/user.ts b/frontend/interfaces/user.ts index e7ddb066b..9926c7aae 100644 --- a/frontend/interfaces/user.ts +++ b/frontend/interfaces/user.ts @@ -16,7 +16,12 @@ export default PropTypes.shape({ teams: PropTypes.arrayOf(teamInterface), }); -export const USERS_ROLES = ["admin", "maintainer", "observer"] as const; +export const USERS_ROLES = [ + "admin", + "maintainer", + "observer", + "observer_plus", +] as const; export type IUserRole = typeof USERS_ROLES[number]; export type UserRole = | "admin" diff --git a/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/AgentOptionsPage/AgentOptionsPage.tsx b/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/AgentOptionsPage/AgentOptionsPage.tsx index e4ed4c2f1..caaf9bb93 100644 --- a/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/AgentOptionsPage/AgentOptionsPage.tsx +++ b/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/AgentOptionsPage/AgentOptionsPage.tsx @@ -49,6 +49,7 @@ const AgentOptionsPage = ({ admin: true, maintainer: false, observer: false, + observer_plus: false, }, }); diff --git a/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/MembersPage/MembersPage.tsx b/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/MembersPage/MembersPage.tsx index 59c6725f4..a4c143e3c 100644 --- a/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/MembersPage/MembersPage.tsx +++ b/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/MembersPage/MembersPage.tsx @@ -64,6 +64,7 @@ const MembersPage = ({ location, router }: IMembersPageProps): JSX.Element => { admin: true, maintainer: false, observer: false, + observer_plus: false, }, }); diff --git a/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/TeamDetailsWrapper.tsx b/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/TeamDetailsWrapper.tsx index b0edfe442..52e236e27 100644 --- a/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/TeamDetailsWrapper.tsx +++ b/frontend/pages/admin/TeamManagementPage/TeamDetailsWrapper/TeamDetailsWrapper.tsx @@ -117,6 +117,7 @@ const TeamDetailsWrapper = ({ admin: true, maintainer: false, observer: false, + observer_plus: false, }, }); diff --git a/frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx b/frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx index 713a5461b..a63f75d21 100644 --- a/frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx +++ b/frontend/pages/policies/ManagePoliciesPage/ManagePoliciesPage.tsx @@ -53,6 +53,7 @@ const ManagePolicyPage = ({ location, }: IManagePoliciesPageProps): JSX.Element => { const { + currentUser, isGlobalAdmin, isGlobalMaintainer, isOnGlobalTeam, @@ -62,6 +63,8 @@ const ManagePolicyPage = ({ } = useContext(AppContext); const { renderFlash } = useContext(NotificationContext); + console.log("currentUser: ", currentUser); + const { setLastEditedQueryName, setLastEditedQueryDescription, @@ -89,7 +92,8 @@ const ManagePolicyPage = ({ permittedAccessByTeamRole: { admin: true, maintainer: true, - observer: false, + observer: true, + observer_plus: true, }, }); diff --git a/frontend/pages/policies/PolicyPage/PolicyPage.tsx b/frontend/pages/policies/PolicyPage/PolicyPage.tsx index 3d7e23f05..8e2f1ea67 100644 --- a/frontend/pages/policies/PolicyPage/PolicyPage.tsx +++ b/frontend/pages/policies/PolicyPage/PolicyPage.tsx @@ -77,7 +77,8 @@ const PolicyPage = ({ permittedAccessByTeamRole: { admin: true, maintainer: true, - observer: false, + observer: true, + observer_plus: true, }, }); diff --git a/frontend/pages/schedule/ManageSchedulePage/ManageSchedulePage.tsx b/frontend/pages/schedule/ManageSchedulePage/ManageSchedulePage.tsx index c818caec7..a654f114d 100644 --- a/frontend/pages/schedule/ManageSchedulePage/ManageSchedulePage.tsx +++ b/frontend/pages/schedule/ManageSchedulePage/ManageSchedulePage.tsx @@ -141,6 +141,7 @@ const ManageSchedulePage = ({ admin: true, maintainer: true, observer: false, + observer_plus: false, }, });