mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2025-12-13 13:11:43 +00:00
fix: abort upload when switch to URL option (#552)
Signed-off-by: Andy Lee <andy.lee@suse.com>
This commit is contained in:
parent
78e78ac8dd
commit
98efd63110
@ -215,19 +215,18 @@ export default {
|
|||||||
if (this.imageSource === IMAGE_METHOD.NEW) {
|
if (this.imageSource === IMAGE_METHOD.NEW) {
|
||||||
this.imageValue.metadata.annotations[HCI_ANNOTATIONS.OS_UPGRADE_IMAGE] = 'True';
|
this.imageValue.metadata.annotations[HCI_ANNOTATIONS.OS_UPGRADE_IMAGE] = 'True';
|
||||||
|
|
||||||
if (this.sourceType === UPLOAD && this.uploadImageId !== '') {
|
if (this.sourceType === UPLOAD && this.uploadImageId !== '') { // upload new image
|
||||||
this.value.spec.image = this.uploadImageId;
|
this.value.spec.image = this.uploadImageId;
|
||||||
} else if (this.sourceType === DOWNLOAD) {
|
} else if (this.sourceType === DOWNLOAD) { // give URL to download new image
|
||||||
this.imageValue.spec.sourceType = DOWNLOAD;
|
this.imageValue.spec.sourceType = DOWNLOAD;
|
||||||
|
|
||||||
if (!this.imageValue.spec.url) {
|
if (!this.imageValue.spec.url) {
|
||||||
this.errors.push(this.$store.getters['i18n/t']('harvester.setting.upgrade.imageUrl'));
|
this.errors.push(this.$store.getters['i18n/t']('harvester.setting.upgrade.imageUrl'));
|
||||||
buttonCb(false);
|
buttonCb(false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
res = await this.imageValue.save();
|
res = await this.imageValue.save();
|
||||||
|
|
||||||
this.value.spec.image = res.id;
|
this.value.spec.image = res.id;
|
||||||
}
|
}
|
||||||
} else if (this.imageSource === IMAGE_METHOD.EXIST) {
|
} else if (this.imageSource === IMAGE_METHOD.EXIST) {
|
||||||
@ -247,7 +246,6 @@ export default {
|
|||||||
if (this.skipSingleReplicaDetachedVolFeatureEnabled) {
|
if (this.skipSingleReplicaDetachedVolFeatureEnabled) {
|
||||||
this.value.metadata.annotations = { [HCI_ANNOTATIONS.SKIP_SINGLE_REPLICA_DETACHED_VOL]: JSON.stringify(this.skipSingleReplicaDetachedVol) };
|
this.value.metadata.annotations = { [HCI_ANNOTATIONS.SKIP_SINGLE_REPLICA_DETACHED_VOL]: JSON.stringify(this.skipSingleReplicaDetachedVol) };
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.value.save();
|
await this.value.save();
|
||||||
this.done();
|
this.done();
|
||||||
buttonCb(true);
|
buttonCb(true);
|
||||||
@ -334,6 +332,22 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
|
async sourceType(neu) {
|
||||||
|
if (neu === DOWNLOAD && this.imageValue && this.uploadController) {
|
||||||
|
if (this.uploadController) {
|
||||||
|
this.uploadController.abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.imageValue.remove();
|
||||||
|
await this.initImageValue();
|
||||||
|
} catch (error) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.error('Error occurred while removing imageValue:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
imageSource(neu) {
|
imageSource(neu) {
|
||||||
if (neu !== IMAGE_METHOD.DELETE) {
|
if (neu !== IMAGE_METHOD.DELETE) {
|
||||||
this.deleteImageId = '';
|
this.deleteImageId = '';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user