Skip to content

Commit 217d519

Browse files
authored
Update dashboard.md - Add documentation for hiding and restricting dashboard access
Adds a new section documenting how to hide dashboards or add conditional access rules using the extension registry. This addresses a common gap in the documentation where developers need to: - Hide default dashboards like the Getting Started dashboard - Restrict dashboard access to specific user groups (e.g., admins only) - Use extensionRegistry.exclude() and extensionRegistry.appendCondition() Includes examples for: - Removing dashboards completely - Restricting to admin users only - Restricting to multiple specific user groups using GUIDs
1 parent b37ed84 commit 217d519

File tree

1 file changed

+67
-0
lines changed
  • 16/umbraco-cms/customizing/extending-overview/extension-types

1 file changed

+67
-0
lines changed

16/umbraco-cms/customizing/extending-overview/extension-types/dashboard.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,73 @@ Even though these dashboards are useful, you might want to create your own custo
3939

4040
You can try and [create a custom dashboard](../../../tutorials/creating-a-custom-dashboard/) as a way on getting started on this topic.
4141

42+
### Hiding or adding conditional rules to existing dashboards
43+
44+
You might need to hide or add conditions to existing dashboards. Common use cases include hiding the Getting Started dashboard or restricting the Redirect Management dashboard to Admin users only.
45+
46+
To do this, you will first need to [create an extension](../../../tutorials/creating-your-first-extension.md). For this example, which implements dashboard customizations, a descriptive name like `DashboardCustomization` works well:
47+
48+
{% code title="~/App_Plugins/DashboardCustomization/umbraco-package.json" lineNumbers="true" %}
49+
```json
50+
{
51+
"name": "DashboardCustomization",
52+
"version": "1.0.0",
53+
"extensions": [
54+
{
55+
"type": "entryPoint",
56+
"alias": "DashboardCustomization.EntryPoint",
57+
"name": "Dashboard Customization Entry Point",
58+
"js": "/App_Plugins/DashboardCustomization/dashboards-setup.js"
59+
}
60+
]
61+
}
62+
```
63+
{% endcode %}
64+
65+
Use the `onInit` function to configure the dashboard removal and customization. The optional `onUnload` function can clean up any customizations when the extension is disposed:
66+
67+
{% code title="~/App_Plugins/DashboardCustomization/dashboards-setup.js" lineNumbers="true" %}
68+
```js
69+
export const onInit = (host, extensionRegistry) => {
70+
// Remove Getting Started dashboard for all users
71+
extensionRegistry.exclude('Umb.Dashboard.UmbracoNews');
72+
73+
// Restrict Redirect Management dashboard to Admin users only
74+
extensionRegistry.appendCondition('Umb.Dashboard.RedirectManagement', {
75+
alias: 'Umb.Condition.CurrentUser.IsAdmin'
76+
});
77+
}
78+
79+
/**
80+
* Optional: Perform cleanup when the extension is unloaded
81+
*/
82+
export const onUnload = (host, extensionRegistry) => {
83+
// Note: In most cases, cleanup is not necessary as the extension registry
84+
// handles this automatically when the backoffice reloads
85+
}
86+
```
87+
{% endcode %}
88+
89+
#### Restricting to specific user groups
90+
91+
To allow multiple user groups (for example, Admin OR a custom group), use the `Umb.Condition.CurrentUser.GroupId` condition with the `oneOf` parameter:
92+
93+
{% code title="~/App_Plugins/DashboardCustomization/dashboards-setup.js" lineNumbers="true" %}
94+
```js
95+
export const onInit = (host, extensionRegistry) => {
96+
extensionRegistry.appendCondition('Umb.Dashboard.RedirectManagement', {
97+
alias: 'Umb.Condition.CurrentUser.GroupId',
98+
oneOf: [
99+
'CUSTOM-GROUP-GUID-1-HERE',
100+
'CUSTOM-GROUP-GUID-2-HERE'
101+
]
102+
});
103+
};
104+
```
105+
{% endcode %}
106+
107+
You can find user group GUIDs in the **Users > User Groups** section of the backoffice.
108+
42109
## Registering your Dashboard
43110

44111
This section dives into the Dashboard Extension Manifest, shows how to register one, and append additional details.

0 commit comments

Comments
 (0)