@micha.bigler/ui-core-micha 4.20.0 → 4.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/README.md +29 -1
- package/dist/pages/AccountPage.js +73 -6
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 4.21.0 - UCM-SHELL-9
|
|
4
|
+
|
|
5
|
+
`AccountPage` accepts an optional `groups` declaration (`[{ key, label, order?, tabs?, visible? }]`) that replaces the
|
|
6
|
+
kit's My account / Management / Help groups: app labels, order, built-in tabs placed in any declared group (their own
|
|
7
|
+
permission checks unchanged), `extraTabs[].group` naming any declared key, and a `visible(context)` rule that hides a
|
|
8
|
+
group together with its tabs (also for `?tab=`). Empty groups stay hidden; unplaced tabs land in "More". Without
|
|
9
|
+
`groups` nothing changes.
|
|
10
|
+
|
|
3
11
|
## 4.20.0 - UCM-AUTH-15
|
|
4
12
|
|
|
5
13
|
`SignUpContent` and `SignUpPage` accept an optional `preferredSignupMode`: when the server offers that mode it is shown
|
package/README.md
CHANGED
|
@@ -18,11 +18,39 @@ The privacy and cookie consent controls and their submitted values remain availa
|
|
|
18
18
|
|
|
19
19
|
## Account page: extra tabs in a navigation group
|
|
20
20
|
|
|
21
|
-
An entry of `AccountPage`'s `extraTabs` (`{ value, label,
|
|
21
|
+
An entry of `AccountPage`'s `extraTabs` (`{ value, label, render, visible? }`) may carry an optional `group` naming one of
|
|
22
22
|
the kit's navigation groups: `my-account` (Profile, Security), `management` (Users, Invite) or `help` (Support). The tab
|
|
23
23
|
then appears in that group after the kit's own tabs, in the order of `extraTabs`, in the desktop sidebar and in the
|
|
24
24
|
phone navigation. Without `group`, or with `more` or an unknown value, it stays in "More" as before.
|
|
25
25
|
|
|
26
|
+
## Account page: app-defined groups
|
|
27
|
+
|
|
28
|
+
Since 4.21.0 `AccountPage` takes an optional `groups` declaration that replaces the kit's three groups:
|
|
29
|
+
`[{ key, label, order?, tabs?, visible? }]`. `label` is the app's text (or `(context) => string`); groups render by
|
|
30
|
+
`order` (array order when absent); `tabs` places the built-in tabs (`profile`, `security`, `users`, `invite`,
|
|
31
|
+
`support`), each still shown only when its own permission check passes; `extraTabs[].group` may name any declared key.
|
|
32
|
+
`visible(context)` (`context` = `{ user, perms, isSuperUser, t }`, as for `extraTabs`) hides a group and makes its tabs
|
|
33
|
+
unreachable, `?tab=` included. Empty groups are hidden; a tab placed in no declared group lands in "More". Without
|
|
34
|
+
`groups` the hub is unchanged.
|
|
35
|
+
|
|
36
|
+
```jsx
|
|
37
|
+
<AccountPage
|
|
38
|
+
groups={[
|
|
39
|
+
{ key: 'personal', label: 'Persönlich', tabs: ['profile', 'security'] },
|
|
40
|
+
{ key: 'collaboration', label: 'Zusammenarbeit', tabs: ['invite'] },
|
|
41
|
+
{ key: 'help', label: 'Hilfe', tabs: ['support'] },
|
|
42
|
+
{ key: 'operations', label: 'Betrieb', tabs: ['users'], visible: ({ user }) => isOperator(user) },
|
|
43
|
+
]}
|
|
44
|
+
extraTabs={[
|
|
45
|
+
{ value: 'subscription', label: 'Abo und Token', group: 'personal', render: () => <Subscription /> },
|
|
46
|
+
{ value: 'teams', label: 'Teams', group: 'collaboration', render: () => <Teams /> },
|
|
47
|
+
{ value: 'all-projects', label: 'Alle Projekte', group: 'operations', render: () => <AllProjects /> },
|
|
48
|
+
]}
|
|
49
|
+
/>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Labels are passed already translated (for example `t('Maana.GROUP_PERSONAL')`), so an app's own DE and EN texts apply.
|
|
53
|
+
|
|
26
54
|
## Users tab: access column and delete
|
|
27
55
|
|
|
28
56
|
With billing in the account page, the user list shows two columns: "Zugang", a short coloured status ("Freigeschaltet",
|
|
@@ -31,8 +31,11 @@ import { useBillingUsersColumn } from '../billing/useBillingUsersColumn';
|
|
|
31
31
|
* `billingOperator({ user, account }) => boolean` (optional, UCM-BILL-10): the app's operator rule for the billing
|
|
32
32
|
* users columns built when `billingUsers` is set (status, badge and the "Ohne Abo" switch). Without it superusers are
|
|
33
33
|
* the operators. A new function on each render only recomputes the columns; it does not refetch the accounts.
|
|
34
|
+
* `groups` (optional): app-defined account navigation groups with `{ key, label, order?, tabs?, visible? }`. Labels
|
|
35
|
+
* may be strings or `(context) => string`; `tabs` assigns built-in tab values, and `visible(context)` can hide a group
|
|
36
|
+
* and its tabs. Without this prop, the default groups and placement are unchanged.
|
|
34
37
|
*/
|
|
35
|
-
export function AccountPage({ userListExtraColumns = [], userListExtraRowActions = [], userListExtraContext = null, userListRefreshTrigger = 0, userListCanEditUser = null, userListShowNewColumn = true, userListShowSuccessfulLoginColumn = true, userListShowRoleColumn = true, userListOnChangeRole = null, userListShowDeleteAction = true, userListCanDeleteUser = null, userListOnDeleteUser = null, showBulkInviteCsvTab = false, bulkInviteCsvProps = {}, extraTabs = [], showProfileStatements = true, billingUsers = false, billingOperator, }) {
|
|
38
|
+
export function AccountPage({ userListExtraColumns = [], userListExtraRowActions = [], userListExtraContext = null, userListRefreshTrigger = 0, userListCanEditUser = null, userListShowNewColumn = true, userListShowSuccessfulLoginColumn = true, userListShowRoleColumn = true, userListOnChangeRole = null, userListShowDeleteAction = true, userListCanDeleteUser = null, userListOnDeleteUser = null, showBulkInviteCsvTab = false, bulkInviteCsvProps = {}, extraTabs = [], showProfileStatements = true, billingUsers = false, billingOperator, groups: groupsProp, }) {
|
|
36
39
|
var _a;
|
|
37
40
|
const { t, i18n } = useTranslation();
|
|
38
41
|
const { user, login, loading } = useContext(AuthContext);
|
|
@@ -62,6 +65,25 @@ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions
|
|
|
62
65
|
const canSendInvites = Boolean(isSuperUser || perms.can_send_invites);
|
|
63
66
|
const canManageAccessCodes = Boolean(isSuperUser || perms.can_manage_access_codes);
|
|
64
67
|
const canManageSignupQr = Boolean(isSuperUser || perms.can_manage_signup_qr);
|
|
68
|
+
const extensionContext = { user, perms, isSuperUser, t };
|
|
69
|
+
const declaredGroups = useMemo(() => {
|
|
70
|
+
if (!Array.isArray(groupsProp))
|
|
71
|
+
return null;
|
|
72
|
+
const definitions = groupsProp
|
|
73
|
+
.filter((group) => group && typeof group.key === 'string' && group.key.length > 0)
|
|
74
|
+
.map((group, index) => (Object.assign(Object.assign({}, group), { index, sortOrder: Number.isFinite(group.order) ? group.order : index, isVisible: typeof group.visible === 'function' ? Boolean(group.visible(extensionContext)) : true })))
|
|
75
|
+
.sort((left, right) => left.sortOrder - right.sortOrder || left.index - right.index);
|
|
76
|
+
const builtInAssignments = new Map();
|
|
77
|
+
definitions.forEach((group) => {
|
|
78
|
+
(Array.isArray(group.tabs) ? group.tabs : []).forEach((value) => {
|
|
79
|
+
if (['profile', 'security', 'users', 'invite', 'support'].includes(value)
|
|
80
|
+
&& !builtInAssignments.has(value)) {
|
|
81
|
+
builtInAssignments.set(value, group.key);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
return { definitions, builtInAssignments };
|
|
86
|
+
}, [groupsProp, user, perms, isSuperUser, t]);
|
|
65
87
|
const handleTabChange = (_event, newValue) => {
|
|
66
88
|
setSearchParams({ tab: newValue });
|
|
67
89
|
};
|
|
@@ -101,7 +123,6 @@ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions
|
|
|
101
123
|
const tabs = useMemo(() => {
|
|
102
124
|
if (!user)
|
|
103
125
|
return [];
|
|
104
|
-
const extensionContext = { user, perms, isSuperUser, t };
|
|
105
126
|
const list = [
|
|
106
127
|
{ value: 'profile', label: t('Account.TAB_PROFILE', 'Profile') },
|
|
107
128
|
{ value: 'security', label: t('Account.TAB_SECURITY', 'Security') },
|
|
@@ -116,19 +137,65 @@ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions
|
|
|
116
137
|
if (isSuperUser || perms.can_view_support) {
|
|
117
138
|
list.push({ value: 'support', label: t('Account.TAB_SUPPORT', 'Support') });
|
|
118
139
|
}
|
|
140
|
+
if (declaredGroups) {
|
|
141
|
+
for (let index = list.length - 1; index >= 0; index -= 1) {
|
|
142
|
+
const assignedGroupKey = declaredGroups.builtInAssignments.get(list[index].value);
|
|
143
|
+
const assignedGroup = declaredGroups.definitions.find((group) => group.key === assignedGroupKey);
|
|
144
|
+
if (assignedGroup && !assignedGroup.isVisible)
|
|
145
|
+
list.splice(index, 1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
119
148
|
extraTabs.forEach((tab) => {
|
|
120
149
|
if (!(tab === null || tab === void 0 ? void 0 : tab.value) || !(tab === null || tab === void 0 ? void 0 : tab.label))
|
|
121
150
|
return;
|
|
122
151
|
const isVisible = typeof tab.visible === 'function' ? tab.visible(extensionContext) : true;
|
|
152
|
+
const declaredGroup = declaredGroups === null || declaredGroups === void 0 ? void 0 : declaredGroups.definitions.find((group) => group.key === tab.group);
|
|
153
|
+
const collidesWithBuiltIn = declaredGroups
|
|
154
|
+
&& ['profile', 'security', 'users', 'invite', 'support'].includes(tab.value);
|
|
155
|
+
if (declaredGroups && (collidesWithBuiltIn || (declaredGroup && !declaredGroup.isVisible)))
|
|
156
|
+
return;
|
|
123
157
|
if (isVisible && !list.some((entry) => entry.value === tab.value)) {
|
|
124
|
-
//
|
|
125
|
-
const group =
|
|
158
|
+
// Legacy apps may join the three built-in groups; declared apps may use any declared group key.
|
|
159
|
+
const group = declaredGroups
|
|
160
|
+
? (declaredGroup ? tab.group : undefined)
|
|
161
|
+
: (['my-account', 'management', 'help'].includes(tab.group) ? tab.group : undefined);
|
|
126
162
|
list.push(Object.assign({ value: tab.value, label: typeof tab.label === 'function' ? tab.label(extensionContext) : tab.label }, (group ? { group } : {})));
|
|
127
163
|
}
|
|
128
164
|
});
|
|
129
165
|
return list;
|
|
130
|
-
}, [user, perms, t, isSuperUser, extraTabs, canViewUsers, canViewInvite]);
|
|
166
|
+
}, [user, perms, t, isSuperUser, extraTabs, canViewUsers, canViewInvite, declaredGroups]);
|
|
131
167
|
const groups = useMemo(() => {
|
|
168
|
+
if (declaredGroups) {
|
|
169
|
+
const placedValues = new Set();
|
|
170
|
+
const mappedGroups = declaredGroups.definitions
|
|
171
|
+
.filter((group) => group.isVisible)
|
|
172
|
+
.map((group) => {
|
|
173
|
+
const builtInValues = (Array.isArray(group.tabs) ? group.tabs : [])
|
|
174
|
+
.filter((value) => declaredGroups.builtInAssignments.get(value) === group.key);
|
|
175
|
+
const items = [
|
|
176
|
+
...builtInValues.map((value) => tabs.find((tab) => tab.value === value)).filter(Boolean),
|
|
177
|
+
...tabs.filter((tab) => tab.group === group.key),
|
|
178
|
+
].map((tab) => ({ key: tab.value, label: tab.label }));
|
|
179
|
+
items.forEach((item) => placedValues.add(item.key));
|
|
180
|
+
return {
|
|
181
|
+
key: group.key,
|
|
182
|
+
label: typeof group.label === 'function' ? group.label(extensionContext) : group.label,
|
|
183
|
+
items,
|
|
184
|
+
};
|
|
185
|
+
})
|
|
186
|
+
.filter((group) => group.items.length > 0);
|
|
187
|
+
const extraItems = tabs
|
|
188
|
+
.filter((tab) => !placedValues.has(tab.value))
|
|
189
|
+
.map((tab) => ({ key: tab.value, label: tab.label }));
|
|
190
|
+
if (extraItems.length > 0) {
|
|
191
|
+
mappedGroups.push({
|
|
192
|
+
key: 'more',
|
|
193
|
+
label: t('Account.GROUP_MORE', 'More'),
|
|
194
|
+
items: extraItems,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return mappedGroups;
|
|
198
|
+
}
|
|
132
199
|
const groupDefinitions = [
|
|
133
200
|
{
|
|
134
201
|
key: 'my-account',
|
|
@@ -168,7 +235,7 @@ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions
|
|
|
168
235
|
});
|
|
169
236
|
}
|
|
170
237
|
return mappedGroups.filter((group) => group.items.length > 0);
|
|
171
|
-
}, [tabs, t]);
|
|
238
|
+
}, [tabs, t, declaredGroups, user, perms, isSuperUser]);
|
|
172
239
|
// 4. Loading & Auth Checks
|
|
173
240
|
if (loading) {
|
|
174
241
|
return (_jsx(Box, { sx: { display: 'flex', justifyContent: 'center', mt: 10 }, children: _jsx(CircularProgress, {}) }));
|