From b7b259c699b3b3774b3ed992b3db5a0da1c9df4b Mon Sep 17 00:00:00 2001 From: Yi-Ya Chen Date: Thu, 2 Jan 2025 16:30:25 +0800 Subject: [PATCH 1/2] fix: allow to update labels Signed-off-by: Yi-Ya Chen --- pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue b/pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue index 423462fb..984e42c9 100644 --- a/pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue +++ b/pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue @@ -530,6 +530,7 @@ export default { :mode="mode" :pad-left="false" :read-allowed="false" + :value-can-be-empty="true" @focusKey="focusKey" @update:value="value.setLabels($event)" > @@ -552,7 +553,7 @@ export default { autocorrect="off" autocapitalize="off" spellcheck="false" - @update:value="queueUpdate" + @input="queueUpdate" /> From e5d4d0556d0bdefc20f7a1eec5ed4dce0f2339ed Mon Sep 17 00:00:00 2001 From: Yi-Ya Chen Date: Fri, 3 Jan 2025 13:33:04 +0800 Subject: [PATCH 2/2] fix: patch data to avoid status overwrite Signed-off-by: Yi-Ya Chen --- .../harvesterhci.io.virtualmachineimage.vue | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue b/pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue index 984e42c9..5256ef6a 100644 --- a/pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue +++ b/pkg/harvester/edit/harvesterhci.io.virtualmachineimage.vue @@ -245,6 +245,8 @@ export default { async saveImage(buttonCb) { this.value.spec.displayName = (this.value.spec.displayName || '').trim(); + if (this.isEdit) return await this.handleEditImage(buttonCb); + if (this.value.spec.sourceType === UPLOAD && this.isCreate) { try { this.value.spec.url = ''; @@ -269,6 +271,23 @@ export default { } }, + async handleEditImage(buttonCb) { + try { + const data = [{ + op: 'replace', path: '/metadata/labels', value: this.value.metadata.labels + }, { + op: 'replace', path: '/metadata/annotations', value: this.value.metadata.annotations + }]; + + await this.value.patch(data); + buttonCb(true); + this.done(); + } catch (e) { + this.errors = exceptionToErrorsArray(e); + buttonCb(false); + } + }, + setImageLabels(str) { const suffixName = str?.split('/')?.pop() || str;