Mailing Lists, Roles, and Domains got new/existing columns in prior commits but no way to sort them — the account-client-sort mechanism was only wired up in accountColumns.ts. Extracted its one-line clientSortable() column tagger into schemaDeviationTypes.ts (shared, same intersection-type pattern) and used it in all four column-patch files: - Mailing Lists: Email Address, Description, Aliases - Roles: Description, Enabled Permissions, Disabled Permissions - Domains: Domain Name, Enabled, Aliases Re-verified server sort support live, per list this time rather than just Accounts: every property tried returns unsupportedSort except one surprise — x:Domain/query actually accepts sort by "name", despite the schema not declaring it. Documented in SCHEMA_DEVIATIONS.md and deliberately routed through the same client-sort path as everything else instead of adding a one-off "trust an undeclared sort" mechanism for that single case. Verified in the running dev server: sort indicators appear on the intended columns for all three lists, clicking reorders rows correctly (alphabetical on Mailing Lists' Email Address, numeric on Roles' Enabled Permissions: 1 -> 3 -> 50 -> 229 -> 244 -> 452), Domains sorts without error. No regression on Accounts/Groups.
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2020 Stalwart Labs LLC <hello@stalw.art>
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-SEL
|
|
*/
|
|
|
|
import type { Schema } from '@/types/schema';
|
|
import { clientSortable } from './schemaDeviationTypes';
|
|
|
|
/**
|
|
* SCHEMA-DEVIATION: role-permission-count-columns (see SCHEMA_DEVIATIONS.md)
|
|
*
|
|
* The Roles list only shows Description, hiding how many permissions a
|
|
* role actually grants or explicitly revokes without opening it. Adds two
|
|
* synthetic columns — DynamicList's generic count-column handling
|
|
* resolves them from the real `enabledPermissions`/`disabledPermissions`
|
|
* set properties and renders their entry counts.
|
|
*
|
|
* SCHEMA-DEVIATION: account-client-sort (see SCHEMA_DEVIATIONS.md)
|
|
*
|
|
* Description and both permission-count columns are tagged
|
|
* `clientSortable` — same reasoning as Accounts/Groups: the server
|
|
* doesn't support sorting on any `x:Role` property either.
|
|
*/
|
|
export function withRoleListColumns(schema: Schema): Schema {
|
|
const list = schema.lists['x:Role'];
|
|
if (!list) return schema;
|
|
|
|
return {
|
|
...schema,
|
|
lists: {
|
|
...schema.lists,
|
|
'x:Role': {
|
|
...list,
|
|
columns: [
|
|
...list.columns.map((c) => (c.name === 'description' ? clientSortable(c) : c)),
|
|
clientSortable({ name: 'enabledPermissionCount', label: 'Enabled Permissions' }),
|
|
clientSortable({ name: 'disabledPermissionCount', label: 'Disabled Permissions' }),
|
|
],
|
|
},
|
|
},
|
|
};
|
|
}
|