@micha.bigler/ui-core-micha 4.16.0 → 4.18.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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.18.0 - UCM-BILL-10
4
+
5
+ `AccountPage` accepts an optional `billingOperator({ user, account }) => boolean` and passes it as the operator rule to
6
+ the billing users columns it builds when `billingUsers` is set, so status, badge and the "Ohne Abo" switch follow the
7
+ app's rule. Without the prop the superuser default stays; with `billingUsers` off nothing changes.
8
+
9
+ ## 4.17.0 - UCM-BILL-9
10
+
11
+ Users tab, every app: the billing access column is a short coloured status (`accountAccessText` now returns
12
+ "Freigeschaltet", "{plan name} · bis {short date}", "Team · bis {date}", "Schreibgeschützt" or "Betreiber"; plan names from
13
+ `getMe().plans`, neutral `Billing.OP_SUBSCRIPTION` when missing, never the key) and the free-access switch moved to its own
14
+ "Ohne Abo" column without a visible label (`FreeAccessSwitch` option `hideLabel`; "–" for subscription, team and operator
15
+ rows); grant and revoke dialogs unchanged. `useBillingUsersColumn` returns two columns and takes `isOperator` (default
16
+ `user.is_superuser`). The built-in delete in `UserListComponent` is an icon button named "Löschen – {name}" and is shown
17
+ disabled on the own row instead of hidden; confirmation, permissions and app row actions unchanged. New `formatShortDate`.
18
+ New keys `Billing.OP_FREE_ACCESS_SHORT`, `OP_TEAM`, `OP_OPERATOR`, `OP_SUBSCRIPTION`, `OP_NO_SUBSCRIPTION`,
19
+ `OP_FREE_ACCESS_FOR`, `Common.DELETE_FOR`.
20
+
3
21
  ## 4.16.0 - UCM-CHAT-7
4
22
 
5
23
  Opt-in compact chat composer: `ChatWorkspace` props `composerLayout` (`'standard'` default, `'compact'`) and
package/README.md CHANGED
@@ -23,6 +23,17 @@ the kit's navigation groups: `my-account` (Profile, Security), `management` (Use
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
+ ## Users tab: access column and delete
27
+
28
+ With billing in the account page, the user list shows two columns: "Zugang", a short coloured status ("Freigeschaltet",
29
+ "{Plan} · bis {Datum}", "Team · bis {Datum}", "Schreibgeschützt", "Betreiber"), and "Ohne Abo", the free-access switch
30
+ without a visible label (only for free and read-only rows; "–" otherwise). Plan names come from the app's own catalogue
31
+ (`getMe().plans`); a plan without a name shows "Abo", never its key. Operator rows default to `user.is_superuser`;
32
+ `<AccountPage billingUsers billingOperator={({ user }) => user.is_superuser || user.role === 'admin'}>` (or
33
+ `useBillingUsersColumn({ isOperator })` directly) applies the app's own rule; a new function per render does not
34
+ refetch the accounts. The built-in delete is an icon button
35
+ named "Löschen – {Name}", shown disabled on the own row; confirmation, permissions and app row actions are unchanged.
36
+
26
37
  ## Account section: plan choice on the app's own page
27
38
 
28
39
  `SubscriptionSection` shows an inline plan picker for an account without access. An app with its own plan page passes
