Skip to content

Commit 4f7db09

Browse files
authored
Merge pull request #7505 from steveatkiss/patch-1
Update dashboard.md - Add documentation for hiding and restricting dashboard access
2 parents 15d79e5 + f4807e1 commit 4f7db09

File tree

1 file changed

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

1 file changed

+72
-0
lines changed

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,78 @@ 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": "backofficeEntryPoint",
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+
109+
Read more about the available conditions:
110+
111+
{% content-ref url="condition.md" %}
112+
[condition.md](condition.md)
113+
{% endcontent-ref %}
42114
## Registering your Dashboard
43115

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

0 commit comments

Comments
 (0)