mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-01 11:09:14 +00:00
Improvement:- given 3 level deep search support for search in table option in dataset detail (#1185)
This commit is contained in:
parent
43ceb4b1f7
commit
f7c98835f4
@ -16,7 +16,7 @@
|
||||
*/
|
||||
|
||||
import classNames from 'classnames';
|
||||
import { cloneDeep, lowerCase, upperCase } from 'lodash';
|
||||
import { cloneDeep, isUndefined, lowerCase, upperCase } from 'lodash';
|
||||
import { EntityTags } from 'Models';
|
||||
import React, { Fragment, useEffect, useState } from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
@ -371,17 +371,41 @@ const EntityTable = ({
|
||||
);
|
||||
};
|
||||
|
||||
const searchInColumns = (table: Column[], searchText: string): Column[] => {
|
||||
const searchedValue: Column[] = table.reduce((searchedCols, column) => {
|
||||
const isContainData =
|
||||
lowerCase(column.name).includes(searchText) ||
|
||||
lowerCase(column.description).includes(searchText) ||
|
||||
lowerCase(getDataTypeString(column.dataType)).includes(searchText);
|
||||
|
||||
if (isContainData) {
|
||||
return [...searchedCols, column];
|
||||
} else if (!isUndefined(column.children)) {
|
||||
const searchedChildren = searchInColumns(column.children, searchText);
|
||||
if (searchedChildren.length > 0) {
|
||||
toggleAllRowsExpanded(true);
|
||||
|
||||
return [
|
||||
...searchedCols,
|
||||
{
|
||||
...column,
|
||||
children: searchedChildren,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return searchedCols;
|
||||
}, [] as Column[]);
|
||||
|
||||
return searchedValue;
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (!searchText) {
|
||||
setSearchedColumns(tableColumns);
|
||||
} else {
|
||||
const searchCols = tableColumns.filter((column) => {
|
||||
return (
|
||||
lowerCase(column.name).includes(searchText) ||
|
||||
lowerCase(column.description).includes(searchText) ||
|
||||
lowerCase(getDataTypeString(column.dataType)).includes(searchText)
|
||||
);
|
||||
});
|
||||
const searchCols = searchInColumns(tableColumns, searchText);
|
||||
setSearchedColumns(searchCols);
|
||||
}
|
||||
}, [searchText, tableColumns]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user