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
This commit is contained in:
Jingwei.Zhang 2022-06-24 11:11:19 +08:00
parent 31876de016
commit 81f77b555d
3 changed files with 56 additions and 1 deletions

View File

@ -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",

View File

@ -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虚拟化型",

View File

@ -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,