Skip to content

Commit 65f932e

Browse files
NickChungSUSExingzhang-suse
authored andcommitted
fix: Fix errors, vex overview layout, and customize action label
1 parent fc0de55 commit 65f932e

File tree

7 files changed

+63
-200
lines changed

7 files changed

+63
-200
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,19 @@ export function init($plugin: any, store: any) {
6868
},
6969
});
7070

71+
virtualType({
72+
labelKey: "imageScanner.vexManagement.title",
73+
name: PAGE.VEX_MANAGEMENT,
74+
namespaced: false,
75+
route: {
76+
name: `c-cluster-${PRODUCT_NAME}-${PAGE.VEX_MANAGEMENT}`,
77+
params: {
78+
product: PRODUCT_NAME,
79+
},
80+
meta: { pkg: PRODUCT_NAME, product: PRODUCT_NAME },
81+
},
82+
});
83+
7184
virtualType({
7285
label: "Components Demo",
7386
name: "demo",
@@ -84,13 +97,14 @@ export function init($plugin: any, store: any) {
8497
weightType(PAGE.DASHBOARD, 98, true);
8598
weightType(PAGE.IMAGE_OVERVIEW, 97, true);
8699
weightType(PAGE.VULNERABILITY_OVERVIEW, 96, true);
100+
weightType(PAGE.VEX_MANAGEMENT, 95, true);
87101

88102
basicType([
89103
PAGE.DASHBOARD,
90104
PAGE.IMAGE_OVERVIEW,
91105
PAGE.VULNERABILITY_OVERVIEW,
92106
]);
93107
// Prepend spaces on group name, as Rancher 2.12 render group name algin with sidemenu
94-
basicType([PAGE.REGISTRIES, PAGE.VEX_MANAGEMENT, RESOURCE.VEX_HUB], '    Advanced');
108+
basicType([PAGE.REGISTRIES, PAGE.VEX_MANAGEMENT], '    Advanced');
95109

96110
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ imageScanner:
205205
enable: Enable
206206
disable: Disable
207207
delete: Delete
208+
editConfiguration: Edit configuration
208209
actions:
209210
clone: Clone
210211
editConfig: Edit configuration
Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
<template>
22
<div>
3-
4-
<Banner color="info">
5-
{{t('imageScanner.vexManagement.description')}}
6-
</Banner>
7-
83
<ResourceTable
94
ref="rt"
105
:schema="schema"
@@ -23,7 +18,6 @@
2318
<script>
2419
import { RESOURCE } from "@pkg/types";
2520
import ResourceTable from "@shell/components/ResourceTable";
26-
import Banner from '@components/Banner/Banner.vue';
2721
import RegisterStatusBadge from "@pkg/components/common/RegisterStatusBadge";
2822
import { VEX_MANAGEMENT_TABLE } from "@pkg/config/table-headers";
2923
import {
@@ -33,7 +27,6 @@ import {
3327
export default {
3428
name: 'VexManagement',
3529
components: {
36-
Banner,
3730
ResourceTable,
3831
RegisterStatusBadge,
3932
},
@@ -63,123 +56,15 @@ export default {
6356
await m.save();
6457
}));
6558
await this.$fetch();
66-
},
67-
createVexHub() {
68-
this.$router.push({
69-
name: `${ PRODUCT_NAME }-c-cluster-resource-create`,
70-
params: {
71-
resource: RESOURCE.VEX_HUB,
72-
cluster: this.$route.params.cluster,
73-
product: PRODUCT_NAME
74-
}
75-
});
7659
}
7760
},
7861
computed: {
7962
schema() {
8063
return this.$store.getters['cluster/schemaFor']?.(RESOURCE.VEX_HUB);
81-
},
82-
showMasthead(){
83-
const showMasthead = getters[`type-map/optionsFor`](this.resource).showListMasthead;
84-
console.log("=====showMasthead", showMasthead, this.resource);
85-
return false;
8664
}
8765
}
8866
}
8967
</script>
9068
9169
<style lang="scss" scoped>
92-
93-
.header-section {
94-
display: flex;
95-
align-items: flex-start;
96-
gap: 24px;
97-
align-self: stretch;
98-
margin-bottom: 24px;
99-
100-
.header-left {
101-
display: flex;
102-
flex-direction: column;
103-
justify-content: center;
104-
align-items: flex-start;
105-
gap: 8px;
106-
flex: 1 0 0;
107-
}
108-
109-
.title-wrap {
110-
display: flex;
111-
align-items: center;
112-
gap: 12px;
113-
align-self: stretch;
114-
115-
.title {
116-
color: #141419;
117-
font-family: Lato;
118-
font-size: 24px;
119-
font-style: normal;
120-
font-weight: 600;
121-
line-height: 32px;
122-
}
123-
}
124-
125-
.description {
126-
max-width: 900px;
127-
align-self: stretch;
128-
color: #717179;
129-
font-family: Lato;
130-
font-size: 14px;
131-
font-style: normal;
132-
font-weight: 400;
133-
line-height: 21px;
134-
}
135-
136-
.header-right {
137-
display: flex;
138-
align-items: flex-end;
139-
justify-content: end;
140-
flex: 1 0 0;
141-
gap: 24px;
142-
}
143-
144-
.header-btn {
145-
height: 40px;
146-
}
147-
}
148-
149-
// Status cell centering
150-
.status-cell {
151-
display: flex;
152-
align-items: center;
153-
justify-content: flex-start;
154-
height: 100%;
155-
min-height: 48px;
156-
padding: 8px 0;
157-
158-
:deep(.badge) {
159-
margin: 0;
160-
vertical-align: middle;
161-
}
162-
}
163-
164-
.uri-link .icon-external-link {
165-
margin-left: 6px;
166-
opacity: 0.7;
167-
}
168-
169-
/* Bulk header action buttons - align icons and text */
170-
.bulk-actions {
171-
display: flex;
172-
align-items: center;
173-
gap: 12px;
174-
}
175-
176-
.bulk-actions .btn {
177-
display: inline-flex;
178-
align-items: center;
179-
}
180-
181-
.bulk-actions .btn i {
182-
margin-right: 6px;
183-
line-height: 1;
184-
}
18570
</style>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

pkg/sbombastic-image-vulnerability-scanner/models/sbombastic.rancher.io.vexhub.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ export default class SbombasticRancherIoVexhub extends SteveModel {
1919
]);
2020
out = out.filter((a) => !a?.action || !remove.has(a.action));
2121

