Skip to content

Commit 6bfe68a

Browse files
committed
Address review comments
1 parent 700f4e0 commit 6bfe68a

5 files changed

Lines changed: 50 additions & 41 deletions

File tree

ui/public/locales/en.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3669,9 +3669,9 @@
36693669
"message.upload.iso.failed.description": "Failed to upload ISO.",
36703670
"message.upload.template.failed.description": "Failed to upload Template",
36713671
"message.upload.volume.failed": "Volume upload failed",
3672-
"message.ssvm.cert.untrusted": "The upload server certificate is not trusted by your browser.",
3673-
"message.ssvm.cert.trust.instructions": "Click 'Open Certificate Page' to open the upload server in a new browser tab. Accept the certificate warning shown by your browser, then come back here and click 'Retry Upload'.",
3674-
"message.ssvm.cert.still.untrusted": "The certificate still appears untrusted. Please accept it in the opened tab and try again.",
3672+
"message.ssvm.cert.untrusted": "Unable to reach the upload server.",
3673+
"message.ssvm.cert.trust.instructions": "The upload server may be using a self-signed or untrusted certificate. Click 'Open Certificate Page' to open the server in a new browser tab, accept the certificate warning, then return here and click 'Retry Upload'. If the server remains unreachable, contact your administrator.",
3674+
"message.ssvm.unreachable.retry": "The upload server is still unreachable. If it uses a self-signed certificate, please accept it in the opened tab and try again.",
36753675
"message.user.not.permitted.api": "User is not permitted to use the API",
36763676
"message.validate.equalto": "Please enter the same value again.",
36773677
"message.validate.max": "Please enter a value less than or equal to {0}.",

ui/src/utils/ssvmProbe.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
const SSVM_PROBE_TIMEOUT_MS = 5000
19+
export async function probeSsvmCert (origin) {
20+
const controller = new AbortController()
21+
const timeoutId = setTimeout(() => controller.abort(), SSVM_PROBE_TIMEOUT_MS)
22+
try {
23+
await fetch(origin, { method: 'HEAD', mode: 'no-cors', signal: controller.signal })
24+
return true
25+
} catch (e) {
26+
return false
27+
} finally {
28+
clearTimeout(timeoutId)
29+
}
30+
}

