@@ -6,13 +6,13 @@ import NameNsDescription from '@shell/components/form/NameNsDescription';
6
6
import CruResource from ' @shell/components/CruResource' ;
7
7
import SelectOrCreateAuthSecret from ' @shell/components/form/SelectOrCreateAuthSecret' ;
8
8
import LabeledSelect from ' @shell/components/form/LabeledSelect' ;
9
- import { Checkbox } from ' @components/Form/Checkbox' ;
10
- import { MANAGEMENT , NAMESPACE } from ' @shell/config/types' ;
9
+ import { MANAGEMENT , SECRET } from ' @shell/config/types' ;
11
10
import {
12
11
REGISTRY_TYPE_OPTIONS ,
13
12
SCAN_INTERVAL_OPTIONS , SCAN_INTERVALS
14
13
} from " @pkg/constants/scan-interval-options" ;
15
14
import { PRODUCT_NAME , PAGE } from " @pkg/types" ;
15
+ import { SECRET_TYPES } from " @shell/config/secret" ;
16
16
17
17
export default {
18
18
name: ' CruRegistry' ,
@@ -23,12 +23,17 @@ export default {
23
23
NameNsDescription,
24
24
CruResource,
25
25
SelectOrCreateAuthSecret,
26
- Checkbox,
27
26
LabeledSelect
28
27
},
29
28
30
29
mixins: [CreateEditView],
31
30
31
+ async fetch () {
32
+ this .allSecrets = await this .$store .dispatch (
33
+ ` ${ this .inStore } /findAll` ,{type: SECRET }
34
+ )
35
+ },
36
+
32
37
data () {
33
38
if (! this .value .spec ) {
34
39
this .value .spec = {
@@ -46,6 +51,8 @@ export default {
46
51
return {
47
52
inStore: this .$store .getters [' currentProduct' ].inStore ,
48
53
errors: null ,
54
+ allSecrets: null ,
55
+ filteredSecrets: null ,
49
56
PAGE ,
50
57
PRODUCT_NAME ,
51
58
};
@@ -55,17 +62,45 @@ export default {
55
62
inStore () {
56
63
return this .$store .getters [' currentProduct' ]? .inStore || MANAGEMENT ;
57
64
},
58
- secretNamespace () {
59
- const currentNamespace = this .value .metadata ? .namespace ? this .value .metadata .namespace : this .$store .getters [' defaultNamespace' ];
60
- const tryNames = [ currentNamespace, ' default' ];
61
65
62
- for ( const name of tryNames ) {
63
- if ( this .$store .getters [' cluster/byId' ](NAMESPACE , name) ) {
64
- return name;
66
+ /**
67
+ * Filter secrets given their namespace and required secret type
68
+ *
69
+ * Convert secrets to list of options and supplement with custom entries
70
+ */
71
+ options (){
72
+ let filteredSecrets = [];
73
+
74
+ if (this .allSecrets ){
75
+ const currentNamespace = this .value .metadata ? .namespace ? this .value .metadata .namespace : " default" ;
76
+ if (this .allSecrets ) {
77
+ // Filter secrets given their namespace
78
+ filteredSecrets = this .allSecrets
79
+ .filter ((secret ) => secret .metadata .namespace === currentNamespace)
80
+ .filter ((secret ) =>
81
+ SECRET_TYPES .DOCKER_JSON === secret ._type
82
+ );
65
83
}
66
84
}
67
85
68
- return this .$store .getters [` ${ this .inStore } /all` ](NAMESPACE )[0 ]? .id ;
86
+ let out = filteredSecrets .map ((x ) => {
87
+ const {
88
+ metadata , id
89
+ } = x;
90
+ const label = metadata .name ;
91
+
92
+ return {
93
+ label,
94
+ value: id .includes (' /' )? id .split (' /' )[1 ]: id,
95
+ };
96
+ });
97
+
98
+ out .unshift ({
99
+ label: this .t (' generic.none' ),
100
+ value: " " ,
101
+ });
102
+
103
+ return out;
69
104
},
70
105
71
106
SCAN_INTERVAL_OPTIONS : function () {
@@ -101,6 +136,8 @@ export default {
101
136
});
102
137
},
103
138
139
+ update (){},
140
+
104
141
doneRoute () {
105
142
console .log (' doneRoute' );
106
143
return ` c-cluster-${ PRODUCT_NAME } -${ PAGE .REGISTRIES } ` ;
@@ -163,21 +200,19 @@ export default {
163
200
/ >
164
201
< / div>
165
202
< / div>
166
- < div class = " registry-input-label mt-24 mb-0 " >
203
+ < div class = " registry-input-label mt-24" >
167
204
{{ t (' imageScanner.registries.configuration.cru.authentication.label' ) }}
168
205
< / div>
169
- < SelectOrCreateAuthSecret
170
- v- model: value= " value.spec.authSecret"
171
- : mode= " mode"
172
- data- testid= " registry-auth-secret"
173
- : register- before- hook= " registerBeforeHook"
174
- : namespace= " secretNamespace"
175
- : limit- to- namespace= " true"
176
- : in - store= " inStore"
177
- : allow- ssh= false
178
- generate- name= " registry-auth-"
179
- : cache- secrets= " true"
180
- / >
206
+ < div class = " row" >
207
+ < div class = " col span-6" >
208
+ < LabeledSelect
209
+ v- model: value= " value.spec.authSecret"
210
+ data- testid= " auth-secret-select"
211
+ : mode= " mode"
212
+ : options= " options"
213
+ / >
214
+ < / div>
215
+ < / div>
181
216
< div class = " registry-input-label mt-24" >
182
217
{{ t (' imageScanner.registries.configuration.cru.scan.label' ) }}
183
218
< / div>
0 commit comments