Skip to content

Commit

Permalink
[OPIK-839] [FE] Remove not leaves nodes(subtrees) from the autocomple…
Browse files Browse the repository at this point in the history
…te component in the rules popup (#1099)
  • Loading branch information
andriidudar authored Jan 21, 2025
1 parent 8a665a7 commit f230645
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,19 @@ const TracesPathsAutocomplete: React.FC<TracesPathsAutocompleteProps> = ({

const items = useMemo(() => {
return uniq(
(data?.content || []).reduce<string[]>(
(acc, d) => {
return acc.concat(
rootKeys.reduce<string[]>(
(internalAcc, key) =>
internalAcc.concat(
isObject(d[key]) || isArray(d[key])
? getJSONPaths(d[key], key)
: [],
),
[],
),
);
},
[...rootKeys],
),
(data?.content || []).reduce<string[]>((acc, d) => {
return acc.concat(
rootKeys.reduce<string[]>(
(internalAcc, key) =>
internalAcc.concat(
isObject(d[key]) || isArray(d[key])
? getJSONPaths(d[key], key)
: [],
),
[],
),
);
}, []),
)
.filter((p) =>
value ? p.toLowerCase().includes(value.toLowerCase()) : true,
Expand Down
2 changes: 0 additions & 2 deletions apps/opik-frontend/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ export const getJSONPaths = (
: key;

if (isArray(value)) {
results.push(path);
getJSONPaths(value, path, results);
} else if (isObject(value)) {
results.push(path);
getJSONPaths(value, path, results);
} else {
results.push(path);
Expand Down

0 comments on commit f230645

Please # to comment.