Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package List - V1 Parity #174

Merged
merged 3 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions client/src/app/components/SbomsByPackageCount.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";

import { useFetchSbomsByPackageId } from "@app/queries/sboms";

export interface ISbomsByPackageCountProps {
packageId: string;
}

export const SbomsByPackageCount: React.FC<ISbomsByPackageCountProps> = ({
packageId,
}) => {
const {
result: { total },
} = useFetchSbomsByPackageId(packageId, {
page: { pageNumber: 1, itemsPerPage: 1 },
});

return <>{total}</>;
};
10 changes: 5 additions & 5 deletions client/src/app/pages/package-list/package-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface PackageTableData extends PurlSummary {
interface IPackageSearchContext {
tableControls: ITableControls<
PackageTableData,
"name" | "namespace" | "version" | "type" | "qualifiers",
"name" | "version" | "type" | "vulnerabilities" | "sboms",
never,
"" | "type",
string
Expand Down Expand Up @@ -51,10 +51,10 @@ export const PackageSearchProvider: React.FunctionComponent<
persistenceKeyPrefix: TablePersistenceKeyPrefixes.packages,
columnNames: {
name: "Name",
namespace: "Namespace",
version: "Version",
type: "Type",
qualifiers: "Qualifiers",
vulnerabilities: "Vulnerabilities",
sboms: "SBOMs",
},
isPaginationEnabled: true,
isSortEnabled: true,
Expand All @@ -79,8 +79,7 @@ export const PackageSearchProvider: React.FunctionComponent<
],
},
],
isExpansionEnabled: true,
expandableVariant: "single",
isExpansionEnabled: false,
});

const {
Expand All @@ -90,6 +89,7 @@ export const PackageSearchProvider: React.FunctionComponent<
} = useFetchPackages(
getHubRequestParams({
...tableControlState,
hubSortFieldKeys: {},
})
);

Expand Down
69 changes: 12 additions & 57 deletions client/src/app/pages/package-list/package-table.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,9 @@
import React from "react";
import { NavLink } from "react-router-dom";

import {
DescriptionList,
DescriptionListDescription,
DescriptionListGroup,
DescriptionListTerm,
} from "@patternfly/react-core";
import {
ExpandableRowContent,
Table,
Tbody,
Td,
Th,
Thead,
Tr,
} from "@patternfly/react-table";
import { Table, Tbody, Td, Th, Thead, Tr } from "@patternfly/react-table";

import { PackageQualifiers } from "@app/components/PackageQualifiers";
import { SbomsByPackageCount } from "@app/components/SbomsByPackageCount";
import { SimplePagination } from "@app/components/SimplePagination";
import {
ConditionalTableBody,
Expand Down Expand Up @@ -51,10 +37,10 @@ export const PackageTable: React.FC = () => {
<Tr>
<TableHeaderContentWithControls {...tableControls}>
<Th {...getThProps({ columnKey: "name" })} />
<Th {...getThProps({ columnKey: "namespace" })} />
<Th {...getThProps({ columnKey: "version" })} />
<Th {...getThProps({ columnKey: "type" })} />
<Th {...getThProps({ columnKey: "qualifiers" })} />
<Th {...getThProps({ columnKey: "vulnerabilities" })} />
<Th {...getThProps({ columnKey: "sboms" })} />
</TableHeaderContentWithControls>
</Tr>
</Thead>
Expand All @@ -73,7 +59,7 @@ export const PackageTable: React.FC = () => {
item={item}
rowIndex={rowIndex}
>
<Td width={25} {...getTdProps({ columnKey: "name" })}>
<Td width={40} {...getTdProps({ columnKey: "name" })}>
<NavLink
to={`/packages/${encodeURIComponent(item.uuid)}`}
>
Expand All @@ -83,14 +69,7 @@ export const PackageTable: React.FC = () => {
</NavLink>
</Td>
<Td
width={10}
modifier="truncate"
{...getTdProps({ columnKey: "namespace" })}
>
{item.decomposedPurl?.namespace}
</Td>
<Td
width={15}
width={20}
modifier="truncate"
{...getTdProps({ columnKey: "version" })}
>
Expand All @@ -103,39 +82,15 @@ export const PackageTable: React.FC = () => {
>
{item.decomposedPurl?.type}
</Td>
<Td width={40} {...getTdProps({ columnKey: "qualifiers" })}>
{item.decomposedPurl?.qualifiers && (
<PackageQualifiers
value={item.decomposedPurl?.qualifiers}
/>
)}
<Td
width={15}
{...getTdProps({ columnKey: "vulnerabilities" })}
></Td>
<Td width={15} {...getTdProps({ columnKey: "sboms" })}>
<SbomsByPackageCount packageId={item.uuid} />
</Td>
</TableRowContentWithControls>
</Tr>
{isCellExpanded(item) ? (
<Tr isExpanded>
<Td colSpan={7}>
<ExpandableRowContent>
<div className="pf-v5-u-m-md">
<DescriptionList>
<DescriptionListGroup>
<DescriptionListTerm>Purl</DescriptionListTerm>
<DescriptionListDescription>
{item.purl}
</DescriptionListDescription>
</DescriptionListGroup>
<DescriptionListGroup>
<DescriptionListTerm>Path</DescriptionListTerm>
<DescriptionListDescription>
{item.decomposedPurl?.path}
</DescriptionListDescription>
</DescriptionListGroup>
</DescriptionList>
</div>
</ExpandableRowContent>
</Td>
</Tr>
) : null}
</Tbody>
);
})}
Expand Down
Loading