@@ -1,29 +1,42 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from 'react';
3
- import { Button, Stack, Typography } from '@mui/material';
3
+ import { Button, Chip, Stack, Typography } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
- import { formatDate } from './format';
6
- import { FreeAccessSwitch } from './FreeAccessSwitch';
7
- export function accountAccessText(account, t, language) {
5
+ import { formatShortDate } from './format';
6
+ import SoftChip from '../components/SoftChip';
7
+ export const BILLING_ACCESS_BADGE_SX = { maxWidth: '100%' };
8
+ export function accountAccessText(account, t, language, { planNames = {}, isOperator = false } = {}) {
8
9
  if (!account)
9
10
  return '–'; // no row for this person (not loaded): say nothing rather than claim read-only
10
11
  const access = account.access || {};
12
+ if (isOperator)
13
+ return t('Billing.OP_OPERATOR');
14
+ if (access.status === 'read_only')
15
+ return t('Billing.OP_READ_ONLY');
11
16
  if (access.source === 'subscription') {
12
- const date = formatDate(account.term_ends_at || access.ends_at, language);
13
- const plan = account.plan_key || '';
14
- return [t('Billing.OP_PLAN', { plan }), date && t('Billing.OP_UNTIL', { date }), access.status === 'read_only' && t('Billing.OP_READ_ONLY')].filter(Boolean).join(' · ');
17
+ const date = formatShortDate(account.term_ends_at || access.ends_at, language);
18
+ const plan = planNames[account.plan_key] || t('Billing.OP_SUBSCRIPTION');
19
+ return [plan, date && t('Billing.OP_UNTIL', { date })].filter(Boolean).join(' · ');
15
20
  }
16
21
  if (access.source === 'team') {
17
- const date = formatDate(access.ends_at, language);
18
- return [t('Billing.OP_TEAM_SEAT'), date && t('Billing.OP_UNTIL', { date }), access.status === 'read_only' && t('Billing.OP_READ_ONLY')].filter(Boolean).join(' · ');
22
+ const date = formatShortDate(access.ends_at, language);
23
+ return [t('Billing.OP_TEAM'), date && t('Billing.OP_UNTIL', { date })].filter(Boolean).join(' · ');
19
24
  }
20
- if (access.source === 'free')
21
- return [t('Billing.OP_FREE_ACCESS'), access.status === 'read_only' && t('Billing.OP_READ_ONLY')].filter(Boolean).join(' · ');
25
+ if (access.source === 'free' && access.status !== 'read_only')
26
+ return t('Billing.OP_FREE_ACCESS_SHORT');
22
27
  return t('Billing.OP_READ_ONLY');
23
28
  }
24
- export function BillingAccessCell({ account, api, onChanged }) {
29
+ export function BillingAccessCell({ account, planNames, isOperator = false }) {
25
30
  const { t, i18n } = useTranslation();
26
- return _jsxs(Stack, { spacing: 0.5, children: [_jsx(Typography, { children: accountAccessText(account, t, i18n.language) }), account && _jsx(FreeAccessSwitch, { account: account, api: api, onChanged: onChanged })] });
31
+ if (!account)
32
+ return '–';
33
+ const access = account.access || {};
34
+ const label = accountAccessText(account, t, i18n.language, { planNames, isOperator });
35
+ // Operator is neutral; the others are the kit's soft tinted status chips, as in the prototype.
36
+ if (isOperator)
37
+ return _jsx(Chip, { size: "small", variant: "outlined", label: label, sx: BILLING_ACCESS_BADGE_SX });
38
+ const tone = access.status === 'read_only' ? 'warning' : access.source === 'subscription' ? 'success' : 'primary';
39
+ return _jsx(SoftChip, { tone: tone, label: label });
27
40
  }
28
41
  export function BillingAccessError({ onRetry }) {
29
42
  const { t } = useTranslation();
@@ -1,10 +1,10 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { useId, useRef, useState } from 'react';
3
- import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, Switch, TextField, Box } from '@mui/material';
3
+ import { Alert, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControlLabel, Switch, TextField, Box, Tooltip } from '@mui/material';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  export const FREE_ACCESS_SWITCH_ALERT_SX = { width: '100%' };
6
6
  const statusOf = (error) => { var _a; return (_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.status; };
7
- export function FreeAccessSwitch({ account, api, onChanged, sx }) {
7
+ export function FreeAccessSwitch({ account, api, onChanged, sx, hideLabel = false, name }) {
8
8
  const { t } = useTranslation();
9
9
  const [open, setOpen] = useState(false);
10
10
  const [reason, setReason] = useState('');
@@ -13,6 +13,7 @@ export function FreeAccessSwitch({ account, api, onChanged, sx }) {
13
13
  const inFlight = useRef(false);
14
14
  const titleId = useId();
15
15
  const active = Boolean(account === null || account === void 0 ? void 0 : account.free_access);
16
+ const displayName = name || (account === null || account === void 0 ? void 0 : account.name) || (account === null || account === void 0 ? void 0 : account.email) || (account === null || account === void 0 ? void 0 : account.user_id) || '';
16
17
  const openDialog = () => { setReason(''); setError(null); setOpen(true); };
17
18
  const close = () => { if (!busy)
18
19
  setOpen(false); };
@@ -36,6 +37,7 @@ export function FreeAccessSwitch({ account, api, onChanged, sx }) {
36
37
  }
37
38
  };
38
39
  const validReason = reason.trim().length > 0 && reason.trim().length <= 1000;
39
- return _jsxs(_Fragment, { children: [_jsx(Box, { sx: sx, children: _jsx(FormControlLabel, { control: _jsx(Switch, { checked: active, disabled: busy, onChange: openDialog, slotProps: { input: { 'aria-label': `${t('Billing.OP_FREE_ACCESS')} – ${(account === null || account === void 0 ? void 0 : account.name) || (account === null || account === void 0 ? void 0 : account.email) || (account === null || account === void 0 ? void 0 : account.user_id)}` } } }), label: t('Billing.OP_FREE_ACCESS') }) }), _jsxs(Dialog, { open: open, onClose: close, "aria-labelledby": titleId, children: [_jsx(DialogTitle, { id: titleId, children: active ? t('Billing.OP_REVOKE_TITLE') : t('Billing.OP_FREE_ACCESS') }), _jsxs(DialogContent, { children: [active ? _jsx("p", { children: t('Billing.OP_REVOKE_BODY') }) : _jsx(TextField, { label: t('Billing.OP_REASON'), multiline: true, required: true, fullWidth: true, disabled: busy, value: reason, onChange: (event) => setReason(event.target.value), inputProps: { maxLength: 1001 } }), error && _jsx(Alert, { severity: "error", sx: FREE_ACCESS_SWITCH_ALERT_SX, children: t(error) })] }), _jsxs(DialogActions, { children: [_jsx(Button, { disabled: busy, onClick: close, children: t('Billing.OP_CANCEL') }), _jsx(Button, { disabled: busy || (!active && !validReason), onClick: submit, children: active ? t('Billing.OP_REVOKE') : t('Billing.OP_GRANT') })] })] })] });
40
+ const control = _jsx(Switch, { checked: active, disabled: busy, onChange: openDialog, slotProps: { input: { 'aria-label': hideLabel ? t('Billing.OP_FREE_ACCESS_FOR', { name: displayName }) : `${t('Billing.OP_FREE_ACCESS')} – ${displayName}` } } });
41
+ return _jsxs(_Fragment, { children: [_jsx(Box, { sx: sx, children: hideLabel ? _jsx(Tooltip, { title: t('Billing.OP_FREE_ACCESS_FOR', { name: displayName }), children: _jsx("span", { children: control }) }) : _jsx(FormControlLabel, { control: control, label: t('Billing.OP_FREE_ACCESS') }) }), _jsxs(Dialog, { open: open, onClose: close, "aria-labelledby": titleId, children: [_jsx(DialogTitle, { id: titleId, children: active ? t('Billing.OP_REVOKE_TITLE') : t('Billing.OP_FREE_ACCESS') }), _jsxs(DialogContent, { children: [active ? _jsx("p", { children: t('Billing.OP_REVOKE_BODY') }) : _jsx(TextField, { label: t('Billing.OP_REASON'), multiline: true, required: true, fullWidth: true, disabled: busy, value: reason, onChange: (event) => setReason(event.target.value), inputProps: { maxLength: 1001 } }), error && _jsx(Alert, { severity: "error", sx: FREE_ACCESS_SWITCH_ALERT_SX, children: t(error) })] }), _jsxs(DialogActions, { children: [_jsx(Button, { disabled: busy, onClick: close, children: t('Billing.OP_CANCEL') }), _jsx(Button, { disabled: busy || (!active && !validReason), onClick: submit, children: active ? t('Billing.OP_REVOKE') : t('Billing.OP_GRANT') })] })] })] });
40
42
  }
41
43
  export default FreeAccessSwitch;
@@ -38,6 +38,14 @@ export function formatDate(iso, language) {
38
38
  return '';
39
39
  return new Intl.DateTimeFormat(intlLocale(language), { year: 'numeric', month: 'long', day: 'numeric', timeZone: 'UTC' }).format(date);
40
40
  }
41
+ export function formatShortDate(iso, language) {
42
+ if (typeof iso !== 'string' || !iso)
43
+ return '';
44
+ const date = new Date(iso);
45
+ if (!Number.isFinite(date.getTime()))
46
+ return '';
47
+ return new Intl.DateTimeFormat(intlLocale(language), { year: 'numeric', month: 'numeric', day: 'numeric', timeZone: 'UTC' }).format(date);
48
+ }
41
49
  export function formatDateTime(iso, language) {
42
50
  if (typeof iso !== 'string' || !iso)
43
51
  return '';
@@ -1,21 +1,60 @@
1
- import React, { useMemo } from 'react';
1
+ import React, { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { useTranslation } from 'react-i18next';
3
3
  import { defaultBillingApi } from './api';
4
4
  import { BillingAccessCell, BillingAccessError, accountAccessText } from './BillingAccessCell';
5
+ import { FreeAccessSwitch } from './FreeAccessSwitch';
5
6
  import { useOperatorAccounts } from './useOperatorAccounts';
6
- export function useBillingUsersColumn({ api = defaultBillingApi, enabled = true } = {}) {
7
+ const defaultIsOperator = ({ user }) => (user === null || user === void 0 ? void 0 : user.is_superuser) === true;
8
+ const userName = (user) => [user === null || user === void 0 ? void 0 : user.first_name, user === null || user === void 0 ? void 0 : user.last_name].filter(Boolean).join(' ') || (user === null || user === void 0 ? void 0 : user.name) || (user === null || user === void 0 ? void 0 : user.email) || (user === null || user === void 0 ? void 0 : user.username) || '';
9
+ export function useBillingUsersColumn({ api = defaultBillingApi, enabled = true, isOperator = defaultIsOperator } = {}) {
7
10
  const { t, i18n } = useTranslation();
8
11
  const billing = useOperatorAccounts(api, { enabled });
12
+ const [planNames, setPlanNames] = useState({});
13
+ // Plan names are loaded once per activation; reading `api` through a ref keeps an inline `api` object from
14
+ // refetching on every render.
15
+ const apiRef = useRef(api);
16
+ apiRef.current = api;
17
+ useEffect(() => {
18
+ var _a;
19
+ let active = true;
20
+ const getMe = (_a = apiRef.current) === null || _a === void 0 ? void 0 : _a.getMe;
21
+ if (!enabled || typeof getMe !== 'function') {
22
+ setPlanNames({});
23
+ return () => { active = false; };
24
+ }
25
+ Promise.resolve().then(() => getMe.call(apiRef.current)).then((me) => {
26
+ if (!active)
27
+ return;
28
+ setPlanNames(Object.fromEntries((Array.isArray(me === null || me === void 0 ? void 0 : me.plans) ? me.plans : []).filter((plan) => (plan === null || plan === void 0 ? void 0 : plan.key) && (plan === null || plan === void 0 ? void 0 : plan.name)).map((plan) => [plan.key, plan.name])));
29
+ }).catch(() => { if (active)
30
+ setPlanNames({}); });
31
+ return () => { active = false; };
32
+ }, [enabled]);
9
33
  const extraColumns = useMemo(() => billing.status === 'error' ? [{
10
34
  key: 'billing-access', label: t('Billing.OP_ACCESS'), minWidth: 260,
11
35
  renderCell: () => React.createElement(BillingAccessError, { onRetry: billing.reload }),
12
36
  getSortValue: () => '', getSearchValue: () => '',
13
- }] : billing.status !== 'ready' ? [] : [{
14
- key: 'billing-access', label: t('Billing.OP_ACCESS'), minWidth: 260,
15
- renderCell: ({ user }) => React.createElement(BillingAccessCell, { account: billing.accounts.get(user === null || user === void 0 ? void 0 : user.id), api, onChanged: (answer) => billing.setFreeAccess(user.id, answer) }),
16
- getSortValue: ({ user }) => accountAccessText(billing.accounts.get(user === null || user === void 0 ? void 0 : user.id), t, i18n.language),
17
- getSearchValue: ({ user }) => accountAccessText(billing.accounts.get(user === null || user === void 0 ? void 0 : user.id), t, i18n.language),
18
- }], [billing.status, billing.accounts, billing.setFreeAccess, billing.reload, api, t, i18n.language]);
37
+ }] : billing.status !== 'ready' ? [] : (() => {
38
+ const statusFor = ({ user, account }) => accountAccessText(account, t, i18n.language, { planNames, isOperator: isOperator({ user, account }) });
39
+ return [{
40
+ key: 'billing-access', label: t('Billing.OP_ACCESS'), minWidth: 180,
41
+ renderCell: ({ user }) => React.createElement(BillingAccessCell, { account: billing.accounts.get(user === null || user === void 0 ? void 0 : user.id), planNames, isOperator: isOperator({ user, account: billing.accounts.get(user === null || user === void 0 ? void 0 : user.id) }) }),
42
+ getSortValue: (context) => { var _a; return statusFor(Object.assign(Object.assign({}, context), { account: billing.accounts.get((_a = context.user) === null || _a === void 0 ? void 0 : _a.id) })); },
43
+ getSearchValue: (context) => { var _a; return statusFor(Object.assign(Object.assign({}, context), { account: billing.accounts.get((_a = context.user) === null || _a === void 0 ? void 0 : _a.id) })); },
44
+ }, {
45
+ key: 'billing-free-access', label: t('Billing.OP_NO_SUBSCRIPTION'), minWidth: 112, align: 'center',
46
+ renderCell: ({ user }) => {
47
+ var _a, _b;
48
+ const account = billing.accounts.get(user === null || user === void 0 ? void 0 : user.id);
49
+ const operator = isOperator({ user, account });
50
+ const source = (_a = account === null || account === void 0 ? void 0 : account.access) === null || _a === void 0 ? void 0 : _a.source;
51
+ if (!account || operator || source === 'subscription' || source === 'team' || (source !== 'free' && ((_b = account.access) === null || _b === void 0 ? void 0 : _b.status) !== 'read_only'))
52
+ return '–';
53
+ return React.createElement(FreeAccessSwitch, { account, api, name: userName(user), hideLabel: true, onChanged: (answer) => billing.setFreeAccess(user.id, answer) });
54
+ },
55
+ getSortValue: () => '', getSearchValue: () => '',
56
+ }];
57
+ })(), [billing.status, billing.accounts, billing.setFreeAccess, billing.reload, api, t, i18n.language, planNames, isOperator]);
19
58
  return { status: billing.status, extraColumns, reload: billing.reload };
20
59
  }
21
60
  export default useBillingUsersColumn;
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React, { useMemo, useState, useEffect, useCallback } from 'react';
3
- import { Box, Typography, FormControl, Select, MenuItem, Button, Tooltip, CircularProgress, Alert, TextField, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TableSortLabel, TablePagination, } from '@mui/material';
3
+ import { Box, Typography, FormControl, Select, MenuItem, Button, IconButton, Tooltip, CircularProgress, Alert, TextField, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TableSortLabel, TablePagination, } from '@mui/material';
4
4
  import CheckCircleIcon from '@mui/icons-material/CheckCircle';
5
5
  import CancelIcon from '@mui/icons-material/Cancel';
6
6
  import DeleteIcon from '@mui/icons-material/Delete';
@@ -148,6 +148,7 @@ export function UserListComponent({ roles = DEFAULT_ROLES, currentUser, extraCol
148
148
  }
149
149
  return (user === null || user === void 0 ? void 0 : user.username) || '';
150
150
  };
151
+ const getUserDeleteName = (user) => getUserDisplayName(user) || (user === null || user === void 0 ? void 0 : user.email) || (user === null || user === void 0 ? void 0 : user.username) || '';
151
152
  const renderBooleanStatusIcon = (value, positiveLabel, negativeLabel) => (_jsx(Tooltip, { title: value ? positiveLabel : negativeLabel, children: _jsx("span", { children: value ? (_jsx(CheckCircleIcon, { color: "success", fontSize: "small" })) : (_jsx(CancelIcon, { color: "error", fontSize: "small" })) }) }));
152
153
  const getExtraColumnSortValue = (column, user) => {
153
154
  var _a;
@@ -340,7 +341,7 @@ export function UserListComponent({ roles = DEFAULT_ROLES, currentUser, extraCol
340
341
  return (_jsx(Button, { size: "small", variant: "outlined", onClick: () => runRowAction(action, row), disabled: isBusy || isDisabled, sx: USER_LIST_ACTION_SX, children: typeof action.label === 'function'
341
342
  ? action.label({ user: row, t, currentUser, canEdit: canEdit(row) })
342
343
  : action.label }, `${action.key}-${row.id}`));
343
- }), showDeleteAction && !isOwnRow(row) && (_jsx(Tooltip, { title: t('Common.DELETE', 'Delete'), children: _jsx("span", { children: _jsx(Button, { size: "small", variant: "outlined", color: "error", startIcon: _jsx(DeleteIcon, {}), onClick: () => handleDelete(row.id), disabled: !canDelete(row), sx: USER_LIST_ACTION_SX, children: t('Common.DELETE', 'Delete') }) }) }))] })),
344
+ }), showDeleteAction && (_jsx(Tooltip, { title: t('Common.DELETE_FOR', { name: getUserDeleteName(row) }), children: _jsx("span", { children: _jsx(IconButton, { color: "error", "aria-label": t('Common.DELETE_FOR', { name: getUserDeleteName(row) }), onClick: () => handleDelete(row.id), disabled: isOwnRow(row) || !canDelete(row), size: "small", children: _jsx(DeleteIcon, { fontSize: "small" }) }) }) }))] })),
344
345
  };
