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,