|
15 | 15 | </span>
|
16 | 16 | </div>
|
17 | 17 | <div class="resource-header-actions">
|
18 |
| - <button class="btn role-secondary"> |
| 18 | + <button |
| 19 | + class="btn role-secondary" |
| 20 | + aria-label="Refresh data" |
| 21 | + type="button" |
| 22 | + @click="loadData(true)"> |
19 | 23 | <i class="icon icon-refresh"></i>
|
20 | 24 | {{ t('imageScanner.general.refresh') }}
|
21 | 25 | </button>
|
22 |
| - <button class="btn role-primary"> |
23 |
| - <i class="icon icon-play"></i> |
24 |
| - {{ t('imageScanner.registries.configuration.scan') }} |
25 |
| - </button> |
| 26 | + <ScanButton :selectedRegistries="[{name: $route.params.id, namespace: $route.params.ns}]" :reloadFn="loadData" /> |
26 | 27 | </div>
|
27 | 28 | </div>
|
28 | 29 | <RancherMeta :properties="registryMetadata" />
|
29 | 30 | </div>
|
30 |
| - <RegistryDetailScanTable :registry="registry" /> |
| 31 | + <RegistryDetailScanTable :scanHistory="scanHistory" /> |
31 | 32 | </div>
|
32 | 33 | </template>
|
33 | 34 |
|
|
37 | 38 | import ResourceTable from "@shell/components/ResourceTable";
|
38 | 39 | import RancherMeta from './common/RancherMeta.vue';
|
39 | 40 | import RegisterStatusBadge from './common/RegisterStatusBadge.vue';
|
40 |
| - import { REGISTRY_SCAN_HISTORY_TABLE } from '@sbombastic-image-vulnerability-scanner/config/table-headers'; |
41 | 41 | import RegistryDetailScanTable from './RegistryDetailScanTable.vue';
|
| 42 | + import ScanButton from './common/ScanButton.vue'; |
42 | 43 |
|
43 | 44 | export default {
|
44 | 45 | name: 'registryDetails',
|
|
47 | 48 | ResourceTable,
|
48 | 49 | RancherMeta,
|
49 | 50 | RegisterStatusBadge,
|
50 |
| - RegistryDetailScanTable |
| 51 | + RegistryDetailScanTable, |
| 52 | + ScanButton |
51 | 53 | },
|
52 | 54 | data() {
|
53 | 55 | return {
|
54 | 56 | PRODUCT_NAME,
|
55 | 57 | RESOURCE,
|
56 | 58 | PAGE,
|
57 |
| - registry: null, |
58 | 59 | registryStatus: null,
|
59 | 60 | registryMetadata: [],
|
| 61 | + scanHistory: [], |
60 | 62 | }
|
61 | 63 | },
|
62 | 64 | async fetch() {
|
63 |
| -
|
64 |
| - await this.$store.dispatch('cluster/find', { type: RESOURCE.REGISTRY, id: `${this.$route.params.ns}/${this.$route.params.id}` }); |
65 |
| - let registry = this.$store.getters['cluster/byId'](RESOURCE.REGISTRY, `${this.$route.params.ns}/${this.$route.params.id}`); |
66 |
| -
|
67 |
| -
|
68 |
| - await this.$store.dispatch('cluster/findAll', { type: RESOURCE.SCAN_JOB }); |
69 |
| - let scanJobs = this.$store.getters['cluster/all'](RESOURCE.SCAN_JOB); |
70 |
| -
|
71 |
| - // filter scan jobs for the current registry |
72 |
| - scanJobs = scanJobs.filter((job) => { |
73 |
| - return job.spec.registry === registry.metadata.name; |
74 |
| - }); |
75 |
| -
|
76 |
| - this.registryStatus = this.getRegistryStatus(registry); |
77 |
| - this.registryMetadata = [ |
78 |
| - { |
79 |
| - type: 'text', |
80 |
| - label: this.t('imageScanner.registries.configuration.meta.registry'), |
81 |
| - value: registry.spec.uri |
82 |
| - }, |
83 |
| - { |
84 |
| - type: 'text', |
85 |
| - label: this.t('imageScanner.registries.configuration.meta.repositories'), |
86 |
| - value: registry.spec.repositories?.length || 0 |
87 |
| - }, |
88 |
| - { |
89 |
| - type: 'text', |
90 |
| - label: this.t('imageScanner.registries.configuration.meta.schedule') |
91 |
| - }, |
92 |
| - { |
93 |
| - type: 'text', |
94 |
| - label: this.t('imageScanner.registries.configuration.meta.namespace'), |
95 |
| - value: registry.metadata.namespace |
96 |
| - }, |
97 |
| - { |
98 |
| - type: 'tags', |
99 |
| - tags: registry.spec.repositories || [] |
100 |
| - }, |
101 |
| - { |
102 |
| - type: 'text', |
103 |
| - value: registry.metadata.schedule || '', |
104 |
| - } |
105 |
| - ]; |
106 |
| -
|
107 |
| - this.registry = registry; |
| 65 | + await this.loadData(); |
108 | 66 | },
|
109 | 67 | methods: {
|
| 68 | + async loadData(isForceLoading = false) { |
| 69 | + await this.$store.dispatch('cluster/find', { type: RESOURCE.REGISTRY, id: `${this.$route.params.ns}/${this.$route.params.id}`, opt: {force: isForceLoading} }); |
| 70 | + if (this.$store.getters['cluster/canList'](RESOURCE.SCAN_JOB)) { |
| 71 | + await this.$store.dispatch('cluster/findAll', { type: RESOURCE.SCAN_JOB, opt: {force: isForceLoading} }); |
| 72 | + } |
| 73 | +
|
| 74 | + let registry = this.$store.getters['cluster/byId'](RESOURCE.REGISTRY, `${this.$route.params.ns}/${this.$route.params.id}`); |
| 75 | + let scanJobs = this.$store.getters['cluster/all'](RESOURCE.SCAN_JOB).filter((rec) => { |
| 76 | + return rec.spec.registry === registry.metadata.name; |
| 77 | + }); |
| 78 | +
|
| 79 | + this.registryStatus = this.getRegistryStatus(registry); |
| 80 | + this.registryMetadata = [ |
| 81 | + { |
| 82 | + type: 'text', |
| 83 | + label: this.t('imageScanner.registries.configuration.meta.registry'), |
| 84 | + value: registry.spec.uri |
| 85 | + }, |
| 86 | + { |
| 87 | + type: 'text', |
| 88 | + label: this.t('imageScanner.registries.configuration.meta.repositories'), |
| 89 | + value: registry.spec.repositories?.length || 0 |
| 90 | + }, |
| 91 | + { |
| 92 | + type: 'text', |
| 93 | + label: this.t('imageScanner.registries.configuration.meta.schedule') |
| 94 | + }, |
| 95 | + { |
| 96 | + type: 'text', |
| 97 | + label: this.t('imageScanner.registries.configuration.meta.namespace'), |
| 98 | + value: registry.metadata.namespace |
| 99 | + }, |
| 100 | + { |
| 101 | + type: 'tags', |
| 102 | + tags: registry.spec.repositories || [] |
| 103 | + }, |
| 104 | + { |
| 105 | + type: 'text', |
| 106 | + value: registry.metadata.schedule || '', |
| 107 | + } |
| 108 | + ]; |
| 109 | +
|
| 110 | + this.scanHistory = scanJobs.map((rec) => { |
| 111 | + rec.status.statusResult = rec.status.conditions.filter(condition => { |
| 112 | + return condition.status === "True"; |
| 113 | + })[0] || { |
| 114 | + type: "Pending", |
| 115 | + lastTransitionTime: null, |
| 116 | + }; |
| 117 | + return rec; |
| 118 | + }); |
| 119 | + }, |
110 | 120 | getRegistryStatus(registry) {
|
111 | 121 | if (!registry || !registry.status || !registry.status.conditions || !registry.status.conditions.length) {
|
112 | 122 | return null;
|
|
0 commit comments