Skip to content

Commit

Permalink
🐛 Hide create and kebab when no valid permissions on archetypes page (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ibolton336 authored Jan 3, 2024
1 parent b21de21 commit c01f3a0
Showing 1 changed file with 78 additions and 71 deletions.
149 changes: 78 additions & 71 deletions client/src/app/pages/archetypes/archetypes-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ const Archetypes: React.FC = () => {
<FilterToolbar {...filterToolbarProps} />
<ToolbarGroup variant="button-group">
<ToolbarItem>
<CreateButton />
{archetypeWriteAccess && <CreateButton />}
</ToolbarItem>
</ToolbarGroup>
<ToolbarItem {...paginationToolbarItemProps}>
Expand Down Expand Up @@ -381,76 +381,83 @@ const Archetypes: React.FC = () => {
<ArchetypeApplicationsColumn archetype={archetype} />
</Td>
<Td isActionCell>
<ActionsColumn
items={[
...(archetypeWriteAccess
? [
{
title: t("actions.duplicate"),
onClick: () =>
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)) && (
<ActionsColumn
items={[
...(archetypeWriteAccess
? [
{
title: t("actions.duplicate"),
onClick: () =>
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,
},
]
: []),
]}
/>
)}
</Td>
</TableRowContentWithControls>
</Tr>
Expand Down

0 comments on commit c01f3a0

Please sign in to comment.