1
+ <script >
2
+ import CreateEditView from ' @shell/mixins/create-edit-view' ;
3
+ import Footer from ' @shell/components/form/Footer' ;
4
+ import { LabeledInput } from ' @components/Form/LabeledInput' ;
5
+ import { RadioGroup } from ' @components/Form/Radio' ;
6
+ import NameNsDescription from ' @shell/components/form/NameNsDescription' ;
7
+ import CruResource from ' @shell/components/CruResource' ;
8
+ import SelectOrCreateAuthSecret from ' @shell/components/form/SelectOrCreateAuthSecret' ;
9
+ import LabeledSelect from ' @shell/components/form/LabeledSelect' ;
10
+ import Banner from ' @components/Banner/Banner.vue' ;
11
+ import { Checkbox } from ' @components/Form/Checkbox' ;
12
+ import { MANAGEMENT , NAMESPACE , CLUSTER_REPO_TYPES } from ' @shell/config/types' ;
13
+ import UnitInput from ' @shell/components/form/UnitInput.vue' ;
14
+ import {ref } from " vue" ;
15
+
16
+ export default {
17
+ name: ' CruRegistry' ,
18
+
19
+ components: {
20
+ Footer,
21
+ RadioGroup,
22
+ LabeledInput,
23
+ NameNsDescription,
24
+ CruResource,
25
+ SelectOrCreateAuthSecret,
26
+ Banner,
27
+ Checkbox,
28
+ UnitInput,
29
+ LabeledSelect
30
+ },
31
+
32
+ mixins: [CreateEditView],
33
+
34
+ data () {
35
+
36
+ if (! this .value .spec ) {
37
+ this .value .spec = {
38
+ insecure: true ,
39
+ authSecret: ' ' ,
40
+ caBundle: ' ' ,
41
+ type: {},
42
+ uri: ' ' ,
43
+ repositories: [],
44
+ };
45
+ }
46
+ if (! this .value .status ){
47
+ this .value .status = {
48
+ conditions: [],
49
+ };
50
+ }
51
+
52
+ console .log (' this.value after:' ,this .value );
53
+
54
+ return {
55
+ selectedRegistryType: this .value .type || ' ecr' ,
56
+ secretNamespace: this .$store .getters [' defaultNamespace' ],
57
+ inStore: this .$store .getters [' currentProduct' ].inStore ,
58
+ errors: null ,
59
+ };
60
+ },
61
+
62
+ computed: {
63
+ registryTypeOptions (){
64
+ return [
65
+ {
66
+ label: this .t (' imageScanner.registries.configuration.cru.registry.type.ecr' ),
67
+ value: ' ecr' ,
68
+ },
69
+ {
70
+ label: this .t (' imageScanner.registries.configuration.cru.registry.type.azure' ),
71
+ value: ' azure' ,
72
+ },
73
+ ];
74
+ },
75
+
76
+ namespace (){
77
+ console .log (' this.value.spec.type:' ,this .value .spec .type );
78
+ return this .value .spec .type === ' ecr' ? " kube-system" : " "
79
+ },
80
+
81
+ inStore () {
82
+ return this .$store .getters [' currentProduct' ]? .inStore || MANAGEMENT ;
83
+ },
84
+ secretNamespace () {
85
+ const tryNames = [' cattle-system' , ' default' ];
86
+
87
+ for ( const name of tryNames ) {
88
+ if ( this .$store .getters [' cluster/byId' ](NAMESPACE , name) ) {
89
+ return name;
90
+ }
91
+ }
92
+
93
+ return this .$store .getters [` ${ this .inStore } /all` ](NAMESPACE )[0 ]? .id ;
94
+ },
95
+
96
+ useProxy: {
97
+ get () {
98
+ return ! this .value .spec .insecure ;
99
+ },
100
+ set (val ) {
101
+ this .value .spec .insecure = ! val;
102
+ }
103
+ }
104
+ },
105
+ }
106
+
107
+ < / script>
108
+ < template>
109
+ < div class = " filled-height" >
110
+ < Banner color= " info" >
111
+ {{t (' imageScanner.registries.configuration.cru.description' )}}
112
+ < / Banner>
113
+ < CruResource
114
+ : done- route= " doneRoute"
115
+ : mode= " mode"
116
+ : resource= " value"
117
+ : subtypes= " []"
118
+ : validation- passed= " true"
119
+ : errors= " errors"
120
+ @error= " (e) => (errors = e)"
121
+ @finish= " save"
122
+ @cancel= " done"
123
+ >
124
+ < NameNsDescription
125
+ : value= " value"
126
+ : mode= " mode"
127
+ : namespaced= " isNamespaced"
128
+ @update: value= " $emit('input', $event)"
129
+ / >
130
+
131
+ < div class = " registry-input-label" >
132
+ {{ t (' imageScanner.registries.configuration.cru.registry.label' ) }}
133
+ < / div>
134
+
135
+ < div class = " row" >
136
+ < div class = " col span-6" >
137
+ < LabeledSelect
138
+ v- model: value= " value.spec.type"
139
+ data- testid= " registry-type-select"
140
+ : label= " t('imageScanner.registries.configuration.cru.registry.type.label')"
141
+ : options= " registryTypeOptions"
142
+ : placeholder= " t('imageScanner.registry.configuration.cru.registry.type.placeholder')"
143
+ required
144
+ / >
145
+ < / div>
146
+ < div class = " col span-3" >
147
+ < LabeledInput
148
+ : label= " t('imageScanner.registries.configuration.cru.registry.namespace.label')"
149
+ : value= " namespace"
150
+ : placeholderKey= " t('imageScanner.registries.configuration.cru.registry.namespace.placeholder')"
151
+ disabled= true
152
+ / >
153
+ < / div>
154
+ < / div>
155
+
156
+ < Checkbox
157
+ v- model: value= " useProxy"
158
+ class = " mt-20 mb-10"
159
+ : mode= " mode"
160
+ : label= " t('imageScanner.registries.configuration.cru.proxy.enable')"
161
+ : tooltipKey= " t('imageScanner.registries.configuration.cru.proxy.tooltip')"
162
+ data- testid= " registry-use-proxy"
163
+ / >
164
+
165
+ < div v- if = " useProxy" >
166
+ < div class = " registry-input-label mb-0" >
167
+ {{ t (' imageScanner.registries.configuration.cru.authLabel' ) }}
168
+ < / div>
169
+ < SelectOrCreateAuthSecret
170
+ : 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= " false"
176
+ : in - store= " inStore"
177
+ : allow- ssh= false
178
+ generate- name= " registry-auth-"
179
+ : cache- secrets= " true"
180
+ @input= " val => value.spec.authSecret = val"
181
+ / >
182
+
183
+ < div class = " registry-input-label mt-24" >
184
+ {{ t (' imageScanner.registries.configuration.cru.scan.label' ) }}
185
+ < / div>
186
+
187
+ < div class = " row" >
188
+ < div class = " col span-6" >
189
+ < LabeledSelect
190
+ v- model: value= " value.spec.repositories"
191
+ : label= " t('imageScanner.registries.configuration.cru.scan.type')"
192
+ >
193
+ < / LabeledSelect>
194
+ < / div>
195
+ < div class = " col span-3" >
196
+ < UnitInput
197
+ v- model: value= " unitInput"
198
+ : label= " t('imageScanner.registries.configuration.cru.scan.schedule.label')"
199
+ : mode= " mode"
200
+ min= " 0"
201
+ : suffix= " t('unit.hour', { count: 3 })"
202
+ : placeholder= " t('imageScanner.registries.configuration.cru.scan.schedule.placeholder', { hours: 3 })"
203
+ @update: value= " updateRefreshInterval($event)"
204
+ / >
205
+ < / div>
206
+ < / div>
207
+
208
+ < / div>
209
+
210
+ < / CruResource>
211
+ < / div>
212
+ < / template>
213
+
214
+ < style lang= " scss" scoped>
215
+ .registry - input- label {
216
+ margin- bottom: 16px ;
217
+ font- size: 16px ;
218
+ line- height: 20px ;
219
+ font- weight: 500 ;
220
+ font- family: ' Lato' , sans- serif;
221
+ color: #141419 ;
222
+ display: block;
223
+ }
224
+ .mt - 24 {
225
+ margin- top: 24px ;
226
+ }
227
+ < / style>
0 commit comments