From c6eaddabe6c96b667382263a2e3bee3a93126122 Mon Sep 17 00:00:00 2001 From: "Jingwei.Zhang" Date: Mon, 18 Jul 2022 15:04:56 +0800 Subject: [PATCH] feat: support quota info when instance snapshot create volume 1. Support quota info when instance snapshot create volume 2. Disable click submit button when the given type's left quota is insufficient Change-Id: I2665b5285b7e93324fec7b02bbf095cf9fad3b9f --- .../InstanceSnapshot/actions/CreateVolume.jsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/pages/compute/containers/InstanceSnapshot/actions/CreateVolume.jsx b/src/pages/compute/containers/InstanceSnapshot/actions/CreateVolume.jsx index d84eb7b0..3968dc37 100644 --- a/src/pages/compute/containers/InstanceSnapshot/actions/CreateVolume.jsx +++ b/src/pages/compute/containers/InstanceSnapshot/actions/CreateVolume.jsx @@ -17,6 +17,14 @@ import { toJS } from 'mobx'; import { ModalAction } from 'containers/Action'; import globalVolumeStore from 'stores/cinder/volume'; import { InstanceSnapshotStore } from 'stores/glance/instance-snapshot'; +import { + getQuotaInfo, + checkQuotaDisable, + fetchQuota, + setCreateVolumeType, + onVolumeSizeChange, + onVolumeTypeChange, +} from 'resources/cinder/volume'; export class CreateVolume extends ModalAction { static id = 'create'; @@ -42,6 +50,22 @@ export class CreateVolume extends ModalAction { static allowed = () => Promise.resolve(true); + static get disableSubmit() { + return checkQuotaDisable(); + } + + static get showQuota() { + return true; + } + + get showQuota() { + return true; + } + + get quotaInfo() { + return getQuotaInfo(this); + } + async getVolumeTypes() { const { id } = this.item; // eslint-disable-next-line no-unused-vars @@ -53,6 +77,7 @@ export class CreateVolume extends ModalAction { const typeItem = this.volumeTypes.find((it) => it.label === volumeType); if (typeItem) { this.volumeType = typeItem.value; + setCreateVolumeType(volumeType); } this.updateFormValue('volume_type', this.volumeType); } @@ -60,9 +85,11 @@ export class CreateVolume extends ModalAction { async getMinSize() { const { id } = this.item; if (this.snapshot && this.snapshot.volume_size) { + fetchQuota(this, this.minSize); return; } await this.snapshotStore.fetchDetail({ id }); + fetchQuota(this, this.minSize); this.updateDefaultValue(); } @@ -134,6 +161,7 @@ export class CreateVolume extends ModalAction { min: this.minSize, extra: `${t('Min size')}: ${this.minSize}GiB`, required: true, + onChange: onVolumeSizeChange, }, { name: 'more', @@ -147,6 +175,7 @@ export class CreateVolume extends ModalAction { options: this.volumeTypes, placeholder: t('Please select volume type'), hidden: !more, + onChange: onVolumeTypeChange, }, ]; }