From f20b28c64e66805311531c8480383f9ce6632dd9 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Wed, 21 Sep 2022 16:24:19 +0800 Subject: [PATCH] fix: The loading cannot be canceled The loading state cannot be canceled when create a flavor with a existing name Closes-Bug: #1990362 Change-Id: I409024fe9a47103e9e6401d408b739d0365bd621 --- src/stores/nova/flavor.js | 41 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/src/stores/nova/flavor.js b/src/stores/nova/flavor.js index 9499e3fb..7f740297 100644 --- a/src/stores/nova/flavor.js +++ b/src/stores/nova/flavor.js @@ -116,25 +116,30 @@ export class FlavorStore extends Base { async create(data, extraSpecs, accessControl) { const body = {}; body[this.responseKey] = data; - this.isSubmitting = true; - const result = await this.client.create(body); - const { id } = result.flavor; - const extraBody = { - extra_specs: extraSpecs, - }; - if (accessControl && accessControl.length > 0) { - await Promise.all( - accessControl.map((it) => { - const accessBody = { - addTenantAccess: { - tenant: it, - }, - }; - return this.client.action(id, accessBody); - }) - ); + try { + this.isSubmitting = true; + const result = await this.client.create(body); + const { id } = result.flavor; + const extraBody = { + extra_specs: extraSpecs, + }; + if (accessControl && accessControl.length > 0) { + await Promise.all( + accessControl.map((it) => { + const accessBody = { + addTenantAccess: { + tenant: it, + }, + }; + return this.client.action(id, accessBody); + }) + ); + } + return this.submitting(this.client.extraSpecs.create(id, extraBody)); + } catch (error) { + this.isSubmitting = false; + return Promise.reject(error); } - return this.submitting(this.client.extraSpecs.create(id, extraBody)); } @action