feat: add client-side Level/Event filters to Log Entries
The backend rejects `level`/`event` as x:Log/query filter conditions (unsupportedFilter), even though both are already returned per row. Since a real fix requires backend changes outside this repo, the two filters are injected into the schema client-side (clientOnly flag) and applied entirely in the browser: excluded from the JMAP filter sent to the server, and used to narrow an eagerly-fetched, locally-paginated result set instead. Also makes large enum filters (Event has 634 values) render as a searchable Combobox instead of a plain Select, generically for any list with more than 15 enum options. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
da2c99990f
commit
21b183327c
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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';
|
||||
|
||||
/**
|
||||
* The Stalwart JMAP backend rejects `level`/`event` as filter conditions on
|
||||
* `x:Log/query` (`unsupportedFilter`), even though both properties are
|
||||
* already returned per row. Until the backend adds real support, these two
|
||||
* filters are appended client-side and applied entirely in the browser
|
||||
* (see the `clientOnly` flag consumed by DynamicList) instead of being sent
|
||||
* to the server.
|
||||
*/
|
||||
export function withClientLogFilters(schema: Schema): Schema {
|
||||
const logList = schema.lists['x:Log'];
|
||||
if (!logList || !schema.enums['TracingLevel'] || !schema.enums['EventType']) return schema;
|
||||
|
||||
return {
|
||||
...schema,
|
||||
lists: {
|
||||
...schema.lists,
|
||||
'x:Log': {
|
||||
...logList,
|
||||
filters: [
|
||||
...(logList.filters ?? []),
|
||||
{ type: 'enum', field: 'level', enumName: 'TracingLevel', label: 'Level', clientOnly: true },
|
||||
{ type: 'enum', field: 'event', enumName: 'EventType', label: 'Event', clientOnly: true },
|
||||
],
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user