Skip to content

Commit 0cb7cd1

Browse files
xingzhang-suselsongsuse
authored andcommitted
Fixed style issues for designer review, utilized fetching secondary resource and pagination, resolved github issue #148: Feat: Column base filters on Registries overview page out of table
1 parent 3e4e27a commit 0cb7cd1

File tree

11 files changed

+555
-198
lines changed

11 files changed

+555
-198
lines changed

pkg/sbombastic-image-vulnerability-scanner/components/RecentUpdatedRegistries.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div class="chart-section">
33
<div class="title">
44
{{ t('imageScanner.registries.recentUpdatedRegistries.title') }}
5+
<i class="icon icon-question-mark"></i>
56
</div>
67
<div class="status-list">
78
<RegistryStatusUpdate v-for="registryStatus in registryStatusList" :registryStatus="registryStatus" />
@@ -37,12 +38,16 @@
3738
flex: 1 0 0;
3839
border-right: 1px solid #DCDEE7;
3940
.title {
41+
display: flex;
42+
align-items: center;
43+
gap: 8px;
4044
color: #141419;
4145
font-family: Lato;
4246
font-size: 18px;
4347
font-style: normal;
4448
font-weight: 400;
4549
line-height: 21px; /* 116.667% */
50+
margin-right: 8px;
4651
}
4752
.status-list {
4853
padding: 4px 8px;

pkg/sbombastic-image-vulnerability-scanner/components/StatusDistribution.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div class="chart-section">
33
<div class="title">
44
{{ t('imageScanner.registries.StatusDistribution.title') }}
5+
<i class="icon icon-question-mark"></i>
56
</div>
67
<div class="severity-bar-chart">
78
<BarChart :filterFn="filterFn" :chartData="chartData" colorPrefix="status" :description="t('imageScanner.registries.StatusDistribution.subTitle')" />
@@ -40,6 +41,9 @@
4041
gap: 12px;
4142
flex: 1 0 0;
4243
.title {
44+
display: flex;
45+
align-items: center;
46+
gap: 8px;
4347
color: #141419;
4448
font-family: Lato;
4549
font-size: 18px;

pkg/sbombastic-image-vulnerability-scanner/components/common/ScanButton.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<button
3-
class="btn role-primary"
3+
class="btn role-primary scan-btn"
44
:disabled="disableBtn"
55
@click="startScan()"
66
>
@@ -72,3 +72,11 @@ export default {
7272
},
7373
}
7474
</script>
75+
76+
<style scoped>
77+
.scan-btn {
78+
display: flex;
79+
align-items: center;
80+
gap: 12px;
81+
}
82+
</style>

pkg/sbombastic-image-vulnerability-scanner/config/table-headers.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,55 @@ export const REGISTRY_SCAN_TABLE = [
33
name: "registry",
44
labelKey: "imageScanner.registries.registrytable.header.registry",
55
value: "metadata.name",
6-
sort: "registry",
6+
sort: "metadata.name",
77
formatter: "RegistryNameCell",
88
},
99
{
1010
name: "namespace",
1111
labelKey: "imageScanner.registries.registrytable.header.namespace",
1212
value: "metadata.namespace",
13-
sort: "namespace",
13+
sort: "metadata.namespace",
1414
},
1515
{
1616
name: "uri",
1717
labelKey: "imageScanner.registries.registrytable.header.uri",
1818
value: "spec.uri",
19-
sort: "uri",
19+
sort: "spec.uri",
2020
},
2121
{
2222
name: "repositories",
2323
labelKey: "imageScanner.registries.registrytable.header.repos",
2424
value: "spec.repositories",
25-
sort: "repositories",
25+
sort: "spec.repositories",
2626
},
2727
{
2828
name: "scanInterval",
2929
labelKey: "imageScanner.registries.registrytable.header.schedule",
3030
value: (row: any) => `Every ${row.spec.scanInterval}`,
31-
sort: "scanInterval",
31+
sort: "spec.scanInterval",
3232
},
3333
{
3434
name: "status",
3535
labelKey: "imageScanner.registries.registrytable.header.status",
36-
value: "currStatus",
36+
value: "scanRec.currStatus",
3737
formatter: "RegistryStatusCellBadge",
38-
sort: "status",
38+
sort: "scanRec.currStatus",
3939
width: 100,
4040
},
4141
{
4242
name: "progress",
4343
labelKey: "imageScanner.registries.registrytable.header.progress",
44-
getValue: (row: any) => row,
44+
value: "scanRec.progress",
4545
formatter: "ProgressCell",
46-
sort: "progress",
46+
sort: "scanRec.progress",
4747
width: 120,
4848
},
4949
{
5050
name: "previousScan",
5151
labelKey: "imageScanner.registries.registrytable.header.prevScan",
52-
getValue: (row: any) => row,
52+
value: "scanRec.previousScan",
5353
formatter: "PreviousScanCell",
54-
sort: "previousScan",
54+
sort: "scanRec.previousScan",
5555
width: 200,
5656
},
5757
];

