From ad95bac5cc1c9e2421a4041e55f6f6548b107a09 Mon Sep 17 00:00:00 2001 From: Prabhat Khera Date: Tue, 26 Sep 2023 11:24:50 +1300 Subject: [PATCH] disable user list api call if not authorised --- .../AccessControlPanel/AccessControlPanel.tsx | 1 + .../AccessControlPanel/AccessControlPanelDetails.tsx | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/react/portainer/access-control/AccessControlPanel/AccessControlPanel.tsx b/app/react/portainer/access-control/AccessControlPanel/AccessControlPanel.tsx index 82ab49161..4109c6a5d 100644 --- a/app/react/portainer/access-control/AccessControlPanel/AccessControlPanel.tsx +++ b/app/react/portainer/access-control/AccessControlPanel/AccessControlPanel.tsx @@ -52,6 +52,7 @@ export function AccessControlPanel({ {!isEditDisabled && !isEditMode && ( diff --git a/app/react/portainer/access-control/AccessControlPanel/AccessControlPanelDetails.tsx b/app/react/portainer/access-control/AccessControlPanel/AccessControlPanelDetails.tsx index 3201959cc..503493356 100644 --- a/app/react/portainer/access-control/AccessControlPanel/AccessControlPanelDetails.tsx +++ b/app/react/portainer/access-control/AccessControlPanel/AccessControlPanelDetails.tsx @@ -24,11 +24,13 @@ import { ResourceControlViewModel } from '../models/ResourceControlViewModel'; interface Props { resourceControl?: ResourceControlViewModel; resourceType: ResourceControlType; + isAuthorisedToFetchUsers?: boolean; } export function AccessControlPanelDetails({ resourceControl, resourceType, + isAuthorisedToFetchUsers = false, }: Props) { const inheritanceMessage = getInheritanceMessage( resourceType, @@ -41,7 +43,10 @@ export function AccessControlPanelDetails({ TeamAccesses: restrictedToTeams = [], } = resourceControl || {}; - const users = useAuthorizedUsers(restrictedToUsers.map((ra) => ra.UserId)); + const users = useAuthorizedUsers( + restrictedToUsers.map((ra) => ra.UserId), + isAuthorisedToFetchUsers + ); const teams = useAuthorizedTeams(restrictedToTeams.map((ra) => ra.TeamId)); const teamsLength = teams.data ? teams.data.length : 0;