From c01f3a0d81730a8e03d7d5fc6303154dbd39e318 Mon Sep 17 00:00:00 2001 From: Ian Bolton Date: Wed, 3 Jan 2024 09:32:57 -0500 Subject: [PATCH] :bug: Hide create and kebab when no valid permissions on archetypes page (#1647) Resolves https://issues.redhat.com/browse/MTA-1893 ![image](https://github.com/konveyor/tackle2-ui/assets/11218376/9c5c5069-49c7-4543-a639-130672892c59) Signed-off-by: ibolton336 --- .../app/pages/archetypes/archetypes-page.tsx | 149 +++++++++--------- 1 file changed, 78 insertions(+), 71 deletions(-) diff --git a/client/src/app/pages/archetypes/archetypes-page.tsx b/client/src/app/pages/archetypes/archetypes-page.tsx index 879c9c0cc2..b4c6941e54 100644 --- a/client/src/app/pages/archetypes/archetypes-page.tsx +++ b/client/src/app/pages/archetypes/archetypes-page.tsx @@ -307,7 +307,7 @@ const Archetypes: React.FC = () => { - + {archetypeWriteAccess && } @@ -381,76 +381,83 @@ const Archetypes: React.FC = () => { - - setArchetypeToDuplicate(archetype), - }, - ] - : []), - ...(assessmentWriteAccess - ? [ - { - title: t("actions.assess"), - onClick: () => - assessSelectedArchetype(archetype), - }, - ] - : []), - ...(reviewsWriteAccess - ? [ - { - title: t("actions.review"), - onClick: () => - reviewSelectedArchetype(archetype), - }, - ] - : []), - ...(archetypeWriteAccess - ? [ - { - title: t("actions.edit"), - onClick: () => - setArchetypeToEdit(archetype), - }, - ] - : []), - ...(archetype?.assessments?.length && - assessmentWriteAccess - ? [ - { - title: t("actions.discardAssessment"), - onClick: () => - setAssessmentToDiscard(archetype), - }, - ] - : []), - ...(archetype?.review && reviewsWriteAccess - ? [ - { - title: t("actions.discardReview"), - onClick: () => - setReviewToDiscard(archetype), - }, - ] - : []), - { isSeparator: true }, - ...(archetypeWriteAccess - ? [ - { - title: t("actions.delete"), - onClick: () => - setArchetypeToDelete(archetype), - isDanger: true, - }, - ] - : []), - ]} - /> + {(archetypeWriteAccess || + assessmentWriteAccess || + reviewsWriteAccess || + (archetype?.assessments?.length && + assessmentWriteAccess) || + (archetype?.review && reviewsWriteAccess)) && ( + + setArchetypeToDuplicate(archetype), + }, + ] + : []), + ...(assessmentWriteAccess + ? [ + { + title: t("actions.assess"), + onClick: () => + assessSelectedArchetype(archetype), + }, + ] + : []), + ...(reviewsWriteAccess + ? [ + { + title: t("actions.review"), + onClick: () => + reviewSelectedArchetype(archetype), + }, + ] + : []), + ...(archetypeWriteAccess + ? [ + { + title: t("actions.edit"), + onClick: () => + setArchetypeToEdit(archetype), + }, + ] + : []), + ...(archetype?.assessments?.length && + assessmentWriteAccess + ? [ + { + title: t("actions.discardAssessment"), + onClick: () => + setAssessmentToDiscard(archetype), + }, + ] + : []), + ...(archetype?.review && reviewsWriteAccess + ? [ + { + title: t("actions.discardReview"), + onClick: () => + setReviewToDiscard(archetype), + }, + ] + : []), + { isSeparator: true }, + ...(archetypeWriteAccess + ? [ + { + title: t("actions.delete"), + onClick: () => + setArchetypeToDelete(archetype), + isDanger: true, + }, + ] + : []), + ]} + /> + )}