From 53f398b8c66cc71a5105bc0ca499fa2286e45425 Mon Sep 17 00:00:00 2001 From: zhangjingwei Date: Fri, 30 Jul 2021 10:12:43 +0800 Subject: [PATCH] fix: Fix create instance error hint 1. Fix create instance error hint 2. Fix create ironic error hint Change-Id: I42371374d1e7d70d6b6b81fbf451603138ed0b24 --- .../Instance/actions/CreateIronic/index.jsx | 25 +++++++++++++++++++ .../Instance/actions/StepCreate/index.jsx | 5 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/pages/compute/containers/Instance/actions/CreateIronic/index.jsx b/src/pages/compute/containers/Instance/actions/CreateIronic/index.jsx index bf3e32a9..23e100b1 100644 --- a/src/pages/compute/containers/Instance/actions/CreateIronic/index.jsx +++ b/src/pages/compute/containers/Instance/actions/CreateIronic/index.jsx @@ -23,6 +23,7 @@ import classnames from 'classnames'; import { isEmpty, isFinite } from 'lodash'; import { getUserData, canCreateIronicByLicense } from 'resources/instance'; import { ironicOriginEndpoint } from 'client/client/constants'; +import Notify from 'components/Notify'; import styles from './index.less'; import ConfirmStep from './ConfirmStep'; import SystemStep from './SystemStep'; @@ -318,4 +319,28 @@ export default class CreateIronic extends StepAction { }; return this.store.create(body); }; + + onOk = () => { + const { data } = this.state; + this.values = data; + this.onSubmit(data).then( + () => { + this.routing.push(this.listUrl); + Notify.success(this.successText); + }, + (err) => { + const { response: { data: responseData } = {} } = err; + const { forbidden: { message = '' } = {} } = responseData || {}; + if ( + message && + typeof message === 'string' && + message.indexOf('Quota exceeded') !== -1 + ) { + Notify.error(t('Quota exceeded')); + } else { + Notify.errorWithDetail(responseData, this.errorText); + } + } + ); + }; } diff --git a/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx b/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx index 90c12e8a..04538a85 100644 --- a/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx +++ b/src/pages/compute/containers/Instance/actions/StepCreate/index.jsx @@ -371,7 +371,8 @@ class StepCreate extends StepAction { Notify.success(this.successText); }, (err) => { - const { data: { forbidden: { message = '' } = {} } = {} } = err; + const { response: { data: responseData } = {} } = err; + const { forbidden: { message = '' } = {} } = responseData || {}; if ( message && isString(message) && @@ -379,7 +380,7 @@ class StepCreate extends StepAction { ) { Notify.error(t('Quota exceeded')); } else { - Notify.errorWithDetail(err, this.errorText); + Notify.errorWithDetail(responseData, this.errorText); } } );