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
Copy file name to clipboardExpand all lines: workspaces/homepage/plugins/homepage-backend/README.md
+79-5Lines changed: 79 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# homepage
2
2
3
-
This plugin backend was templated using the Backstage CLI. You should replace this text with a description of your plugin backend.
3
+
Backend for the dynamic homepage. It reads default widget settings from config and exposes them over HTTP. The frontend uses this to show cards, and can hide cards per **user**, **group**, or **permission**.
This plugin backend can be started in a standalone mode from directly in this
25
-
package with `yarn start`. It is a limited setup that is most convenient when
26
-
developing the plugin backend itself.
24
+
Run `yarn start` in this package to work on the backend only.
27
25
28
-
If you want to run the entire project, including the frontend, run `yarn start` from the root directory.
26
+
Run `yarn start` from the repo root to run the full app with the frontend.
27
+
28
+
## Default widgets (`homepage.defaultWidgets`)
29
+
30
+
You list widgets under `homepage` in `app-config.yaml`. The backend checks this file when it starts. Bad config stops startup.
31
+
32
+
For each request to `GET /api/homepage/default-widgets`, the backend looks at the signed-in user and returns JSON `{ "items": [...] }`. That list is **only the card rows** (leaves), in order. Each item has `id`, `ref`, and optional `props` and `layout`.
33
+
34
+
**Groups and `children`.** You can group cards under a parent that has `children` only (no `id` or `ref` on that parent). The parent can use `if` to hide the whole group. Cards inside the group are normal leaves with `id` and `ref`. The parent row is not returned in `items`—only the cards.
35
+
36
+
**Who can see a card (`if`).** A node can have an optional `if` with `users`, `groups`, and/or `permissions`.
37
+
38
+
- If `if` is missing, or every list inside it is empty, **everyone** sees that node.
39
+
- If you set any list, the user must match **at least one** rule:
40
+
-**users:** their user ref (for example `user:default/jane`) is in the list.
41
+
-**groups:** they belong to a listed group. Membership comes from the catalog. If the user is not in the catalog, group rules do not match.
42
+
-**permissions:** the permissions service **allows** any listed permission name.
43
+
44
+
Rules inside `if` use **OR** logic. If the parent fails its `if`, nothing under it is shown.
45
+
46
+
At startup the backend finds every permission name used in the tree. Each request checks only those names in one batch.
47
+
48
+
**Leaves vs groups.** A **leaf** needs `id` and `ref`. A **group** needs `children` and must not use `id` or `ref`. The full rules are in `src/defaultWidgets/loadDefaultWidgets.ts`.
49
+
50
+
### `app-config.yaml` example
51
+
52
+
```yaml
53
+
homepage:
54
+
defaultWidgets:
55
+
# --- Simple cards (leaves) ---
56
+
# id = mountpoint id for the card; ref = which widget to render.
57
+
- id: onboarding
58
+
ref: 'rhdh-onboarding-section'
59
+
layout:
60
+
xl: { w: 12, h: 6 }
61
+
lg: { w: 12, h: 6 }
62
+
- id: quickaccess-card
63
+
ref: quickaccess-card
64
+
layout:
65
+
xl: { w: 6, h: 8, x: 6 }
66
+
67
+
# --- Group with children (shared visibility) ---
68
+
# The group row has `if` and `children` only. All listed cards are hidden
69
+
# unless the user passes the group's `if` (here: member of admins).
70
+
- if:
71
+
groups: [group:default/admins]
72
+
children:
73
+
- id: rbac
74
+
ref: RBAC
75
+
layout:
76
+
xl: { w: 12, h: 6 }
77
+
78
+
# --- group with several children ---
79
+
# Use one parent to apply the same visibility to multiple cards.
80
+
# - if:
81
+
# groups: [group:default/platform-team]
82
+
# children:
83
+
# - id: metrics-card
84
+
# ref: platform-metrics
85
+
# layout:
86
+
# xl: { w: 6, h: 8 }
87
+
# - id: logs-card
88
+
# ref: platform-logs
89
+
# layout:
90
+
# xl: { w: 6, h: 8 }
91
+
# # Each child can still have its own `if` for finer rules.
92
+
# - id: audit-card
93
+
# ref: platform-audit
94
+
# if:
95
+
# users: [user:default/auditor]
96
+
97
+
# --- Commented: single card gated by permission ---
0 commit comments