-
-
Notifications
You must be signed in to change notification settings - Fork 66
Description
Is your feature request related to a problem? Please describe.
This might be a niche problem, but I have a use case where I want to have separate admin panels handling different domains in a Phoenix app. Currently, the ash_admin dashboard displays all domains, which can become problematic when domains have overlapping names or when segregation of domain management is required.
The reason for multiple admin panels is that I want to build 2+ websites/products, but to reuse functionality and have less hosting costs I want to share the same Phoenix app.
Describe the solution you'd like
I propose extending the current implementation to support multiple ash_admin dashboards by introducing group-based filtering. The changes would include:
- Extending the
AshAdmin.DomainDSL with a field calledgroup, which is an optional atom that defaults tonil. - Updating the
ash_adminrouter macro to accept a new option, for example:ash_admin("/admin", group: :a_group_name)
- Adjusting the LiveView mount function in AshAdmin.PageLive to:
- Retrieve the group value from the session.
- In
domains/1If a group is provided, filter the list of domains to include only those with a matching group.
Describe alternatives you've considered
An alternative approach might involve using a separate configuration (e.g., an :ash_admin_groups setting) to manage domain grouping. However, leveraging the existing DSL by adding a group attribute seems to be a cleaner and more integrated solution.
Express the feature either with a change to resource syntax, or with a change to the resource interface
For example:
# In the domain
admin do
name("MyDomain")
show?(true)
group(:a_group_name)
end
# In the router:
ash_admin("/admin", group: :a_group_name) # Dashboard filters to display only domains for group :a_group_nameAdditional context
I'm considering putting together a PR for this feature. Based on my understanding of the codebase, the required changes include extending the DSL in AshAdmin.Domain, updating the router macro to pass the group option, and filtering domains in the LiveView mount function based on the provided group.
Not sure if there are other issues that can arrise when having mutiple dashboards. Currently I want to have them both in /admin, but separated by host used. E.g. myapp.com/admin and myotherapp.com/admin.
Would you be open to a PR for this setup? And do you see any potential pitfalls or have suggestions on this approach?