22+
// Customize the edit action label
23+
out = out.map((action) => {
24+
// Check for various possible edit action names
25+
if (action?.action === 'edit' || action?.action === 'goToEdit' || action?.action === 'editConfig') {
26+
return {
27+
...action,
28+
label: this.t('imageScanner.vexManagement.buttons.editConfiguration') || 'Edit configuration'
29+
};
30+
}
31+
32+
return action;
33+
});
34+
2235
const isEnabled = !!this.spec?.enabled;
2336
const toggle = this.toggle;
2437

pkg/sbombastic-image-vulnerability-scanner/pages/c/_cluster/sbombastic-image-vulnerability-scanner/VexManagement.vue

Lines changed: 12 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -21,67 +21,32 @@
2121
</div>
2222
</div>
2323

24-
<ResourceTable
25-
ref="rt"
26-
:schema="schema"
27-
:rows="rows"
28-
:namespaced="false"
29-
:headers="headers"
30-
:key-field="'id'"
31-
:table-actions="true"
32-
:use-query-params-for-simple-filtering="true"
33-
:force-update-live-and-delayed="forceUpdateKey"
34-
>
35-
</ResourceTable>
24+
<VexHubList />
3625
</div>
3726
</template>
3827

3928
<script>
4029
import { RESOURCE } from "@pkg/types";
41-
import ResourceTable from "@shell/components/ResourceTable";
42-
import RegisterStatusBadge from "@pkg/components/common/RegisterStatusBadge";
43-
import { VEX_MANAGEMENT_TABLE } from "@pkg/config/table-headers";
30+
import VexHubList from "@pkg/list/sbombastic.rancher.io.vexhub.vue";
4431
import {
4532
PRODUCT_NAME,
4633
} from "@pkg/types";
4734
4835
export default {
4936
name: 'VexManagement',
5037
components: {
51-
ResourceTable,
52-
RegisterStatusBadge,
53-
},
54-
data() {
55-
return {
56-
PRODUCT_NAME: PRODUCT_NAME,
57-
headers: VEX_MANAGEMENT_TABLE,
58-
disabled: false,
59-
selectedRows: [],
60-
filterText: '',
61-
rows: [],
62-
forceUpdateKey: 0
63-
}
64-
},
65-
async fetch() {
66-
await this.$store.dispatch('cluster/findAll', { type: RESOURCE.VEX_HUB });
67-
const vexhubsCRD = this.$store.getters['cluster/all']?.(RESOURCE.VEX_HUB);
68-
this.rows = vexhubsCRD || [];
38+
VexHubList,
6939
},
7040
methods: {
71-
rowWithActions(r) { return r; },
72-
async switchStatus(desired, selected) {
73-
const resources = selected && selected.length ? selected : (this.selectedRows || []);
74-
if (!resources.length) return;
75-
await Promise.all(resources.map(async (m) => {
76-
m.spec = { ...(m.spec || {}), enabled: desired };
77-
await m.save();
78-
}));
79-
await this.$fetch();
80-
}
81-
},
82-
computed: {
83-
schema() {
84-
return this.$store.getters['cluster/schemaFor']?.(RESOURCE.VEX_HUB);
41+
createVexHub() {
42+
this.$router.push({
43+
name: `${ PRODUCT_NAME }-c-cluster-resource-create`,
44+
params: {
45+
resource: RESOURCE.VEX_HUB,
46+
cluster: this.$route.params.cluster,
47+
product: PRODUCT_NAME
48+
}
49+
});
8550
}
8651
}
8752
}
@@ -150,41 +115,4 @@ export default {
150115
height: 40px;
151116
}
152117
}
153-
154-
// Status cell centering
155-
.status-cell {
156-
display: flex;
157-
align-items: center;
158-
justify-content: flex-start;
159-
height: 100%;
160-
min-height: 48px;
161-
padding: 8px 0;
162-
163-
:deep(.badge) {
164-
margin: 0;
165-
vertical-align: middle;
166-
}
167-
}
168-
169-
.uri-link .icon-external-link {
170-
margin-left: 6px;
171-
opacity: 0.7;
172-
}
173-
174-
/* Bulk header action buttons - align icons and text */
175-
.bulk-actions {
176-
display: flex;
177-
align-items: center;
178-
gap: 12px;
179-
}
180-
181-
.bulk-actions .btn {
182-
display: inline-flex;
183-
align-items: center;
184-
}
185-
186-
.bulk-actions .btn i {
187-
margin-right: 6px;
188-
line-height: 1;
189-
}
190118
</style>

