Handle unexpected filter formats better in system-filter ui (#10251)

Fixes #9573
This commit is contained in:
Rijk van Zanten
2021-12-02 19:42:39 -05:00
committed by GitHub
parent a77f08b3d3
commit 6e866487d7

View File

@@ -1,13 +1,16 @@
import { get } from 'lodash';
import { get, isPlainObject } from 'lodash';
import { Filter } from '@directus/shared/types';
export function getNodeName(node: Filter): string {
if (!node) return '';
return Object.keys(node)[0];
}
export function getField(node: Record<string, any>): string {
const name = getNodeName(node);
if (name.startsWith('_')) return '';
if (!isPlainObject(node[name])) return '';
const subFields = getField(node[name]);
return subFields !== '' ? `${name}.${subFields}` : name;
}