From ed41e2579a194cdeb7410f9aa9d616f74560bced Mon Sep 17 00:00:00 2001 From: 639852 Date: Tue, 3 Sep 2024 20:44:07 +0400 Subject: [PATCH] - Fixed change of addons when changing ovh vps tariff --- .../cloud/modules/ovh vps/openInstance.vue | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/components/cloud/modules/ovh vps/openInstance.vue b/src/components/cloud/modules/ovh vps/openInstance.vue index f0fd45ed..59050a3e 100644 --- a/src/components/cloud/modules/ovh vps/openInstance.vue +++ b/src/components/cloud/modules/ovh vps/openInstance.vue @@ -1131,7 +1131,21 @@ export default defineComponent({ try { this.isSwitchLoading = true - const { price, resources } = this.tariffs[this.planCode] + const { price, resources, meta } = this.tariffs[this.planCode] ?? {} + const backupIndex = instance.config.addons.findIndex((key) => key.includes('backup')) + const snapshotIndex = instance.config.addons.findIndex((key) => key.includes('snapshot')) + + if (backupIndex !== -1) { + const backup = meta.addons.find((key) => key.includes('backup')) + + instance.config.addons.splice(backupIndex, 1, backup) + } + + if (snapshotIndex !== -1) { + const snapshot = meta.addons.find((key) => key.includes('snapshot')) + + instance.config.addons.splice(snapshotIndex, 1, snapshot) + } instance.config.planCode = this.planCode.split(' ')[1] instance.product = this.planCode