mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
## Addresses #16942 - Disable header on empty table - make vertical margin even - also addresses same issue on Software version details tables <img width="1912" alt="Screenshot 2024-02-19 at 1 56 34 PM" src="https://github.com/fleetdm/fleet/assets/61553566/8605a7a8-5538-407e-94ba-6e3ee33aefa5"> - [x] Changes file added for user-visible changes in `changes/` - [x] Manual QA for all new/changed functionality --------- Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
80 lines
2.2 KiB
TypeScript
80 lines
2.2 KiB
TypeScript
import React, { useContext, useMemo } from "react";
|
|
import classnames from "classnames";
|
|
|
|
import { AppContext } from "context/app";
|
|
import { ISoftwareVulnerability } from "interfaces/software";
|
|
import { GITHUB_NEW_ISSUE_LINK } from "utilities/constants";
|
|
|
|
import TableContainer from "components/TableContainer";
|
|
import EmptyTable from "components/EmptyTable";
|
|
import CustomLink from "components/CustomLink";
|
|
|
|
import generateTableConfig from "./SoftwareVulnerabilitiesTableConfig";
|
|
|
|
const baseClass = "software-vulnerabilities-table";
|
|
|
|
interface INoVulnsDetectedProps {
|
|
itemName: string;
|
|
}
|
|
|
|
const NoVulnsDetected = ({ itemName }: INoVulnsDetectedProps): JSX.Element => {
|
|
return (
|
|
<EmptyTable
|
|
header={`No vulnerabilities detected for this ${itemName}`}
|
|
info={
|
|
<>
|
|
Expecting to see vulnerabilities?{" "}
|
|
<CustomLink
|
|
url={GITHUB_NEW_ISSUE_LINK}
|
|
text="File an issue on GitHub"
|
|
newTab
|
|
/>
|
|
</>
|
|
}
|
|
/>
|
|
);
|
|
};
|
|
|
|
interface ISoftwareVulnerabilitiesTableProps {
|
|
data: ISoftwareVulnerability[];
|
|
/** Name displayed on the empty state */
|
|
itemName: string;
|
|
isLoading: boolean;
|
|
className?: string;
|
|
}
|
|
|
|
const SoftwareVulnerabilitiesTable = ({
|
|
data,
|
|
itemName,
|
|
isLoading,
|
|
className,
|
|
}: ISoftwareVulnerabilitiesTableProps) => {
|
|
const { isPremiumTier, isSandboxMode } = useContext(AppContext);
|
|
|
|
const classNames = classnames(baseClass, className);
|
|
|
|
const tableHeaders = useMemo(
|
|
() => generateTableConfig(Boolean(isPremiumTier), Boolean(isSandboxMode)),
|
|
[isPremiumTier, isSandboxMode]
|
|
);
|
|
return (
|
|
<div className={classNames}>
|
|
<TableContainer
|
|
columnConfigs={tableHeaders}
|
|
data={data}
|
|
defaultSortHeader={isPremiumTier ? "epss_probability" : "cve"}
|
|
defaultSortDirection="desc"
|
|
emptyComponent={() => <NoVulnsDetected itemName={itemName} />}
|
|
isAllPagesSelected={false}
|
|
isLoading={isLoading}
|
|
isClientSidePagination
|
|
pageSize={20}
|
|
resultsTitle="vulnerabilities"
|
|
showMarkAllPages={false}
|
|
disableTableHeader={data.length === 0}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default SoftwareVulnerabilitiesTable;
|