pkg/sbombastic-image-vulnerability-scanner/routes/sbombastic-image-vulnerability-scanner-routes.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import Vulnerabilities from "@pkg/pages/c/_cluster/sbombastic-image-vulnerabilit
66
import CreateResource from "@pkg/pages/c/_cluster/sbombastic-image-vulnerability-scanner/_resource/create.vue";
77
import ListResource from "@pkg/pages/c/_cluster/sbombastic-image-vulnerability-scanner/_resource/index.vue";
88
import Entry from "@pkg/pages/c/_cluster/sbombastic-image-vulnerability-scanner/index.vue";
9+
import VexManagement from "@pkg/pages/c/_cluster/sbombastic-image-vulnerability-scanner/VexManagement.vue";
910
import {
1011
PRODUCT_NAME,
1112
PAGE,
13+
RESOURCE,
1214
} from "@pkg/types";
1315

1416
const routes = [
@@ -42,6 +44,11 @@ const routes = [
4244
path: `/c/:cluster/${PRODUCT_NAME}/${PAGE.REGISTRIES}/:ns/:id`,
4345
component: RegistryDetails,
4446
},
47+
{
48+
name: `c-cluster-${PRODUCT_NAME}-${PAGE.VEX_MANAGEMENT}`,
49+
path: `/c/:cluster/${PRODUCT_NAME}/${PAGE.VEX_MANAGEMENT}`,
50+
component: VexManagement,
51+
},
4552
{
4653
name: `${ PRODUCT_NAME }-c-cluster-resource-create`,
4754
path: `/${ PRODUCT_NAME }/c/:cluster/:resource/create`,
@@ -57,6 +64,20 @@ const routes = [
5764
meta: {
5865
product: PRODUCT_NAME,
5966
},
67+
beforeEnter: (to: any, from: any, next: any) => {
68+
// Redirect VexHub resource to custom VexManagement page
69+
if (to.params.resource === RESOURCE.VEX_HUB) {
70+
next({
71+
name: `c-cluster-${PRODUCT_NAME}-${PAGE.VEX_MANAGEMENT}`,
72+
params: {
73+
cluster: to.params.cluster,
74+
product: PRODUCT_NAME
75+
}
76+
});
77+
} else {
78+
next();
79+
}
80+
}
6081
},
6182
];
6283

0 commit comments

Comments
 (0)