pkg/sbombastic-image-vulnerability-scanner/formatters/PreviousScanCell.vue

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script>
22
import ProgressCell from "@pkg/formatters/ProgressCell";
33
import TextWithPopedDetail from "@pkg/components/common/TextWithPopedDetail";
4+
import _ from 'lodash';
45
export default {
56
components: {
67
ProgressCell,
@@ -9,40 +10,40 @@ export default {
910
name: "PreviousScanCell",
1011
props: {
1112
value: {
12-
type: String,
13+
type: Object,
1314
required: true
1415
},
1516
row: {
1617
type: Object,
1718
required: true
1819
}
1920
},
20-
methods: {
21-
getStatusText(row) {
22-
return row.prevScanStatus ? this.t(`imageScanner.enum.status.${row.prevScanStatus.toLowerCase()}`) : "";
21+
computed: {
22+
getStatusText() {
23+
return this.value.prevScanStatus ? this.t(`imageScanner.enum.status.${this.value.prevScanStatus.toLowerCase()}`) : "";
2324
},
24-
getStatusLabelClass(row) {
25-
return row.prevScanStatus? row.prevScanStatus.toLowerCase() : "";
25+
getStatusLabelClass() {
26+
return this.value.prevScanStatus ? this.value.prevScanStatus.toLowerCase() : "";
2627
},
27-
getStatusDotClass(row) {
28-
return row.prevScanStatus? `dot ${row.prevScanStatus.toLowerCase()}` : "";
28+
getStatusDotClass() {
29+
return this.value.prevScanStatus ? `dot ${this.value.prevScanStatus.toLowerCase()}` : "";
2930
}
3031
}
3132
};
3233
</script>
3334

3435
<template>
3536
<div class="previous-scan-cell">
36-
<div :class="getStatusDotClass(row)"></div>
37-
<div class="status" :class="getStatusLabelClass(row)">{{ getStatusText(row) }}</div>
38-
<div v-if="row.prevProgress">
39-
<span>{{ t("imageScanner.general.at") }}</span><ProgressCell style="display: inline-block;" :row="{ metadata: { name: row.metadata.name }, progress: row.prevProgress, progressDetail: row.prevProgressDetail, error: null}" />
37+
<div :class="getStatusDotClass"></div>
38+
<div class="status" :class="getStatusLabelClass">{{ getStatusText }}</div>
39+
<div v-if="value.prevProgress">
40+
<span>{{ t("imageScanner.general.at") }}</span><ProgressCell style="display: inline-block;" :value="{ metadata: { name: row.metadata.name }, progress: value.prevProgress, progressDetail: value.prevProgressDetail, error: null}" />
4041
</div>
41-
<div v-if="row.prevScanStatus?.toLowerCase() === 'failed' && row.PrevError">
42+
<div v-if="value.prevScanStatus?.toLowerCase() === 'failed' && value.prevError">
4243
<span>|
4344
<TextWithPopedDetail
4445
:value="t('imageScanner.general.error')"
45-
:detail="{ title: `${row.metadata.name} - ${t('imageScanner.registries.configuration.scanTable.header.error')}`, message: row.PrevError, type: 'error' }"
46+
:detail="{ title: `${row.metadata.name} - ${t('imageScanner.registries.configuration.scanTable.header.error')}`, message: value.prevError, type: 'error' }"
4647
/>
4748
</span>
4849
</div>

pkg/sbombastic-image-vulnerability-scanner/formatters/Progress.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default {
1717
<template>
1818
<div class="progress-cell">
1919
<span v-if="progress" class="progress-text">{{ progress }}%</span>
20-
<span v-else class="progress-text text-muted">n/a</span>
20+
<span v-else class="progress-text text-muted none">n/a</span>
2121
</div>
2222
</template>
2323
<style lang="scss" scoped>
@@ -29,6 +29,9 @@ export default {
2929
3030
.progress-text {
3131
margin-left: 8px;
32+
&.none {
33+
margin-left: 12px;
34+
}
3235
}
3336
}
3437
</style>

pkg/sbombastic-image-vulnerability-scanner/formatters/ProgressCell.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
import TextWithPopedDetail from '@pkg/components/common/TextWithPopedDetail';
33
export default {
44
props: {
5+
value: {
6+
type: Object,
7+
required: true
8+
},
59
row: {
610
type: Object,
711
required: true
@@ -15,19 +19,19 @@ export default {
1519
</script>
1620
<template>
1721
<div class="progress-cell">
18-
<span v-if="row.progress">
22+
<span v-if="value.progress">
1923
<TextWithPopedDetail
20-
:value="`${row.progress}%`"
21-
:detail="{ title: `${row.metadata.name} - ${row.progress}%`, message: row.progressDetail, type: 'info' }"
24+
:value="`${value.progress}%`"
25+
:detail="{ title: `${value.metadata?.name || value.registryName} - ${value.progress}%`, message: value.progressDetail, type: 'info' }"
2226
/>
23-
<span v-if="row.error">|
27+
<span v-if="value.error">|
2428
<TextWithPopedDetail
2529
:value="t('imageScanner.general.error')"
26-
:detail="{title: `${row.metadata.name} - ${t('imageScanner.registries.configuration.scanTable.header.error')}`, message: row.error, type: 'error' }"
30+
:detail="{title: `${value.metadata?.name} - ${t('imageScanner.registries.configuration.scanTable.header.error')}`, message: value.error, type: 'error' }"
2731
/>
2832
</span>
2933
</span>
30-
<span v-else class="progress-text text-muted">n/a</span>
34+
<span v-else class="progress-text text-muted none">n/a</span>
3135
</div>
3236
</template>
3337
<style lang="scss" scoped>
@@ -36,5 +40,11 @@ export default {
3640
align-items: center;
3741
font-size: 14px;
3842
color: var(--text-secondary);
43+
.progress-text {
44+
margin-left: 8px;
45+
&.none {
46+
margin-left: 12px;
47+
}
48+
}
3949
}
4050
</style>

pkg/sbombastic-image-vulnerability-scanner/l10n/en-us.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ imageScanner:
5252
title: Status distribution
5353
subTitle: registry scans
5454
registrytable:
55+
filters:
56+
placeholder:
57+
name: Search by name
58+
address: Search by address
5559
header:
5660
scan: Scan
5761
registry: Registry
@@ -281,6 +285,7 @@ imageScanner:
281285
at: at
282286
schedule: Every {i}
283287
reload: Reload
288+
any: Any
284289

285290
typeLabel:
286291
sbombastic.rancher.io.registry: Registries configuration
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<template>
2+
3+
<PaginatedResourceTable
4+
ref="registryTable"
5+
:headers="headers"
6+
:schema="schema"
7+
:namespaced="false"
8+
:table-actions="true"
9+
:row-actions="true"
10+
:fetchSecondaryResources="fetchSecondaryResources"
11+
:fetchPageSecondaryResources="fetchPageSecondaryResources"
12+
13+
:use-query-params-for-simple-filtering="useQueryParamsForSimpleFiltering"
14+
:overflow-x="overflowX"
15+
:overflow-y="overflowY"
16+
@selection="onSelectionChange"
17+
>
18+
</PaginatedResourceTable>
19+
</template>
20+
21+
<script>
22+
23+
import { RESOURCE } from "@pkg/types";
24+
import PaginatedResourceTable from '@shell/components/PaginatedResourceTable';
25+
import SortableTable from '@shell/components/SortableTable';
26+
import { REGISTRY_SCAN_TABLE } from "@pkg/config/table-headers";
27+
import { FilterArgs, PaginationFilterField, PaginationParamFilter } from '@shell/types/store/pagination.types';
28+
29+
export default {
30+
name: 'registries',
31+
components: {
32+
PaginatedResourceTable,
33+
SortableTable,
34+
},
35+
data() {
36+
return {
37+
headers: REGISTRY_SCAN_TABLE,
38+
}
39+
},
40+
beforeUnmount() {
41+
clearInterval(this.keepAliveTimer);
42+
},
43+
methods: {
44+
async fetchSecondaryResources({ canPaginate }) {
45+
if (canPaginate) {
46+
return;
47+
}
48+
console.log("fetchSecondaryResources");
49+
return await this.$store.dispatch(`cluster/findAll`, { type: RESOURCE.SCAN_JOB });
50+
},
51+
52+
/**
53+
* PV columns need other resources in order to show data in some columns
54+
*
55+
* So when we have a page.... use those entries as filters when fetching the other resources
56+
*/
57+
async fetchPageSecondaryResources({ canPaginate, force, page }) {
58+
if (!page?.length) {
59+
return;
60+
}
61+
62+
const opt = {
63+
force,
64+
pagination: new FilterArgs({
65+
filters: PaginationParamFilter.createMultipleFields(page.map((r) => new PaginationFilterField({
66+
field: 'id',
67+
value: `${r.metadata.namespace}/${r.metadata.name}`
68+
}))),
69+
})
70+
};
71+
const scanJobs = await this.$store.dispatch(`cluster/findAll`, { type: RESOURCE.SCAN_JOB, opt });
72+
console.log("fetchSecondaryResources", scanJobs);
73+
return scanJobs;
74+
},
75+
},
76+
}
77+
78+
</script>

0 commit comments

Comments
 (0)