Skip to content

Commit

Permalink
fix: column keys
Browse files Browse the repository at this point in the history
  • Loading branch information
kahboom committed Oct 7, 2024
1 parent c474dc1 commit 8a3aabf
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 47 deletions.
34 changes: 17 additions & 17 deletions client/src/app/pages/advisory-details/vulnerabilities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ export const Vulnerabilities: React.FC<VulnerabilitiesProps> = ({
const tableControls = useLocalTableControls({
variant: variant,
tableName: "vulnerability-table",
idProperty: "name",
idProperty: "identifier",
items: vulnerabilities,
columnNames: {
name: "Name",
description: "Description",
cvss: "CVSS",
identifier: "Name",
title: "Description",
severity: "CVSS",
discovered: "Discovered",
released: "Released",
cwe: "CWE",
},
hasActionsColumn: false,
isSortEnabled: true,
sortableColumns: ["name", "discovered", "released"],
sortableColumns: ["identifier", "discovered", "released"],
getSortValues: (vuln) => ({
name: vuln?.name || "",
identifier: vuln?.identifier || "",
discovered: vuln.discovered ? dayjs(vuln.discovered).valueOf() : 0,
released: vuln.released ? dayjs(vuln.released).valueOf() : 0,
}),
Expand All @@ -67,7 +67,7 @@ export const Vulnerabilities: React.FC<VulnerabilitiesProps> = ({
title: "ID",
type: FilterType.search,
placeholderText: "Search by ID...",
getItemValue: (item) => item.name || "",
getItemValue: (item) => item.identifier || "",
},
],
});
Expand Down Expand Up @@ -108,9 +108,9 @@ export const Vulnerabilities: React.FC<VulnerabilitiesProps> = ({
<Thead>
<Tr>
<TableHeaderContentWithControls {...tableControls}>
<Th {...getThProps({ columnKey: "name" })} />
<Th {...getThProps({ columnKey: "description" })} />
<Th {...getThProps({ columnKey: "cvss" })} />
<Th {...getThProps({ columnKey: "identifier" })} />
<Th {...getThProps({ columnKey: "title" })} />
<Th {...getThProps({ columnKey: "severity" })} />
<Th {...getThProps({ columnKey: "discovered" })} />
<Th {...getThProps({ columnKey: "released" })} />
<Th {...getThProps({ columnKey: "cwe" })} />
Expand All @@ -125,27 +125,27 @@ export const Vulnerabilities: React.FC<VulnerabilitiesProps> = ({
>
{currentPageItems?.map((item, rowIndex) => {
return (
<Tbody key={item.name}>
<Tbody key={item.identifier}>
<Tr {...getTrProps({ item })}>
<TableRowContentWithControls
{...tableControls}
item={item}
rowIndex={rowIndex}
>
<Td width={15} {...getTdProps({ columnKey: "name" })}>
<NavLink to={`/vulnerabilities/${item.name}`}>
{item.name}
<Td width={15} {...getTdProps({ columnKey: "identifier" })}>
<NavLink to={`/vulnerabilities/${item.identifier}`}>
{item.identifier}
</NavLink>
</Td>
<Td
width={40}
modifier="truncate"
{...getTdProps({ columnKey: "description" })}
{...getTdProps({ columnKey: "title" })}
>
{item.title || item.description}
</Td>
<Td width={15} {...getTdProps({ columnKey: "cvss" })}>
<SeverityShieldAndText value={item.cvss} />
<Td width={15} {...getTdProps({ columnKey: "severity" })}>
<SeverityShieldAndText value={item.severity} />
</Td>
<Td width={10} {...getTdProps({ columnKey: "discovered" })}>
{formatDate(item.discovered)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ export const AdvisoriesByVulnerability: React.FC<
items: advisories,
isLoading: false,
columnNames: {
name: "Name",
description: "Description",
cvss: "CVSS",
identifier: "Name",
title: "Description",
severity: "CVSS",
published: "Published",
modified: "Modified",
},
Expand Down Expand Up @@ -108,9 +108,9 @@ export const AdvisoriesByVulnerability: React.FC<
<Thead>
<Tr>
<TableHeaderContentWithControls {...tableControls}>
<Th {...getThProps({ columnKey: "name" })} />
<Th {...getThProps({ columnKey: "description" })} />
<Th {...getThProps({ columnKey: "cvss" })} />
<Th {...getThProps({ columnKey: "identifier" })} />
<Th {...getThProps({ columnKey: "title" })} />
<Th {...getThProps({ columnKey: "severity" })} />
<Th {...getThProps({ columnKey: "published" })} />
<Th {...getThProps({ columnKey: "modified" })} />
</TableHeaderContentWithControls>
Expand All @@ -125,29 +125,31 @@ export const AdvisoriesByVulnerability: React.FC<
<Tbody>
{currentPageItems?.map((item) => {
return (
<Tr key={item.name} {...getTrProps({ item })}>
<Td width={15} {...getTdProps({ columnKey: "name" })}>
<Tr key={item.identifier} {...getTrProps({ item })}>
<Td width={15} {...getTdProps({ columnKey: "identifier" })}>
<Button
size="sm"
variant={ButtonVariant.secondary}
onClick={() => showDrawer("showAdvisory", item)}
>
{item.name}
{item.identifier}
</Button>
</Td>
<Td
width={50}
modifier="truncate"
{...getTdProps({ columnKey: "description" })}
{...getTdProps({ columnKey: "title" })}
>
{item.description}
{item.title}
</Td>
<Td
width={10}
modifier="truncate"
{...getTdProps({ columnKey: "cvss" })}
{...getTdProps({ columnKey: "severity" })}
>
{item.cvss && <SeverityShieldAndText value={item.cvss} />}
{item.severity && (
<SeverityShieldAndText value={item.severity} />
)}
</Td>
<Td
width={10}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { useFetchVulnerabilities } from "@app/queries/vulnerabilities";
interface IVulnerabilitySearchContext {
tableControls: ITableControls<
VulnerabilitySummary,
"packages" | "name" | "description" | "cvss" | "sboms" | "vulnerabilities",
"packages" | "identifier" | "title" | "severity" | "sboms" | "advisories",
never,
"" | "average_severity",
string
Expand All @@ -44,12 +44,12 @@ export const VulnerabilitySearchProvider: React.FunctionComponent<
tableName: "vulnerability",
persistenceKeyPrefix: TablePersistenceKeyPrefixes.vulnerabilities,
columnNames: {
name: "Name",
description: "Description",
cvss: "CVSS",
identifier: "Name",
title: "Description",
severity: "CVSS",
packages: "Packages",
sboms: "SBOMs",
vulnerabilities: "Vulnerabilities",
advisories: "Vulnerabilities",
},
isPaginationEnabled: true,
isSortEnabled: true,
Expand Down Expand Up @@ -88,15 +88,15 @@ export const VulnerabilitySearchProvider: React.FunctionComponent<
getHubRequestParams({
...tableControlState,
hubSortFieldKeys: {
name: "name",
identifier: "identifier",
severity: "average_score",
},
})
);

const tableControls = useTableControlProps({
...tableControlState,
idProperty: "name",
idProperty: "identifier",
currentPageItems: vulnerabilities,
totalItemCount,
isLoading: isFetching,
Expand Down
20 changes: 10 additions & 10 deletions client/src/app/pages/vulnerability-list/vulnerability-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ export const VulnerabilityTable: React.FC = () => {
<Thead>
<Tr>
<TableHeaderContentWithControls {...tableControls}>
<Th {...getThProps({ columnKey: "name" })} />
<Th {...getThProps({ columnKey: "description" })} />
<Th {...getThProps({ columnKey: "cvss" })} />
<Th {...getThProps({ columnKey: "identifier" })} />
<Th {...getThProps({ columnKey: "title" })} />
<Th {...getThProps({ columnKey: "severity" })} />
<Th {...getThProps({ columnKey: "packages" })} />
<Th {...getThProps({ columnKey: "sboms" })} />
<Th {...getThProps({ columnKey: "vulnerabilities" })} />
<Th {...getThProps({ columnKey: "advisories" })} />
</TableHeaderContentWithControls>
</Tr>
</Thead>
Expand All @@ -118,7 +118,7 @@ export const VulnerabilityTable: React.FC = () => {
<Td
width={15}
{...getTdProps({
columnKey: "name",
columnKey: "identifier",
isCompoundExpandToggle: true,
item: item,
rowIndex,
Expand All @@ -131,11 +131,11 @@ export const VulnerabilityTable: React.FC = () => {
<Td
width={45}
modifier="truncate"
{...getTdProps({ columnKey: "description" })}
{...getTdProps({ columnKey: "title" })}
>
{item.title || item.description}
</Td>
<Td width={10} {...getTdProps({ columnKey: "cvss" })}>
<Td width={10} {...getTdProps({ columnKey: "severity" })}>
{item.average_severity && (
<SeverityShieldAndText value={item.average_severity} />
)}
Expand Down Expand Up @@ -167,7 +167,7 @@ export const VulnerabilityTable: React.FC = () => {
<Td
width={10}
{...getTdProps({
columnKey: "vulnerabilities",
columnKey: "advisories",
isCompoundExpandToggle: true,
item: item,
rowIndex,
Expand Down Expand Up @@ -199,7 +199,7 @@ export const VulnerabilityTable: React.FC = () => {
>
<ExpandableRowContent>
<div className="pf-v5-u-m-md">
{isCellExpanded(item, "name") ? (
{isCellExpanded(item, "identifier") ? (
<>
<Grid hasGutter>
<GridItem md={8}>
Expand Down Expand Up @@ -289,7 +289,7 @@ export const VulnerabilityTable: React.FC = () => {
/>
</>
) : null}
{isCellExpanded(item, "vulnerabilities") ? (
{isCellExpanded(item, "advisories") ? (
<>
<AdvisoriesByVulnerability
variant="compact"
Expand Down

0 comments on commit 8a3aabf

Please sign in to comment.