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

feat: remove onDelete for Placeholder tag for non Platform admiins #3959

Merged
merged 11 commits into from
Nov 20, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import { FONT_WEIGHT_SEMI_BOLD } from "theme";

export const TAG_DISPLAY_VALUES: Record<
NodeTag,
{ color: keyof Palette["nodeTag"]; displayName: string; isEditable?: Role[] }
{ color: keyof Palette["nodeTag"]; displayName: string; editableBy?: Role[] }
> = {
placeholder: {
color: "blocking",
displayName: "Placeholder",
isEditable: ["platformAdmin"], // if new roles are added, we should update the canEdit() in ComponentTagSelect.tsx
editableBy: ["platformAdmin"], // if new roles are added, we should update the canEdit() in ComponentTagSelect.tsx
RODO94 marked this conversation as resolved.
Show resolved Hide resolved
},
toReview: {
color: "nonBlocking",
Expand Down
4 changes: 2 additions & 2 deletions editor.planx.uk/src/ui/editor/ComponentTagSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const renderOption: AutocompleteProps<
false,
"div"
>["renderOption"] = (props, tag, { selected }) => {
if (TAG_DISPLAY_VALUES[tag].isEditable?.some(canEdit)) return null;
if (TAG_DISPLAY_VALUES[tag].editableBy?.some(canEdit)) return null;
return (
<ListItem {...props}>
<CustomCheckbox
Expand Down Expand Up @@ -70,7 +70,7 @@ const renderTags: AutocompleteProps<
),
})}
onDelete={
TAG_DISPLAY_VALUES[tag].isEditable?.some(canEdit)
TAG_DISPLAY_VALUES[tag].editableBy?.some(canEdit)
? undefined
: getTagProps({ index }).onDelete
}
Expand Down
Loading