From 81f77b555d5e6899b86c4c1cd2a530681a7d6c68 Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Fri, 24 Jun 2022 11:11:19 +0800 Subject: [PATCH] feat: support quota info when create virtual adapter 1. Add virtual adapter tip in create form 2. Support port quota info in create form 3. Disable click submit button when port left quota is zero 4. Remove useless projects fetch Change-Id: I6e135930ac2fd1429621dcc3528cea172da2b828 --- src/locales/en.json | 1 + src/locales/zh.json | 1 + .../VirtualAdapter/actions/Create.jsx | 55 ++++++++++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/locales/en.json b/src/locales/en.json index d3a488aa..bb74b056 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -2461,6 +2461,7 @@ "Virtual LANs": "Virtual LANs", "Virtual Resource Num": "Virtual Resource Num", "Virtual Resource Overview": "Virtual Resource Overview", + "Virtual adapter mainly used for binding instance and other operations, occupying the quota of the port.": "Virtual adapter mainly used for binding instance and other operations, occupying the quota of the port.", "VirtualAdapter Mac": "VirtualAdapter Mac", "Visibility": "Visibility", "Visualization Compute Optimized Type with GPU": "Visualization Compute Optimized Type with GPU", diff --git a/src/locales/zh.json b/src/locales/zh.json index 9304bd7c..84952150 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -2461,6 +2461,7 @@ "Virtual LANs": "块虚拟网卡", "Virtual Resource Num": "虚拟资源用量", "Virtual Resource Overview": "虚拟资源总览", + "Virtual adapter mainly used for binding instance and other operations, occupying the quota of the port.": "虚拟网卡,主要用于绑定云主机等操作,占用端口的配额。", "VirtualAdapter Mac": "虚拟网卡的MAC", "Visibility": "可见性", "Visualization Compute Optimized Type with GPU": "GPU虚拟化型", diff --git a/src/pages/network/containers/VirtualAdapter/actions/Create.jsx b/src/pages/network/containers/VirtualAdapter/actions/Create.jsx index 610f0986..1ee2dc47 100644 --- a/src/pages/network/containers/VirtualAdapter/actions/Create.jsx +++ b/src/pages/network/containers/VirtualAdapter/actions/Create.jsx @@ -39,12 +39,16 @@ export class CreateAction extends ModalAction { } init() { + this.state.quota = {}; + this.state.quotaLoading = true; + this.projectStore = globalProjectStore; this.networkStore = new NetworkStore(); this.securityGroupStore = new SecurityGroupStore(); this.qosPolicyStore = new QoSPolicyStore(); this.subnetStore = new SubnetStore(); + this.getQuota(); // this.getSecurityGroups(); - this.isAdminPage && globalProjectStore.fetchList(); + // this.isAdminPage && globalProjectStore.fetchList(); } async getSubnets(value) { @@ -71,6 +75,55 @@ export class CreateAction extends ModalAction { return 'large'; } + get tips() { + return t( + 'Virtual adapter mainly used for binding instance and other operations, occupying the quota of the port.' + ); + } + + static get disableSubmit() { + const { + neutronQuota: { port: { left = 0 } = {} }, + } = globalProjectStore; + return left === 0; + } + + static get showQuota() { + return true; + } + + get showQuota() { + return true; + } + + async getQuota() { + this.setState({ + quotaLoading: true, + }); + const result = await this.projectStore.fetchProjectNeutronQuota(); + const { port: quota = {} } = result || {}; + this.setState({ + quota, + quotaLoading: false, + }); + } + + get quotaInfo() { + const { quota = {}, quotaLoading } = this.state; + if (quotaLoading) { + return []; + } + const { left = 0 } = quota; + const add = left === 0 ? 0 : 1; + const data = { + ...quota, + add, + name: 'port', + title: t('Port'), + }; + return [data]; + } + get defaultValue() { const data = { // project_id: this.currentProjectId,