feat: support quota info when backup create volume

1. Support quota info when backup create volume
2. Disable click submit button when quota is insufficient

Change-Id: I154a2fd85560c9b27770e4c828321da167d68133
This commit is contained in:
Jingwei.Zhang 2022-06-29 15:39:31 +08:00
parent b605ac01c4
commit 132c1d13be

View File

@ -15,6 +15,13 @@
import { inject, observer } from 'mobx-react';
import { ModalAction } from 'containers/Action';
import globalVolumeStore from 'stores/cinder/volume';
import {
getQuotaInfo,
checkQuotaDisable,
fetchQuota,
onVolumeSizeChange,
onVolumeTypeChange,
} from 'resources/cinder/volume';
export class CreateVolume extends ModalAction {
static id = 'create';
@ -31,6 +38,7 @@ export class CreateVolume extends ModalAction {
this.volumeStore = globalVolumeStore;
this.getAvailZones();
this.getVolumeTypes();
fetchQuota(this, this.item.size);
}
getAvailZones() {
@ -58,6 +66,22 @@ export class CreateVolume extends ModalAction {
return this.volumeStore.volumeTypes;
}
static get disableSubmit() {
return checkQuotaDisable();
}
static get showQuota() {
return true;
}
get showQuota() {
return true;
}
get quotaInfo() {
return getQuotaInfo(this);
}
static allowed = (item) => Promise.resolve(item.status === 'available');
get defaultValue() {
@ -94,6 +118,7 @@ export class CreateVolume extends ModalAction {
min: this.minSize,
extra: `${t('Min size')}: ${this.minSize}GiB`,
required: true,
onChange: onVolumeSizeChange,
},
{
name: 'volume_type',
@ -102,6 +127,7 @@ export class CreateVolume extends ModalAction {
required: true,
options: this.volumeTypes,
placeholder: t('Please select volume type'),
onChange: onVolumeTypeChange,
},
{
name: 'availability_zone',