Add AuthCan syntax sugar
OhKai opened this issue · 3 comments
Make it possible to have shortcuts for the casl resource like so:
<AuthCan update process={record}>
-->
<AuthCan resource={toCaslResource('Process', record)} action="update">
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
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.
Oh, I see, I misread your code example. This shouldn't be hard to do.