-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
Removed vultr server and associated DNS entries |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be a more generalisable pattern here than just toggling controls for a single named tag.
Could we set rules in an object, maybe a renamed/repurposed TAG_DISPLAY_VALUES
that controls the behaviour?
export const TAG_DISPLAY_VALUES: Record<
NodeTag,
{ color: keyof Palette["nodeTag"]; displayName: string, isEditable?: boolean }
> = {
placeholder: {
color: "blocking",
displayName: "Placeholder",
isEditable: useStore.getState().user?.isPlatformAdmin
},
...
I think this would give us a more robust, scalable, and data driven solution.
Also, it would be great to see some tests here describing the change please 🙏
ffa182a
to
55c3236
Compare
editor.planx.uk/src/pages/FlowEditor/components/Flow/components/Tag.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still feels a bit more complex and hard to follow than it needs to be.
I'd really recommend changing the variable name from isEditable
(which denotes a boolean) to something more indicative of a Role[]
- maybe editableBy
?
Have a look at how EditorNavMenu
solves a very similar problem.
Nah you're definitely right, this slipped my mind when making the changes, sorry! |
add changes requested add changes requested
943f540
to
518c33f
Compare
What does this PR do?
This PR adds a role access constraint to the
Placeholder
tag so onlyPlatformAdmins
can edit it, but everyone can see it.To do this, I have restricted the
renderOption
function so it only showsPlaceholder
tag in the MultiSelect forPlatformAdmin
users. I have also added the constraint to therenderTags
function, so it removes theonDelete
from theChip
component when a user is not aPlatformAdmin
With the changes to
TAG_DISPLAY_VALUES
we can now useRole
types to add further permission layers in future if required. To ensure this happens, new logic would need to be introduced to thecanEdit()
inComponentTagSelect()