You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Allow a domain to have a :group.
- When defining ash_admin routes, allow to filter on a domain group.
- Test: For the ash_admin_test.exs to ensure the group is accessible.
- Test: For verifying the behaviour on page_live.
- Test/refactor: DomainA and DomainB, to easier test one against the other.
Copy file name to clipboardExpand all lines: lib/ash_admin/domain.ex
+46Lines changed: 46 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -29,6 +29,18 @@ defmodule AshAdmin.Domain do
29
29
default: [],
30
30
doc:
31
31
"Humanized names for each resource group to appear in the admin area. These will be used as labels in the top navigation dropdown and will be shown sorted as given. If a key for a group does not appear in this mapping, the label will not be rendered."
32
+
],
33
+
group: [
34
+
type: :atom,
35
+
default: nil,
36
+
doc: """
37
+
The group for filtering multiple admin dashboards. When set, this domain will only appear
38
+
in admin routes that specify a matching group option. If not set (nil), the domain will
39
+
only appear in admin routes without group filtering.
40
+
41
+
Example:
42
+
group :sub_app # This domain will only show up in routes with group: :sub_app
43
+
"""
32
44
]
33
45
]
34
46
}
@@ -39,6 +51,36 @@ defmodule AshAdmin.Domain do
39
51
40
52
@moduledoc"""
41
53
A domain extension to alter the behavior of a domain in the admin UI.
54
+
55
+
## Group-based Filtering
56
+
57
+
Domains can be assigned to groups using the `group` option in the admin configuration.
58
+
This allows you to create multiple admin dashboards, each showing only the domains that belong
59
+
to a specific group.
60
+
61
+
### Example
62
+
63
+
```elixir
64
+
defmodule MyApp.SomeFeatureDomain do
65
+
use Ash.Domain,
66
+
extensions: [AshAdmin.Domain]
67
+
68
+
admin do
69
+
show? true
70
+
group :sub_app # This domain will only appear in admin routes with group: :sub_app
71
+
end
72
+
73
+
# ... rest of domain configuration
74
+
end
75
+
```
76
+
77
+
Then in your router:
78
+
```elixir
79
+
ash_admin "/sub_app/admin", group: :sub_app # Will only show domains with group: :sub_app
80
+
```
81
+
82
+
Note: If you add a group filter to your admin route but haven't set the corresponding group
83
+
in your domains' admin configuration, those domains won't appear in the admin interface.
0 commit comments