mirror of
https://github.com/fleetdm/fleet
synced 2026-05-15 04:58:25 +00:00
* Allow sort by more than one key * created custom tooltip component * remove unused code * fixed style for more layouts * added tooltip to query side panel * tooltips added to setting form * finished settings form * added tooltip for perf impact table headers * tooltip for pack table and user form * tooltip on manage policies page * tooltip for manage schedules * tooltip for automations; spacing for form input * tooltip for automations modal * user form; fixed input with icon component * more user form tooltips * tooltip for homepage; style fixes * replaced many more tooltips with new version * added story for tooltip * added position prop * fixed tests * re-work how we click react-select dropdowns * forcing the update button click * trying a blur * fixed typo * trying blur on another element * temp check-in * replaced tooltip from host details software * more consolidation of tooltip use for software * fixed settings flow test Co-authored-by: Tomas Touceda <chiiph@gmail.com>
160 lines
4.8 KiB
TypeScript
160 lines
4.8 KiB
TypeScript
import React from "react";
|
|
import classnames from "classnames";
|
|
|
|
import { IOsqueryTable } from "interfaces/osquery_table"; // @ts-ignore
|
|
import { osqueryTableNames } from "utilities/osquery_tables"; // @ts-ignore
|
|
import Dropdown from "components/forms/fields/Dropdown"; // @ts-ignore
|
|
import FleetIcon from "components/icons/FleetIcon";
|
|
import TooltipWrapper from "components/TooltipWrapper"; // @ts-ignore
|
|
import SecondarySidePanelContainer from "../SecondarySidePanelContainer";
|
|
import AppleIcon from "../../../../assets/images/icon-apple-dark-20x20@2x.png";
|
|
import LinuxIcon from "../../../../assets/images/icon-linux-dark-20x20@2x.png";
|
|
import WindowsIcon from "../../../../assets/images/icon-windows-dark-20x20@2x.png";
|
|
import CloseIcon from "../../../../assets/images/icon-close-black-50-8x8@2x.png";
|
|
|
|
interface IQuerySidePanel {
|
|
selectedOsqueryTable: IOsqueryTable;
|
|
onOsqueryTableSelect: (tableName: string) => void;
|
|
onClose?: () => void;
|
|
}
|
|
|
|
const baseClass = "query-side-panel";
|
|
|
|
const QuerySidePanel = ({
|
|
selectedOsqueryTable,
|
|
onOsqueryTableSelect,
|
|
onClose,
|
|
}: IQuerySidePanel): JSX.Element => {
|
|
const displayTypeForDataType = (dataType: string) => {
|
|
switch (dataType) {
|
|
case "TEXT_TYPE":
|
|
return "text";
|
|
case "BIGINT_TYPE":
|
|
return "big int";
|
|
case "INTEGER_TYPE":
|
|
return "integer";
|
|
default:
|
|
return dataType;
|
|
}
|
|
};
|
|
|
|
const onSelectTable = (value: string) => {
|
|
onOsqueryTableSelect(value);
|
|
};
|
|
|
|
const renderColumns = () => {
|
|
const columns = selectedOsqueryTable?.columns;
|
|
const columnBaseClass = "query-column-list";
|
|
|
|
return columns?.map((column) => (
|
|
<li key={column.name} className={`${columnBaseClass}__item`}>
|
|
<span className={`${columnBaseClass}__name`}>
|
|
<TooltipWrapper tipContent={column.description}>
|
|
{column.name}
|
|
</TooltipWrapper>
|
|
</span>
|
|
<div className={`${columnBaseClass}__description`}>
|
|
<span className={`${columnBaseClass}__type`}>
|
|
{displayTypeForDataType(column.type)}
|
|
</span>
|
|
</div>
|
|
</li>
|
|
));
|
|
};
|
|
|
|
const renderTableSelect = () => {
|
|
const tableNames = osqueryTableNames?.map((name: string) => {
|
|
return { label: name, value: name };
|
|
});
|
|
|
|
if (!tableNames) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Dropdown
|
|
options={tableNames}
|
|
value={selectedOsqueryTable?.name}
|
|
onChange={onSelectTable}
|
|
placeholder="Choose Table..."
|
|
/>
|
|
);
|
|
};
|
|
|
|
const { description, platforms } = selectedOsqueryTable || {};
|
|
const iconClasses = classnames([`${baseClass}__icon`], "icon");
|
|
return (
|
|
<SecondarySidePanelContainer className={baseClass}>
|
|
<div
|
|
role="button"
|
|
className={`${baseClass}__close-button`}
|
|
tabIndex={0}
|
|
onClick={onClose}
|
|
>
|
|
<img alt="Close sidebar" src={CloseIcon} />
|
|
</div>
|
|
<div className={`${baseClass}__choose-table`}>
|
|
<h2 className={`${baseClass}__header`}>Tables</h2>
|
|
{renderTableSelect()}
|
|
<p className={`${baseClass}__description`}>{description}</p>
|
|
</div>
|
|
<div className={`${baseClass}__os-availability`}>
|
|
<h2 className={`${baseClass}__header`}>OS Availability</h2>
|
|
<ul className={`${baseClass}__platforms`}>
|
|
{platforms?.map((platform) => {
|
|
if (platform === "all") {
|
|
return (
|
|
<li key={platform}>
|
|
<FleetIcon name="hosts" /> {platform}
|
|
</li>
|
|
);
|
|
} else if (platform === "freebsd") {
|
|
return (
|
|
<li key={platform}>
|
|
<FleetIcon name="single-host" /> {platform}
|
|
</li>
|
|
);
|
|
}
|
|
platform = platform.toLowerCase();
|
|
let icon = (
|
|
<img
|
|
src={AppleIcon}
|
|
alt={`${platform} icon`}
|
|
className={iconClasses}
|
|
/>
|
|
);
|
|
if (platform === "linux") {
|
|
icon = (
|
|
<img
|
|
src={LinuxIcon}
|
|
alt={`${platform} icon`}
|
|
className={iconClasses}
|
|
/>
|
|
);
|
|
} else if (platform === "windows") {
|
|
icon = (
|
|
<img
|
|
src={WindowsIcon}
|
|
alt={`${platform} icon`}
|
|
className={iconClasses}
|
|
/>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<li key={platform}>
|
|
{icon} {platform}
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
</div>
|
|
<div className={`${baseClass}__columns`}>
|
|
<h2 className={`${baseClass}__header`}>Columns</h2>
|
|
<ul className={`${baseClass}__column-list`}>{renderColumns()}</ul>
|
|
</div>
|
|
</SecondarySidePanelContainer>
|
|
);
|
|
};
|
|
|
|
export default QuerySidePanel;
|