From b2cad765bfc67aa5bf8e6eeb83f5840aaee8e7ad Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Fri, 29 Jul 2022 14:00:37 +0800 Subject: [PATCH] fix: fix ports quota check when create virtual adapter If the remaining quota of a port is zero, you can still successfully call the API to create a subnet and automatically add a port. As a result, the used port is greater than the upper limit of the quota. Fix the quota check method to accommodate this situation Change-Id: Icf955b3e4ad40d618305b23bffcd397fdbd0b288 --- .../containers/VirtualAdapter/actions/Create.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/network/containers/VirtualAdapter/actions/Create.jsx b/src/pages/network/containers/VirtualAdapter/actions/Create.jsx index 1ee2dc47..e22192cc 100644 --- a/src/pages/network/containers/VirtualAdapter/actions/Create.jsx +++ b/src/pages/network/containers/VirtualAdapter/actions/Create.jsx @@ -83,9 +83,9 @@ export class CreateAction extends ModalAction { static get disableSubmit() { const { - neutronQuota: { port: { left = 0 } = {} }, + neutronQuota: { port: { used = 0, limit = 0 } = {} }, } = globalProjectStore; - return left === 0; + return limit !== -1 && used >= limit; } static get showQuota() { @@ -113,13 +113,13 @@ export class CreateAction extends ModalAction { if (quotaLoading) { return []; } - const { left = 0 } = quota; - const add = left === 0 ? 0 : 1; + const { used = 0, limit = 0 } = quota; + const add = limit !== -1 && used >= limit ? 0 : 1; const data = { ...quota, add, name: 'port', - title: t('Port'), + title: t('Ports'), }; return [data]; }