Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Hide create and kebab when no valid permissions on archetypes page #1647

Merged
merged 2 commits into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading