From 7350c91a1e6a3029de9945f81a1dfb83f7a98b41 Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Tue, 20 Feb 2024 16:16:42 +0100 Subject: [PATCH] fix: display all roles if we can't get project roles --- .../ApplicationEdit/ApplicationEdit.tsx | 1 - .../ProjectAccessAssign.tsx | 21 ++++++++++++------- src/lib/routes/admin-api/user/user.ts | 1 + 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/frontend/src/component/application/ApplicationEdit/ApplicationEdit.tsx b/frontend/src/component/application/ApplicationEdit/ApplicationEdit.tsx index 7abc3e4a64..cab7262337 100644 --- a/frontend/src/component/application/ApplicationEdit/ApplicationEdit.tsx +++ b/frontend/src/component/application/ApplicationEdit/ApplicationEdit.tsx @@ -16,7 +16,6 @@ import { ConditionallyRender } from 'component/common/ConditionallyRender/Condit import { UPDATE_APPLICATION } from 'component/providers/AccessProvider/permissions'; import { ApplicationView } from '../ApplicationView/ApplicationView'; import { ApplicationUpdate } from '../ApplicationUpdate/ApplicationUpdate'; -import { ConnectedInstances } from '../ConnectedInstances/ConnectedInstances'; import { Dialogue } from 'component/common/Dialogue/Dialogue'; import { PageContent } from 'component/common/PageContent/PageContent'; import { PageHeader } from 'component/common/PageHeader/PageHeader'; diff --git a/frontend/src/component/project/ProjectAccess/ProjectAccessAssign/ProjectAccessAssign.tsx b/frontend/src/component/project/ProjectAccess/ProjectAccessAssign/ProjectAccessAssign.tsx index 586ff82ee5..78303316de 100644 --- a/frontend/src/component/project/ProjectAccess/ProjectAccessAssign/ProjectAccessAssign.tsx +++ b/frontend/src/component/project/ProjectAccess/ProjectAccessAssign/ProjectAccessAssign.tsx @@ -321,13 +321,20 @@ export const ProjectAccessAssign = ({ }; const isValid = selectedOptions.length > 0 && selectedRoles.length > 0; - const filteredRoles = userRoles.some( - (userrole) => userrole.name === 'Admin' || userrole.name === 'Owner', - ) - ? roles - : roles.filter((role) => - userRoles.some((userrole) => role.id === userrole.id), - ); + const displayAllRoles = + userRoles.length === 0 || + userRoles.some( + (userRole) => + userRole.name === 'Admin' || userRole.name === 'Owner', + ); + let filteredRoles: IRole[]; + if (displayAllRoles) { + filteredRoles = roles; + } else { + filteredRoles = roles.filter((role) => + userRoles.some((userrole) => role.id === userrole.id), + ); + } return ( ): Promise {