ui/src/views/image/RegisterOrUploadIso.vue

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ import { api } from '@/api'
327327
import store from '@/store'
328328
import { axios } from '../../utils/request'
329329
import { mixinForm } from '@/utils/mixin'
330+
import { probeSsvmCert } from '@/utils/ssvmProbe'
330331
import ResourceIcon from '@/components/view/ResourceIcon'
331332
import TooltipLabel from '@/components/widgets/TooltipLabel'
332333
@@ -359,7 +360,6 @@ export default {
359360
userdatapolicy: null,
360361
userdatapolicylist: {},
361362
loading: false,
362-
uploading: false,
363363
allowed: false,
364364
uploadParams: null,
365365
uploadPercentage: 0,
@@ -508,20 +508,12 @@ export default {
508508
this.form.file = file
509509
return false
510510
},
511-
async probeSsvmCert (origin) {
512-
try {
513-
await fetch(origin, { method: 'HEAD', mode: 'no-cors' })
514-
return true
515-
} catch (e) {
516-
return false
517-
}
518-
},
519511
async retryUpload () {
520512
this.loading = true
521-
const trusted = await this.probeSsvmCert(this.ssvmOrigin)
513+
const reachable = await probeSsvmCert(this.ssvmOrigin)
522514
this.loading = false
523-
if (!trusted) {
524-
this.$message.warning(this.$t('message.ssvm.cert.still.untrusted'))
515+
if (!reachable) {
516+
this.$message.warning(this.$t('message.ssvm.unreachable.retry'))
525517
return
526518
}
527519
this.ssvmCertUntrusted = false
@@ -630,7 +622,7 @@ export default {
630622
this.linkUserdataToTemplate(this.userdataid, json.postuploadisoresponse.iso[0].id)
631623
}
632624
this.ssvmOrigin = new URL(this.uploadParams.postURL).origin
633-
const trusted = await this.probeSsvmCert(this.ssvmOrigin)
625+
const trusted = await probeSsvmCert(this.ssvmOrigin)
634626
if (!trusted) {
635627
this.ssvmCertUntrusted = true
636628
return

ui/src/views/image/RegisterOrUploadTemplate.vue

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ import { api } from '@/api'
488488
import store from '@/store'
489489
import { axios } from '../../utils/request'
490490
import { mixinForm } from '@/utils/mixin'
491+
import { probeSsvmCert } from '@/utils/ssvmProbe'
491492
import ResourceIcon from '@/components/view/ResourceIcon'
492493
import TooltipLabel from '@/components/widgets/TooltipLabel'
493494
@@ -628,20 +629,12 @@ export default {
628629
this.form.file = file
629630
return false
630631
},
631-
async probeSsvmCert (origin) {
632-
try {
633-
await fetch(origin, { method: 'HEAD', mode: 'no-cors' })
634-
return true
635-
} catch (e) {
636-
return false
637-
}
638-
},
639632
async retryUpload () {
640633
this.loading = true
641-
const trusted = await this.probeSsvmCert(this.ssvmOrigin)
634+
const reachable = await probeSsvmCert(this.ssvmOrigin)
642635
this.loading = false
643-
if (!trusted) {
644-
this.$message.warning(this.$t('message.ssvm.cert.still.untrusted'))
636+
if (!reachable) {
637+
this.$message.warning(this.$t('message.ssvm.unreachable.retry'))
645638
return
646639
}
647640
this.ssvmCertUntrusted = false
@@ -1170,7 +1163,7 @@ export default {
11701163
this.linkUserdataToTemplate(this.userdataid, json.postuploadtemplateresponse.template[0].id)
11711164
}
11721165
this.ssvmOrigin = new URL(this.uploadParams.postURL).origin
1173-
const trusted = await this.probeSsvmCert(this.ssvmOrigin)
1166+
const trusted = await probeSsvmCert(this.ssvmOrigin)
11741167
if (!trusted) {
11751168
this.ssvmCertUntrusted = true
11761169
return

ui/src/views/storage/UploadLocalVolume.vue

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ import { ref, reactive, toRaw } from 'vue'
172172
import { api } from '@/api'
173173
import { axios } from '../../utils/request'
174174
import { mixinForm } from '@/utils/mixin'
175+
import { probeSsvmCert } from '@/utils/ssvmProbe'
175176
import ResourceIcon from '@/components/view/ResourceIcon'
176177
import TooltipLabel from '@/components/widgets/TooltipLabel'
177178
import InfiniteScrollSelect from '@/components/widgets/InfiniteScrollSelect.vue'
@@ -286,34 +287,27 @@ export default {
286287
this.form.account = accountName
287288
this.account = accountName
288289
},
289-
async probeSsvmCert (origin) {
290-
try {
291-
await fetch(origin, { method: 'HEAD', mode: 'no-cors' })
292-
return true
293-
} catch (e) {
294-
return false
295-
}
296-
},
297290
async retryUpload () {
298291
this.loading = true
299-
const trusted = await this.probeSsvmCert(this.ssvmOrigin)
292+
const reachable = await probeSsvmCert(this.ssvmOrigin)
300293
this.loading = false
301-
if (!trusted) {
302-
this.$message.warning(this.$t('message.ssvm.cert.still.untrusted'))
294+
if (!reachable) {
295+
this.$message.warning(this.$t('message.ssvm.unreachable.retry'))
303296
return
304297
}
305298
this.ssvmCertUntrusted = false
306299
this.handleUpload()
307300
},
308301
handleUpload () {
309-
const { fileList } = this
310302
if (this.fileList.length > 1) {
311303
this.$notification.error({
312304
message: this.$t('message.upload.volume.failed'),
313305
description: this.$t('message.upload.file.limit'),
314306
duration: 0
315307
})
308+
return
316309
}
310+
const { fileList } = this
317311
const formData = new FormData()
318312
fileList.forEach(file => {
319313
formData.append('files[]', file)
@@ -372,7 +366,7 @@ export default {
372366
api('getUploadParamsForVolume', params).then(async json => {
373367
this.uploadParams = json.postuploadvolumeresponse?.getuploadparams || ''
374368
this.ssvmOrigin = new URL(this.uploadParams.postURL).origin
375-
const trusted = await this.probeSsvmCert(this.ssvmOrigin)
369+
const trusted = await probeSsvmCert(this.ssvmOrigin)
376370
if (!trusted) {
377371
this.ssvmCertUntrusted = true
378372
return

0 commit comments

Comments
 (0)