diff --git a/SCHEMA_DEVIATIONS.md b/SCHEMA_DEVIATIONS.md index 4ba290f..0cf44fa 100644 --- a/SCHEMA_DEVIATIONS.md +++ b/SCHEMA_DEVIATIONS.md @@ -69,10 +69,10 @@ itself stays byte-for-byte alignable with upstream's version of the file. ### `account-alias-count-column` 🟡 -- **Where**: [`src/lib/accountColumns.ts`](src/lib/accountColumns.ts), rendering in [`src/components/lists/DynamicList.tsx`](src/components/lists/DynamicList.tsx) -- **What**: adds a synthetic `aliasCount` column to the `x:Account/User` and `x:Account/Group` lists — not a real schema property; `DynamicList` resolves it from the real `aliases` objectList property and renders its entry count. -- **Why**: neither list's schema exposes alias count as a column, only the full `aliases` list on the detail view. -- **Ideal fix**: the server's `x:Account/User` and `x:Account/Group` list schemas include a computed alias-count column natively; this column definition is deleted. +- **Where**: [`src/lib/accountColumns.ts`](src/lib/accountColumns.ts), [`src/lib/mailingListColumns.ts`](src/lib/mailingListColumns.ts), rendering in [`src/components/lists/DynamicList.tsx`](src/components/lists/DynamicList.tsx) +- **What**: adds a synthetic `aliasCount` column to the `x:Account/User`, `x:Account/Group`, and `x:MailingList` lists — not a real schema property; `DynamicList` resolves it from the real `aliases` objectList property and renders its entry count. +- **Why**: none of these lists' schemas expose alias count as a column, only the full `aliases` list on the detail view. +- **Ideal fix**: the server's list schemas include a computed alias-count column natively; these column definitions are deleted. ### `account-client-sort` 🟡 diff --git a/src/lib/mailingListColumns.ts b/src/lib/mailingListColumns.ts new file mode 100644 index 0000000..76f48ea --- /dev/null +++ b/src/lib/mailingListColumns.ts @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2020 Stalwart Labs LLC + * + * SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL + */ + +import type { Schema } from '@/types/schema'; + +/** + * SCHEMA-DEVIATION: account-alias-count-column (see SCHEMA_DEVIATIONS.md) + * + * The Mailing Lists list doesn't expose alias count as a column, only the + * full `aliases` objectList on the detail view. Adds the same synthetic + * `aliasCount` column already used on Accounts/Groups — DynamicList's + * generic count-column handling picks it up with no further wiring. + */ +export function withMailingListColumns(schema: Schema): Schema { + const list = schema.lists['x:MailingList']; + if (!list) return schema; + + return { + ...schema, + lists: { + ...schema.lists, + 'x:MailingList': { ...list, columns: [...list.columns, { name: 'aliasCount', label: 'Aliases' }] }, + }, + }; +} diff --git a/src/pages/AdminPanel.tsx b/src/pages/AdminPanel.tsx index 7af865e..6458bb4 100644 --- a/src/pages/AdminPanel.tsx +++ b/src/pages/AdminPanel.tsx @@ -14,6 +14,7 @@ import { useUIStore } from '@/stores/uiStore'; import { fetchSession, fetchSchema, fetchAccountInfo } from '@/services/jmap/client'; import { withClientLogFilters } from '@/lib/logFilters'; import { withAccountListColumns } from '@/lib/accountColumns'; +import { withMailingListColumns } from '@/lib/mailingListColumns'; import { setLocale } from '@/i18n'; import { TopBar } from '@/components/layout/TopBar'; import { Sidebar } from '@/components/layout/Sidebar'; @@ -150,7 +151,7 @@ export default function AdminPanel() { if (cancelled) return; - setSchema(withAccountListColumns(withClientLogFilters(schemaData))); + setSchema(withMailingListColumns(withAccountListColumns(withClientLogFilters(schemaData)))); setAccountInfo(accountData.permissions, accountData.edition, accountData.locale); setLocale(accountData.locale);