mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-11-02 11:39:12 +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 classNames from 'classnames';
|
||||||
import { cloneDeep, lowerCase, upperCase } from 'lodash';
|
import { cloneDeep, isUndefined, lowerCase, upperCase } from 'lodash';
|
||||||
import { EntityTags } from 'Models';
|
import { EntityTags } from 'Models';
|
||||||
import React, { Fragment, useEffect, useState } from 'react';
|
import React, { Fragment, useEffect, useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
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(() => {
|
useEffect(() => {
|
||||||
if (!searchText) {
|
if (!searchText) {
|
||||||
setSearchedColumns(tableColumns);
|
setSearchedColumns(tableColumns);
|
||||||
} else {
|
} else {
|
||||||
const searchCols = tableColumns.filter((column) => {
|
const searchCols = searchInColumns(tableColumns, searchText);
|
||||||
return (
|
|
||||||
lowerCase(column.name).includes(searchText) ||
|
|
||||||
lowerCase(column.description).includes(searchText) ||
|
|
||||||
lowerCase(getDataTypeString(column.dataType)).includes(searchText)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
setSearchedColumns(searchCols);
|
setSearchedColumns(searchCols);
|
||||||
}
|
}
|
||||||
}, [searchText, tableColumns]);
|
}, [searchText, tableColumns]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user