@micha.bigler/ui-core-micha 2.2.6 → 2.2.8

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.
@@ -38,6 +38,11 @@ export function AccountPage({
38
38
  userListExtraContext = null,
39
39
  userListRefreshTrigger = 0,
40
40
  userListCanEditUser = null,
41
+ userListShowRoleColumn = true,
42
+ userListOnChangeRole = null,
43
+ userListShowDeleteAction = true,
44
+ userListCanDeleteUser = null,
45
+ userListOnDeleteUser = null,
41
46
  showBulkInviteCsvTab = false,
42
47
  bulkInviteCsvProps = {},
43
48
  extraTabs = [],
@@ -62,6 +67,13 @@ export function AccountPage({
62
67
 
63
68
  // NEU: Superuser-Flag prüfen
64
69
  const isSuperUser = user?.is_superuser || false;
70
+ const canViewUsers = Boolean(isSuperUser || perms.can_view_users);
71
+ const canViewInvite = Boolean(isSuperUser || perms.can_view_invite || perms.can_invite);
72
+ const canViewAuthPolicy = Boolean(isSuperUser || perms.can_view_auth_policy);
73
+ const canWriteAuthPolicy = Boolean(isSuperUser || perms.can_write_auth_policy);
74
+ const canSendInvites = Boolean(isSuperUser || perms.can_send_invites);
75
+ const canManageAccessCodes = Boolean(isSuperUser || perms.can_manage_access_codes);
76
+ const canManageSignupQr = Boolean(isSuperUser || perms.can_manage_signup_qr);
65
77
 
66
78
  const handleTabChange = (_event, newValue) => {
67
79
  setSearchParams({ tab: newValue });
@@ -74,7 +86,7 @@ export function AccountPage({
74
86
 
75
87
  useEffect(() => {
76
88
  let active = true;
77
- const canLoadPolicy = Boolean(user) && (isSuperUser || perms.can_invite || perms.can_manage_access_codes);
89
+ const canLoadPolicy = Boolean(user) && (canViewAuthPolicy || canManageSignupQr || canManageAccessCodes);
78
90
 
79
91
  if (!canLoadPolicy) {
80
92
  setAuthPolicy(null);
@@ -102,7 +114,7 @@ export function AccountPage({
102
114
  return () => {
103
115
  active = false;
104
116
  };
105
- }, [user, isSuperUser, perms.can_invite, perms.can_manage_access_codes, t]);
117
+ }, [user, canViewAuthPolicy, canManageSignupQr, canManageAccessCodes, t]);
106
118
 
107
119
  // 3. Dynamic Tabs (angepasst für Superuser)
108
120
  const tabs = useMemo(() => {
@@ -116,11 +128,11 @@ export function AccountPage({
116
128
 
117
129
  // Logik: Superuser darf ALLES, sonst gelten die spezifischen Permissions
118
130
 
119
- if (isSuperUser || perms.can_view_users) {
131
+ if (canViewUsers) {
120
132
  list.push({ value: 'users', label: t('Account.TAB_USERS', 'Users') });
121
133
  }
122
134
 
123
- if (isSuperUser || perms.can_invite || perms.can_manage_access_codes) {
135
+ if (canViewInvite) {
124
136
  list.push({ value: 'invite', label: t('Account.TAB_INVITE', 'Invite') });
125
137
  }
126
138
 
@@ -140,7 +152,7 @@ export function AccountPage({
140
152
  });
141
153
 
142
154
  return list;
143
- }, [user, perms, t, isSuperUser, extraTabs]);
155
+ }, [user, perms, t, isSuperUser, extraTabs, canViewUsers, canViewInvite]);
144
156
 
145
157
  // 4. Loading & Auth Checks
146
158
  if (loading) {
@@ -220,6 +232,11 @@ export function AccountPage({
220
232
  extraContext={userListExtraContext}
221
233
  refreshTrigger={userListRefreshTrigger}
222
234
  canEditUser={userListCanEditUser}
235
+ showRoleColumn={userListShowRoleColumn}
236
+ onChangeRole={userListOnChangeRole}
237
+ showDeleteAction={userListShowDeleteAction}
238
+ canDeleteUser={userListCanDeleteUser}
239
+ onDeleteUser={userListOnDeleteUser}
223
240
  />
224
241
  </Box>
225
242
  )}
@@ -227,29 +244,30 @@ export function AccountPage({
227
244
  {safeTab === 'invite' && (
228
245
  <Box sx={{ mt: 2 }}>
229
246
  <Stack spacing={2.5}>
230
- {(isSuperUser || perms.can_invite) && (
247
+ {canViewAuthPolicy && (
231
248
  <Paper variant="outlined" sx={{ p: 2.5, borderRadius: 2 }}>
232
- <AuthFactorRequirementCard />
249
+ <AuthFactorRequirementCard canEdit={canWriteAuthPolicy} policy={authPolicy} />
233
250
  </Paper>
234
251
  )}
235
252
 
236
- {(isSuperUser || perms.can_invite) && (
253
+ {canViewAuthPolicy && (
237
254
  <Paper variant="outlined" sx={{ p: 2.5, borderRadius: 2 }}>
238
255
  <RegistrationMethodsManager
239
256
  policy={authPolicy}
240
257
  error={authPolicyError}
241
258
  onPolicyChange={setAuthPolicy}
259
+ canEdit={canWriteAuthPolicy}
242
260
  />
243
261
  </Paper>
244
262
  )}
245
263
 
246
- {(isSuperUser || perms.can_invite) && Boolean(authPolicy?.allow_admin_invite) && (
264
+ {canSendInvites && Boolean(authPolicy?.allow_admin_invite) && (
247
265
  <Paper variant="outlined" sx={{ p: 2.5, borderRadius: 2 }}>
248
266
  <UserInviteComponent />
249
267
  </Paper>
250
268
  )}
251
269
 
252
- {(isSuperUser || perms.can_manage_access_codes) && Boolean(authPolicy?.allow_self_signup_access_code) && (
270
+ {canManageAccessCodes && Boolean(authPolicy?.allow_self_signup_access_code) && (
253
271
  <Paper variant="outlined" sx={{ p: 2.5, borderRadius: 2 }}>
254
272
  <Typography variant="h6" gutterBottom>
255
273
  {t('Auth.ACCESS_CODE_MANAGER_TITLE', 'Access Codes')}
@@ -261,33 +279,35 @@ export function AccountPage({
261
279
  </Paper>
262
280
  )}
263
281
 
264
- {(isSuperUser || perms.can_invite) && showBulkInviteCsvTab && Boolean(authPolicy?.allow_admin_invite) && (
282
+ {canSendInvites && showBulkInviteCsvTab && Boolean(authPolicy?.allow_admin_invite) && (
265
283
  <Paper variant="outlined" sx={{ p: 2.5, borderRadius: 2 }}>
266
284
  <BulkInviteCsvTab {...bulkInviteCsvProps} />
267
285
  </Paper>
268
286
  )}
269
287
 
270
- {(isSuperUser || perms.can_invite) && Boolean(authPolicy?.allow_self_signup_email_domain) && (
288
+ {canViewAuthPolicy && Boolean(authPolicy?.allow_self_signup_email_domain) && (
271
289
  <Paper variant="outlined" sx={{ p: 2.5, borderRadius: 2 }}>
272
290
  <AllowedEmailDomainsManager
273
291
  enabled={Boolean(authPolicy?.allow_self_signup_email_domain)}
274
292
  domains={authPolicy?.allowed_email_domains || []}
275
293
  onPolicyChange={setAuthPolicy}
294
+ canEdit={canWriteAuthPolicy}
276
295
  />
277
296
  </Paper>
278
297
  )}
279
298
 
280
- {(isSuperUser || perms.can_invite) && Boolean(authPolicy?.allow_self_signup_qr) && (
299
+ {canViewAuthPolicy && Boolean(authPolicy?.allow_self_signup_qr) && (
281
300
  <Paper variant="outlined" sx={{ p: 2.5, borderRadius: 2 }}>
282
301
  <QrSignupValidityManager
283
302
  enabled={Boolean(authPolicy?.allow_self_signup_qr)}
284
303
  expiryDays={authPolicy?.signup_qr_expiry_days}
285
304
  onPolicyChange={setAuthPolicy}
305
+ canEdit={canWriteAuthPolicy}
286
306
  />
287
307
  </Paper>
288
308
  )}
289
309
 
290
- {(isSuperUser || perms.can_invite) && Boolean(authPolicy?.allow_self_signup_qr) && (
310
+ {canManageSignupQr && Boolean(authPolicy?.allow_self_signup_qr) && (
291
311
  <Paper variant="outlined" sx={{ p: 2.5, borderRadius: 2 }}>
292
312
  <QrSignupManager
293
313
  enabled={Boolean(authPolicy?.allow_self_signup_qr)}