chore: add ash_admin? flag to context#394
Conversation
| form_opts = [ | ||
| actor: socket.assigns[:actor], | ||
| authorize?: socket.assigns[:authorizing], | ||
| context: %{ash_admin?: true}, | ||
| domain: socket.assigns.domain, | ||
| forms: auto_forms, | ||
| tenant: socket.assigns[:tenant], | ||
| transform_errors: transform_errors | ||
| ] |
There was a problem hiding this comment.
While adding context: %{ash_admin?: true}, noticed all three forms below used the exact same options, so I refactored the code a bit to reduce repetition.
Please let me know if this is OK or I should undo that.
There was a problem hiding this comment.
Works for me 😄 I believe there are some other cases where we make forms, there should be one for generic actions and one where we build a form for a read action.
There was a problem hiding this comment.
We should do those as well 😄
|
@zachdaniel I have a feeling we should also add some documentation about this somewhere. |
| ## Action Context | ||
|
|
||
| AshAdmin adds `ash_admin?: true` to the context of all AshPhoenix forms it uses (read, update, and | ||
| generic actions). You can find this flag in the `source_context` in the context of each action. |
There was a problem hiding this comment.
I wouldn't be so specific here. Where you find this actually kind of depends. i.e changeset.context and context.source_context etc. depending. We can point to the Ash core context guide perhaps?
There was a problem hiding this comment.
I've made it less specific. Hope that works.
This commit adds `ash_admin?: true` to the context of all AshPhoenix forms so that upstream logic can tell if an action is being called from AshAdmin or not. While doing so, I noticed that all three form calls (`for_create/3`, `for_update/3`, and `for_destroy/3`) were using the exact same options, so I refactored them into a shared variable.
|
🚀 Thank you for your contribution! 🚀 |
This commit adds
ash_admin?: trueto the context of all AshPhoenix forms so that upstream logic can tell if an action is being called from AshAdmin or not.While doing so, I noticed that all three form calls (
for_create/3,for_update/3, andfor_destroy/3) were using the exact same options, so I refactored them into a shared variable. I hope this is OK, but I can roll these changes back and only add the new flag if you prefer.Contributor checklist
Leave anything that you believe does not apply unchecked.