From cc897b08b777f695747d19f99cab1383c6f4064e Mon Sep 17 00:00:00 2001 From: xusongfu Date: Wed, 14 Jul 2021 19:12:53 +0800 Subject: [PATCH] fix: Fix the prompts when form submit 1. Modify response processing to distinguish single operation or batch operation 2. Modify the request function of creating volume in batches Change-Id: Iffcd8174cf69191b8c36aa0f4de1853c8284fa93 --- src/components/Form/index.jsx | 32 ++++++++++++++++++- .../Volume/actions/Create/index.jsx | 2 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/components/Form/index.jsx b/src/components/Form/index.jsx index b06fb289..8802e542 100644 --- a/src/components/Form/index.jsx +++ b/src/components/Form/index.jsx @@ -265,10 +265,40 @@ export default class BaseForm extends React.Component { this.updateSumbitting(false); !this.isModal && this.routing.push(this.listUrl); this.response = response; - this.showNotice && Notify.success(this.successText); if (callback && isFunction(callback)) { callback(true, false); } + if (response instanceof Array) { + const instanceNameArr = this.instanceName.split(', '); + const failedNames = response + .map((it, idx) => { + if (it.status === 'rejected') { + return { + reason: it.reason, + name: instanceNameArr[idx], + }; + } + return null; + }) + .filter((it) => !!it); + if (failedNames.length !== 0) { + failedNames.forEach((it) => { + const { response: { data } = {} } = it.reason; + this.showNotice && + Notify.errorWithDetail( + data, + t('Unable to {action}, instance: {name}.', { + action: this.name.toLowerCase(), + name: it.name, + }) + ); + }); + } else { + this.showNotice && Notify.success(this.successText); + } + } else { + this.showNotice && Notify.success(this.successText); + } }, (err = {}) => { this.updateSumbitting(false); diff --git a/src/pages/storage/containers/Volume/actions/Create/index.jsx b/src/pages/storage/containers/Volume/actions/Create/index.jsx index e2dda3e3..ac79bdcf 100644 --- a/src/pages/storage/containers/Volume/actions/Create/index.jsx +++ b/src/pages/storage/containers/Volume/actions/Create/index.jsx @@ -568,7 +568,7 @@ export default class Create extends FormAction { if (count === 1) { return this.volumeStore.create(volume); } - return Promise.all( + return Promise.allSettled( new Array(count).fill(count).map((_, index) => { const body = { ...volume,