fix(ui): remove starting underscore from the metada which were added to avoid coflicting with existing filter keys (#2320)

This commit is contained in:
Shekar Siri 2024-06-27 19:39:08 +02:00 committed by GitHub
parent 405b11380e
commit 644ef31425
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -146,12 +146,21 @@ function FilterAutoComplete(props: Props) {
}, [value])
const loadOptions = (inputValue: string, callback: (options: []) => void) => {
// remove underscore from params
const _params: Record<string, string> = {}
const keys = Object.keys(params);
keys.forEach((key) => {
_params[key.replace('_', '')] = params[key];
})
const _params = Object.keys(params).reduce((acc: any, key: string) => {
// all metadata keys start with underscore to avoid conflicts with predefined filter keys
// they should be removed before sending to the server
if (key === 'type' && params[key] === 'metadata') {
acc['key'] = params['key'].replace(/^_/, '');
acc['type'] = 'metadata';
}
return acc;
}, {});
// const _params: Record<string, string> = {}
// const keys = Object.keys(params);
// keys.forEach((key) => {
// _params[key.replace('_', '')] = params[key];
// })
new APIClient()
[method?.toLocaleLowerCase()](endpoint, { ..._params, q: inputValue })