345
346
  return [...baseColumns, ...mappedExtraColumns, actionColumn];
346
347
  }, [
@@ -1723,6 +1723,12 @@ export const authTranslations = {
1723
1723
  "en": "Delete",
1724
1724
  "sw": "Futa"
1725
1725
  },
1726
+ "Common.DELETE_FOR": {
1727
+ "de": "Löschen – {{name}}",
1728
+ "fr": "Supprimer – {{name}}",
1729
+ "en": "Delete – {{name}}",
1730
+ "sw": "Futa – {{name}}"
1731
+ },
1726
1732
  "Common.CANCEL": {
1727
1733
  "de": "Abbrechen",
1728
1734
  "fr": "Annuler",
@@ -78,6 +78,12 @@ export const billingTranslations = {
78
78
  'Billing.OP_OVERVIEW_TITLE': { de: 'Übersicht Abos', de_informal: 'Übersicht Abos', en: 'Subscription overview', fr: 'Aperçu des abonnements', sw: 'Muhtasari wa usajili' },
79
79
  'Billing.OP_ACTIVE_ACCOUNTS': { de: 'Aktive Konten', de_informal: 'Aktive Konten', en: 'Active accounts', fr: 'Comptes actifs', sw: 'Akaunti zinazotumika' },
80
80
  'Billing.OP_PLAN': { de: 'Abo {{plan}}', de_informal: 'Abo {{plan}}', en: 'Subscription {{plan}}', fr: 'Abonnement {{plan}}', sw: 'Usajili {{plan}}' },
81
+ 'Billing.OP_SUBSCRIPTION': { de: 'Abo', de_informal: 'Abo', en: 'Subscription', fr: 'Abonnement', sw: 'Usajili' },
82
+ 'Billing.OP_FREE_ACCESS_SHORT': { de: 'Freigeschaltet', de_informal: 'Freigeschaltet', en: 'Free access', fr: 'Accès gratuit', sw: 'Ufikiaji wa bure' },
83
+ 'Billing.OP_FREE_ACCESS_FOR': { de: 'Ohne Abo freigeschaltet – {{name}}', de_informal: 'Ohne Abo freigeschaltet – {{name}}', en: 'Free access without a subscription – {{name}}', fr: 'Accès sans abonnement – {{name}}', sw: 'Ufikiaji bila usajili – {{name}}' },
84
+ 'Billing.OP_TEAM': { de: 'Team', de_informal: 'Team', en: 'Team', fr: 'Équipe', sw: 'Timu' },
85
+ 'Billing.OP_OPERATOR': { de: 'Betreiber', de_informal: 'Betreiber', en: 'Operator', fr: 'Opérateur', sw: 'Mwendeshaji' },
86
+ 'Billing.OP_NO_SUBSCRIPTION': { de: 'Ohne Abo', de_informal: 'Ohne Abo', en: 'No subscription', fr: 'Sans abonnement', sw: 'Bila usajili' },
81
87
  'Billing.OP_TEAM_SEAT': { de: 'Team-Platz', de_informal: 'Team-Platz', en: 'Team seat', fr: 'Place d’équipe', sw: 'Nafasi ya timu' },
82
88
  'Billing.OP_FREE_ACCESS': { de: 'Ohne Abo freigeschaltet', de_informal: 'Ohne Abo freigeschaltet', en: 'Access enabled without a subscription', fr: 'Accès activé sans abonnement', sw: 'Ufikiaji umewezeshwa bila usajili' },
83
89
  'Billing.OP_READ_ONLY': { de: 'Schreibgeschützt', de_informal: 'Schreibgeschützt', en: 'Read-only', fr: 'Lecture seule', sw: 'Kusoma pekee' },
@@ -27,7 +27,12 @@ import { BulkInviteCsvTab } from '../components/BulkInviteCsvTab';
27
27
  import { fetchAuthPolicy, updateUserProfile } from '../auth/authApi'; // Ggf. Pfad anpassen
28
28
  import { defaultBillingApi } from '../billing/api';
29
29
  import { useBillingUsersColumn } from '../billing/useBillingUsersColumn';
30
- 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, }) {
30
+ /**
31
+ * `billingOperator({ user, account }) => boolean` (optional, UCM-BILL-10): the app's operator rule for the billing
32
+ * users columns built when `billingUsers` is set (status, badge and the "Ohne Abo" switch). Without it superusers are
33
+ * the operators. A new function on each render only recomputes the columns; it does not refetch the accounts.
34
+ */
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, }) {
31
36
  var _a;
32
37
  const { t, i18n } = useTranslation();
33
38
  const { user, login, loading } = useContext(AuthContext);
@@ -37,7 +42,7 @@ export function AccountPage({ userListExtraColumns = [], userListExtraRowActions
37
42
  const theme = useTheme();
38
43
  const isMobile = useMediaQuery(theme.breakpoints.down('md'));
39
44
  const billingApi = billingUsers && typeof billingUsers === 'object' ? billingUsers : defaultBillingApi;
40
- const billing = useBillingUsersColumn({ api: billingApi, enabled: Boolean(billingUsers) });
45
+ const billing = useBillingUsersColumn(Object.assign({ api: billingApi, enabled: Boolean(billingUsers) }, (billingOperator ? { isOperator: billingOperator } : {})));
41
46
  // 1. URL State Management
42
47
  const currentTabRaw = searchParams.get('tab') || 'profile';
43
48
  const currentTab = ['invite', 'bulk-invite-csv', 'access'].includes(currentTabRaw)
@@ -37,6 +37,7 @@ import { SETUP_WIZARD_CARD_SX } from '../onboarding/SetupWizardShell';
37
37
  import { REAUTH_MODAL_ALERT_SX, REAUTH_MODAL_TEXT_FIELD_SX } from '../auth/ReauthModal';
38
38
  import { createKitSxEntry } from './kitSxEntry';
39
39
  import { ACCESS_ENDED_BANNER_ALERT_SX } from '../billing/AccessEndedBanner';
40
+ import { BILLING_ACCESS_BADGE_SX } from '../billing/BillingAccessCell';
40
41
  import { TOKEN_BALANCE_BADGE_SX } from '../billing/TokenBalanceBadge';
41
42
  import { PLAN_PICKER_ALERT_SX, PLAN_PICKER_CARD_SX, PLAN_PICKER_LABEL_SX, PLAN_PICKER_SELECTED_CARD_SX } from '../billing/PlanPicker';
42
43
  import { SUBSCRIPTION_SECTION_ALERT_SX, SUBSCRIPTION_SECTION_SEAT_ADD_SX, SUBSCRIPTION_SECTION_SEAT_SELECT_SX } from '../billing/SubscriptionSection';
@@ -51,6 +52,7 @@ import { RECEIPT_REVIEW_ACTIONS_SX, RECEIPT_REVIEW_ACTION_BUTTON_SX, RECEIPT_REV
51
52
  const SX_EXPORTS = {
52
53
  ACCESS_CODE_ACTION_SX,
53
54
  ACCESS_ENDED_BANNER_ALERT_SX,
55
+ BILLING_ACCESS_BADGE_SX,
54
56
  FREE_ACCESS_SWITCH_ALERT_SX,
55
57
  OPERATOR_OVERVIEW_ALERT_SX,
56
58
  ACCESS_CODE_ALERT_SX,
@@ -251,6 +253,7 @@ export const KIT_COMPONENT_SX_REGISTRY = [
251
253
  entry('ReauthModal.alert', 'MuiAlert', REAUTH_MODAL_ALERT_SX),
252
254
  entry('ReauthModal.field', 'MuiTextField', REAUTH_MODAL_TEXT_FIELD_SX),
253
255
  entry('AccessEndedBanner.alert', 'MuiAlert', ACCESS_ENDED_BANNER_ALERT_SX),
256
+ entry('BillingAccessCell.badge', 'MuiChip', BILLING_ACCESS_BADGE_SX),
254
257
  entry('TokenBalanceBadge.root', 'MuiChip', TOKEN_BALANCE_BADGE_SX),
255
258
  entry('PlanPicker.card', 'MuiCard', PLAN_PICKER_CARD_SX),
256
259
  entry('PlanPicker.selectedCard', 'MuiCard', PLAN_PICKER_SELECTED_CARD_SX),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micha.bigler/ui-core-micha",
3
- "version": "4.16.0",
3
+ "version": "4.18.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "exports": {