TableContainer additions: simpleSearch utility and IconCell (#1404)
* Create simpleSearch and IconCell
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import React from "react";
|
||||
|
||||
// @ts-ignore
|
||||
import FleetIcon from "components/icons/FleetIcon";
|
||||
|
||||
interface IIconTooltipCellProps<T> {
|
||||
value: string;
|
||||
}
|
||||
|
||||
const IconTooltipCell = (
|
||||
props: IIconTooltipCellProps<any>
|
||||
): JSX.Element | null => {
|
||||
const { value } = props;
|
||||
|
||||
// The value passed in must be a valid FleetIcon name
|
||||
return <FleetIcon name={value} />;
|
||||
};
|
||||
|
||||
export default IconTooltipCell;
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "./IconCell";
|
||||
@@ -6,7 +6,7 @@ import classnames from "classnames";
|
||||
import { Link } from "react-router";
|
||||
import ReactTooltip from "react-tooltip";
|
||||
import { isEmpty, noop, pick, reduce, filter, includes } from "lodash";
|
||||
|
||||
import simpleSearch from "utilities/simple_search";
|
||||
import Spinner from "components/loaders/Spinner";
|
||||
import Button from "components/buttons/Button";
|
||||
import Modal from "components/modals/Modal";
|
||||
@@ -208,19 +208,7 @@ export class HostDetailsPage extends Component {
|
||||
return;
|
||||
}
|
||||
|
||||
const lowerSearchQuery = searchQuery.toLowerCase();
|
||||
|
||||
const filteredSoftware = filter(host.software, (softwareItem) => {
|
||||
if (!softwareItem.name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const lowerSoftwareName = softwareItem.name.toLowerCase();
|
||||
|
||||
return includes(lowerSoftwareName, lowerSearchQuery);
|
||||
});
|
||||
|
||||
this.setState({ softwareState: filteredSoftware });
|
||||
this.setState({ softwareState: simpleSearch(searchQuery, host.software) });
|
||||
};
|
||||
|
||||
clearHostUpdates() {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
export { default } from "./simple_search";
|
||||
@@ -0,0 +1,19 @@
|
||||
import { filter, includes } from "lodash";
|
||||
|
||||
const simpleSearch = (searchQuery = "", dictionary) => {
|
||||
const lowerSearchQuery = searchQuery.toLowerCase();
|
||||
|
||||
const filterResults = filter(dictionary, (item) => {
|
||||
if (!item.name) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const lowerItemName = item.name.toLowerCase();
|
||||
|
||||
return includes(lowerItemName, lowerSearchQuery);
|
||||
});
|
||||
|
||||
return filterResults;
|
||||
};
|
||||
|
||||
export default simpleSearch;
|
||||
Reference in New Issue
Block a user