diff --git a/plugins/quay/src/components/QuayRepository/QuayRepository.tsx b/plugins/quay/src/components/QuayRepository/QuayRepository.tsx index 4c91cc4d2e..0cc36e522c 100644 --- a/plugins/quay/src/components/QuayRepository/QuayRepository.tsx +++ b/plugins/quay/src/components/QuayRepository/QuayRepository.tsx @@ -38,7 +38,7 @@ export function QuayRepository(_props: QuayRepositoryProps) {
[] = [ { title: 'Tag', field: 'name', @@ -23,7 +23,7 @@ export const columns: TableColumn[] = [ { title: 'Security Scan', field: 'securityScan', - render: (rowData: any): React.ReactNode => { + render: (rowData: QuayTagData): React.ReactNode => { if (!rowData.securityStatus && !rowData.securityDetails) { return ( @@ -43,15 +43,17 @@ export const columns: TableColumn[] = [ } const tagManifest = rowData.manifest_digest_raw; - const retStr = vulnerabilitySummary(rowData.securityDetails as Layer); + const retStr = vulnerabilitySummary(rowData.securityDetails); return {retStr}; }, id: 'securityScan', + sorting: false, }, { title: 'Size', field: 'size', type: 'numeric', + customSort: (a: QuayTagData, b: QuayTagData) => a.rawSize - b.rawSize, }, { title: 'Expires', @@ -63,6 +65,8 @@ export const columns: TableColumn[] = [ title: 'Manifest', field: 'manifest_digest', type: 'string', + customSort: (a: QuayTagData, b: QuayTagData) => + a.manifest_digest_raw.localeCompare(b.manifest_digest_raw), }, ]; diff --git a/plugins/quay/src/components/QuayTagDetails/component.tsx b/plugins/quay/src/components/QuayTagDetails/component.tsx index a178bed8d3..b51ce0fb39 100644 --- a/plugins/quay/src/components/QuayTagDetails/component.tsx +++ b/plugins/quay/src/components/QuayTagDetails/component.tsx @@ -25,38 +25,44 @@ type QuayTagDetailsProps = { // from: https://github.com/quay/quay/blob/f1d85588157eababc3cbf789002c5db521dbd616/web/src/routes/TagDetails/SecurityReport/SecurityReportTable.tsx#L43 const getVulnerabilityLink = (link: string) => link.split(' ')[0]; -const columns: TableColumn[] = [ +const columns: TableColumn[] = [ { title: 'Advisory', field: 'name', - render: (rowData: any): React.ReactNode => { - const row = rowData as Vulnerability; + render: (rowData: VulnerabilityListItem): React.ReactNode => { return (
- {row.Name} - {row.Link.trim().length > 0 ? ( - + {rowData.Name} + {rowData.Link.trim().length > 0 ? ( + ) : null}
); }, + customSort: (a: VulnerabilityListItem, b: VulnerabilityListItem) => + a.Name.localeCompare(b.Name, 'en'), }, { title: 'Severity', field: 'Severity', - render: (rowData: any): React.ReactNode => { - const row = rowData as Vulnerability; + customSort: (a: VulnerabilityListItem, b: VulnerabilityListItem) => { + const severityA = VulnerabilityOrder[a.Severity]; + const severityB = VulnerabilityOrder[b.Severity]; + + return severityA - severityB; + }, + render: (rowData: VulnerabilityListItem): React.ReactNode => { return (
- {row.Severity} + {rowData.Severity}
); }, @@ -74,14 +80,11 @@ const columns: TableColumn[] = [ { title: 'Fixed By', field: 'FixedBy', - render: (rowData: any): React.ReactNode => { - const row = rowData as VulnerabilityListItem; + render: (rowData: VulnerabilityListItem): React.ReactNode => { return ( <> - {row.FixedBy.length > 0 ? ( - <> - {row.FixedBy} - + {rowData.FixedBy.length > 0 ? ( + {rowData.FixedBy} ) : ( '(None)' )} diff --git a/plugins/quay/src/hooks/quay.tsx b/plugins/quay/src/hooks/quay.tsx index 3f48c60d70..733fb217d0 100644 --- a/plugins/quay/src/hooks/quay.tsx +++ b/plugins/quay/src/hooks/quay.tsx @@ -10,7 +10,7 @@ import { Box, Chip, makeStyles } from '@material-ui/core'; import { formatByteSize, formatDate } from '@janus-idp/shared-react'; import { quayApiRef } from '../api'; -import { Layer, Tag } from '../types'; +import { Layer, QuayTagData, Tag } from '../types'; const useLocalStyles = makeStyles({ chip: { @@ -68,7 +68,7 @@ export const useTags = (organization: string, repository: string) => { return tagsResponse; }); - const data = useMemo(() => { + const data: QuayTagData[] = useMemo(() => { return Object.values(tags)?.map(tag => { const hashFunc = tag.manifest_digest.substring(0, 6); const shortHash = tag.manifest_digest.substring(7, 19); @@ -77,6 +77,7 @@ export const useTags = (organization: string, repository: string) => { name: tag.name, last_modified: formatDate(tag.last_modified), size: formatByteSize(tag.size), + rawSize: tag.size, manifest_digest: ( diff --git a/plugins/quay/src/types.ts b/plugins/quay/src/types.ts index e95768372b..1a7d237b0a 100644 --- a/plugins/quay/src/types.ts +++ b/plugins/quay/src/types.ts @@ -20,7 +20,18 @@ export interface Tag { export interface LabelsResponse { labels: Label[]; } - +export interface QuayTagData { + id: string; + name: string; + last_modified: string; + size: string; + rawSize: number; + manifest_digest: React.JSX.Element; + expiration?: string; + securityDetails: Layer; + securityStatus: string; + manifest_digest_raw: string; +} export interface Label { id: string; key: string;