1010 :value =" registry"
1111 showSearch
1212 :filterOption =" filterOption"
13+ optionLabelProp =" label"
1314 @change =" handleRegistryChange" >
14- <a-select-option value =" " >{{ $t('common.tips.select', [$t('compute.eci.repo.image.registry')]) }}</a-select-option >
15+ <a-select-option value =" " label = " " >{{ $t('common.tips.select', [$t('compute.eci.repo.image.registry')]) }}</a-select-option >
1516 <a-select-option
1617 v-for =" cr in registrys"
1718 :key =" cr.value"
18- :value =" cr.value" >{{ cr.label }}</a-select-option >
19- </a-select >
20- </a-col >
21- <a-col :span =" colSpan" >
22- <a-select
23- :loading =" imageLoading"
24- :value =" image"
25- showSearch
26- :filterOption =" filterOption"
27- @change =" handleImageChange" >
28- <a-select-option value =" " >{{ $t('common.tips.select', [$t('compute.pod-image')]) }}</a-select-option >
29- <a-select-option
30- v-for =" cr in images"
31- :key =" cr.value"
32- :value =" cr.value" >{{ cr.label }}</a-select-option >
33- </a-select >
34- </a-col >
35- <a-col :span =" colSpan" >
36- <a-select
37- :loading =" tagLoading"
38- :value =" tag"
39- showSearch
40- :filterOption =" filterOption"
41- @change =" handleTagChange" >
42- <a-select-option value =" " >{{ $t('common.tips.select', [$t('compute.repo.image.tag')]) }}</a-select-option >
43- <a-select-option
44- v-for =" cr in tags"
45- :key =" cr.value"
46- :value =" cr.value" >{{ cr.label }}</a-select-option >
19+ :value =" cr.value"
20+ :label =" cr.label" >
21+ <div >{{ cr.label }}</div >
22+ <div style =" font-size : 12px ; color : #999 ;" >{{ cr.url }}</div >
23+ </a-select-option >
4724 </a-select >
4825 </a-col >
26+ <template v-if =" isCustomRegistry " >
27+ <a-col :span =" 16" >
28+ <a-input
29+ :value =" customImageUrl"
30+ :placeholder =" $t('k8s.repo.image.custom.placeholder')"
31+ @change =" handleCustomImageUrlChange" />
32+ <div v-if =" previewImage" style =" font-size : 12px ; color : #999 ; margin-top : 4px ;" >{{ previewImage }}</div >
33+ </a-col >
34+ </template >
35+ <template v-else >
36+ <a-col :span =" colSpan" >
37+ <a-select
38+ :loading =" imageLoading"
39+ :value =" image"
40+ showSearch
41+ :filterOption =" filterOption"
42+ @change =" handleImageChange" >
43+ <a-select-option value =" " >{{ $t('common.tips.select', [$t('compute.pod-image')]) }}</a-select-option >
44+ <a-select-option
45+ v-for =" cr in images"
46+ :key =" cr.value"
47+ :value =" cr.value" >{{ cr.label }}</a-select-option >
48+ </a-select >
49+ </a-col >
50+ <a-col :span =" colSpan" >
51+ <a-select
52+ :loading =" tagLoading"
53+ :value =" tag"
54+ showSearch
55+ :filterOption =" filterOption"
56+ @change =" handleTagChange" >
57+ <a-select-option value =" " >{{ $t('common.tips.select', [$t('compute.repo.image.tag')]) }}</a-select-option >
58+ <a-select-option
59+ v-for =" cr in tags"
60+ :key =" cr.value"
61+ :value =" cr.value" >{{ cr.label }}</a-select-option >
62+ </a-select >
63+ </a-col >
64+ </template >
4965 </a-row >
5066</template >
5167
@@ -75,8 +91,23 @@ export default {
7591 tag: ' ' ,
7692 tags: [],
7793 colSpan: 8 ,
94+ customImageUrl: ' ' ,
7895 }
7996 },
97+ computed: {
98+ isCustomRegistry () {
99+ const cur = this .registrys .find (o => o .value === this .registry )
100+ return cur? .type === ' custom'
101+ },
102+ previewImage () {
103+ const cur = this .registrys .find (o => o .value === this .registry )
104+ const url = cur? .url
105+ if (url && this .customImageUrl ) {
106+ return ` ${ this .stripProtocol (url)} /${ this .customImageUrl } `
107+ }
108+ return ' '
109+ },
110+ },
80111 watch: {
81112 registry (val ) {
82113 if (! val) {
@@ -96,14 +127,27 @@ export default {
96127 handleRegistryChange (val ) {
97128 if (val) {
98129 this .registry = val
99- this .getImagesByRegistryId (val)
130+ this .customImageUrl = ' '
131+ const cur = this .registrys .find (o => o .value === val)
132+ this .$emit (' credential-change' , cur? .credential_id || ' ' )
133+ if (cur? .type === ' custom' ) {
134+ this .image = ' '
135+ this .images = []
136+ this .tag = ' '
137+ this .tags = []
138+ this .$emit (' change' , ' ' )
139+ } else {
140+ this .getImagesByRegistryId (val)
141+ }
100142 } else {
101143 this .registry = ' '
102144 this .image = ' '
103145 this .images = []
104146 this .tag = ' '
105147 this .tags = []
148+ this .customImageUrl = ' '
106149 this .$emit (' change' , ' ' )
150+ this .$emit (' credential-change' , ' ' )
107151 }
108152 },
109153 async getRegistrys () {
@@ -112,14 +156,16 @@ export default {
112156 this .registryLoading = true
113157 this .registry = ' '
114158 this .registrys = []
115- const params = { details: true , limit: 20 , offset: 0 , $t: uuid () }
159+ const params = { details: true , limit: 20 , offset: 0 , scope : this . $store . getters . scope , $t: uuid () }
116160 const result = await manager .list ({ params })
117161 const dataArr = result .data .data || []
118162 this .registrys = dataArr .map (item => {
119163 return {
120164 label: item .name ,
121165 value: item .id ,
122166 url: item .url ,
167+ type: item .type ,
168+ credential_id: item .credential_id ,
123169 }
124170 })
125171 if (this .isDefaultSelect && this .registrys ? .length > 0 ) {
@@ -203,11 +249,25 @@ export default {
203249 this .tagLoading = false
204250 }
205251 },
252+ stripProtocol (url ) {
253+ return url .replace (/ ^ https? :\/\/ / , ' ' )
254+ },
255+ handleCustomImageUrlChange (e ) {
256+ const val = e .target .value
257+ this .customImageUrl = val
258+ const curRegistry = this .registrys .find (o => o .value === this .registry )
259+ const url = curRegistry? .url
260+ if (url && val) {
261+ this .$emit (' change' , ` ${ this .stripProtocol (url)} /${ val} ` )
262+ } else {
263+ this .$emit (' change' , ' ' )
264+ }
265+ },
206266 triggerChange (registry , image , tag ) {
207267 const curRegistry = this .registrys .find (o => o .value === registry)
208268 const url = curRegistry? .url
209269 if (url && image && tag) {
210- this .$emit (' change' , ` ${ url} /${ image} :${ tag} ` )
270+ this .$emit (' change' , ` ${ this . stripProtocol ( url) } /${ image} :${ tag} ` )
211271 } else {
212272 this .$emit (' change' , ' ' )
213273 }
0 commit comments