Skip to content

Commit 659f4a1

Browse files
authored
Merge pull request #7457 from umbraco/cms/backoffice-signs
Register an entitySign and render an icon.
2 parents dcb9cce + a8d36f1 commit 659f4a1

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

16/umbraco-cms/customizing/back-office-signs.md

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ For example, a Document scheduled for future publishing will have a Flag defined
2323
A Flag can be the determinant for a Sign by declaring the `forEntityFlags` as part of its Manifest.
2424

2525
Example:
26+
2627
```json
2728
...
2829
forEntityFlags: "Umb.ScheduledForPublish",
@@ -33,7 +34,88 @@ Using this binding lets the server determine which signs are present in the resp
3334

3435
## Displaying a Sign
3536

37+
To display a Sign in the backoffice, register an `entitySign` extension.
38+
39+
Typically, you’ll bind it to one or more flags returned in the server response using the `forEntityFlags` property. However, you can also provide your own logic to determine when a Sign should appear.
40+
41+
If you're using an icon variant, set `kind` to `icon` and provide both `meta.iconName` and `meta.label`. This ensures the user interface has the necessary visual and accessible information to render the Sign correctly.
42+
43+
### Example: Rendering an Entity Sign from a Server Flag
44+
45+
```typescript
46+
import type { UmbExtensionManifest } from "@umbraco-cms/backoffice/extension-registry";
47+
import { UMB_DOCUMENT_ENTITY_TYPE } from "@umbraco-cms/backoffice/document";
48+
49+
export const manifests: UmbExtensionManifest = {
50+
type: "entitySign",
51+
kind: "icon",
52+
alias: "Umb.EntitySign.Document.IsProtected",
53+
name: "Is Protected Document Entity Sign",
54+
forEntityTypes: [UMB_DOCUMENT_ENTITY_TYPE], // Where it can appear
55+
forEntityFlags: ["Umb.IsProtected"], // <---Binding part-When it should appear
56+
weight: 1000,
57+
meta: {
58+
iconName: "icon-lock", // Built-in or custom icon name
59+
label: "Protected", // Visible/accessible label
60+
iconColorAlias: "red",
61+
},
62+
};
63+
```
64+
65+
When an entity includes the `Umb.IsProtected` flag, this Sign appears next to it in the UI, indicating that the item is protected.
66+
67+
![Screenshot of Recently Created sign](../reference/images/protected-entity-sign.png)
68+
69+
### Example: Rendering an Entity Sign with Custom Logic
70+
71+
The following Sign appears next to any document created within the past week. This Sign isn’t controlled by server flags.
72+
73+
```typescript
74+
import type { UmbExtensionManifest } from "@umbraco-cms/backoffice/extension-registry";
75+
import { UMB_DOCUMENT_ENTITY_TYPE } from "@umbraco-cms/backoffice/document";
76+
77+
export const manifests: UmbExtensionManifest = {
78+
type: "entitySign",
79+
kind: "icon",
80+
alias: "Umb.EntitySign.Document.RecentlyCreated",
81+
name: "Recently Created Document Sign",
82+
forEntityTypes: [UMB_DOCUMENT_ENTITY_TYPE],
83+
element: () => import("./recently-created-sign.element.ts"),
84+
meta: {
85+
iconName: "icon-umbraco",
86+
label: "Recently Created",
87+
},
88+
};
89+
```
90+
91+
And in `recently-created-sign.element.ts`:
92+
93+
```typescript
94+
@customElement("umb-recently-created-sign")
95+
export class UmbRecentlyCreatedSignElement extends UmbLitElement {
96+
@state() private _createDate?: string;
97+
98+
override connectedCallback(): void {
99+
super.connectedCallback();
100+
this.consumeContext(UMB_TREE_ITEM_CONTEXT, (ctx) => {
101+
const item = ctx?.getTreeItem?.() ?? (ctx as any).item;
102+
this._createDate = item?.createDate;
103+
this.requestUpdate();
104+
});
105+
}
106+
107+
protected override render() {
108+
if (!this._createDate) return null;
109+
const created = new Date(this._createDate);
110+
const weekAgo = new Date();
111+
weekAgo.setDate(weekAgo.getDate() - 7);
112+
return created > weekAgo ? html`<div>New</div>` : null;
113+
}
114+
}
115+
```
116+
117+
![Screenshot of Recently Created sign](../reference/images/custom-entity-sign.png)
118+
36119
{% hint style="info" %}
37-
The client extension for backoffice signs will be available in Umbraco 16.4 / 17.0.
120+
Client extensions for backoffice signs are available in Umbraco version 16.4.
38121
{% endhint %}
39-
27.3 KB
Loading
26.1 KB
Loading

0 commit comments

Comments
 (0)