From e0d2a5e62457fe0bbfb2b7d77040dd518a02b9a7 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Fri, 29 Jul 2022 11:30:28 +0800 Subject: [PATCH] fix: fix the quota info 1.When the quota limit of zun containers is 0, it needs to disable the submit button 2.Change the add default value from 1 to 0 Change-Id: I7196b5075fda7c919784f10b0f2b5d0b3c35ec59 --- src/components/QuotaChart/Line.jsx | 2 +- src/components/QuotaChart/Ring.jsx | 2 +- .../Containers/actions/StepCreate/index.jsx | 26 ++++++++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/components/QuotaChart/Line.jsx b/src/components/QuotaChart/Line.jsx index 0ebfaac8..d2824f27 100644 --- a/src/components/QuotaChart/Line.jsx +++ b/src/components/QuotaChart/Line.jsx @@ -19,7 +19,7 @@ import { typeColors, getUsedValueColor } from './Ring'; export default function Line(props) { const { used = 0, - add = 1, + add = 0, reserved = 0, limit = 1, title = '', diff --git a/src/components/QuotaChart/Ring.jsx b/src/components/QuotaChart/Ring.jsx index 0cfc66a5..ecfb0181 100644 --- a/src/components/QuotaChart/Ring.jsx +++ b/src/components/QuotaChart/Ring.jsx @@ -54,7 +54,7 @@ const testChinese = (str) => { export default function Ring(props) { const { used = 0, - add = 1, + add = 0, reserved = 0, limit = 1, title = '', diff --git a/src/pages/container-service/containers/Containers/actions/StepCreate/index.jsx b/src/pages/container-service/containers/Containers/actions/StepCreate/index.jsx index 326b4d6e..ee505b28 100644 --- a/src/pages/container-service/containers/Containers/actions/StepCreate/index.jsx +++ b/src/pages/container-service/containers/Containers/actions/StepCreate/index.jsx @@ -26,6 +26,7 @@ export class StepCreate extends StepAction { this.store = globalContainersStore; this.projectStore = globalProjectStore; this.getQuota(); + this.state.isLoading = true; this.errorMsg = ''; } @@ -85,22 +86,26 @@ export class StepCreate extends StepAction { } get quotaInfo() { + if (this.state.isLoading) { + return []; + } const { containers = {}, cpu = {}, memory = {}, disk = {}, } = this.projectStore.zunQuota; - const { limit } = containers || {}; - if (!limit) { - return []; - } + const { left = 0 } = containers || {}; const { - data: { cpu: cpuCount, memory: memoryCount, disk: diskCount } = {}, + data: { + cpu: cpuCount = 0, + memory: memoryCount = 0, + disk: diskCount = 0, + } = {}, } = this.state; const containersQuotaInfo = { ...containers, - add: 1, + add: left ? 1 : 0, name: 'containers', title: t('Containers'), }; @@ -136,6 +141,9 @@ export class StepCreate extends StepAction { async getQuota() { await this.projectStore.fetchProjectZunQuota(); + this.setState({ + isLoading: false, + }); } getQuotaMessage(input, left, name) { @@ -153,7 +161,11 @@ export class StepCreate extends StepAction { checkQuota(data, quota) { const { containers = {}, cpu = {}, memory = {}, disk = {} } = quota || {}; - const { cpu: cpuCount, memory: memoryCount, disk: diskCount } = data || {}; + const { + cpu: cpuCount = 0, + memory: memoryCount = 0, + disk: diskCount = 0, + } = data || {}; const { left: containerLeft = 0 } = containers; const containerMsg = this.getQuotaMessage(