PROCEED-Labs / proceed

Business Process Management System
MIT License
5 stars 8 forks source link

Add AuthCan syntax sugar #195

Closed OhKai closed 5 months ago

OhKai commented 8 months ago

Make it possible to have shortcuts for the casl resource like so:

<AuthCan update process={record}>
-->
<AuthCan resource={toCaslResource('Process', record)} action="update">
FelipeTrost commented 5 months ago

This would be only possible if the record object had a way to identify the resource, as this is not possible for all Resource types I didn't build it that way. Maybe we could consider adding such a property to the schemas, processes already have type: 'process' for example

OhKai commented 5 months ago

To clarify, I didn't mean inferring the toCaslResource completely from the record, just that instead of always using resource prop we have a prop for some common resource types (like process={record} in the example), so that we still know the type but don't have so much boilerplate code every time.

It could also be done with sub-components like <AuthCan.Update process={record}> to ensure that we have an action defined.

FelipeTrost commented 5 months ago

Oh, I see, I misread your code example. This shouldn't be hard to do.