puck icon indicating copy to clipboard operation
puck copied to clipboard

Allow to set permissions for an item via the dispatcher

Open genox opened this issue 3 months ago • 1 comments

Description

This might come in handy later, as things grow more complex, but I stumbled over this while trying to work around the drag stuff on my other issues.

It is currently not possible to my knowledge to set the permissions on the app state. To my knowledge, all other config can be set one way or another via state. Setting permissions can only be done on the top configuration level of a component. I assumed that resolvePermissions would run more frequently, but it seems to run only once. And the static permissions object is .. well, static. :)

The only workaround to that is using variables on the component that will be essentially either global or module scoped, depending on the environment. This is a bit of a hack. And even after setting them, they need to be manually refreshed.

Wouldn't it be better to expose permissions via appState as well?

Proposals

Expose the permission state via appState for items, in order to have them consumed easily or updated and triggering state refreshes on consumers.

Allow setting permissions per item via reducer actions.

genox avatar Aug 28 '25 07:08 genox

I think exposing a permissions updater action could be beneficial for the cases you mentioned, but also for situations where a field or custom UI has internal state that component permissions depend on. With the current setup, you can only specify permissions dynamically based on field props, but that might not always be enough.

FedericoBonel avatar Sep 01 '25 04:09 FedericoBonel