fix: Fix extend volume with large volume size
fix extend volume with large volume size limited by quota Change-Id: I57402313acca715d22e9ec8794fe6b66a40f0544
This commit is contained in:
parent
a6f387d67e
commit
8bbb0e1f28
@ -1285,6 +1285,7 @@
|
||||
"Queued": "Queued",
|
||||
"Quota Overview": "Quota Overview",
|
||||
"Quota exceeded": "Quota exceeded",
|
||||
"Quota is not enough for extend volume.": "Quota is not enough for extend volume.",
|
||||
"Quota: Insufficient quota to create resources, please adjust resource quantity or quota(left { quota }, input { input }).": "Quota: Insufficient quota to create resources, please adjust resource quantity or quota(left { quota }, input { input }).",
|
||||
"Quota: Project quotas sufficient resources can be created": "Quota: Project quotas sufficient resources can be created",
|
||||
"RAM": "RAM",
|
||||
|
@ -1284,6 +1284,7 @@
|
||||
"Queued": "已排队",
|
||||
"Quota Overview": "配额概况",
|
||||
"Quota exceeded": "配额用尽",
|
||||
"Quota is not enough for extend volume.": "配额不足以扩容云硬盘。",
|
||||
"Quota: Insufficient quota to create resources, please adjust resource quantity or quota(left { quota }, input { input }).": "配额:项目配额不足,无法创建资源,请进行资源数量或配额的调整(剩余{ quota },输入{ input })。",
|
||||
"Quota: Project quotas sufficient resources can be created": "配额:项目配额充足,可创建资源",
|
||||
"RAM": "内存",
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
import { inject, observer } from 'mobx-react';
|
||||
import { ModalAction } from 'containers/Action';
|
||||
import globalVolumeStore from 'stores/cinder/volume';
|
||||
import globalVolumeStore, { VolumeStore } from 'stores/cinder/volume';
|
||||
import { isAvailableOrInUse } from 'resources/volume';
|
||||
import { get } from 'lodash';
|
||||
import client from 'client';
|
||||
@ -46,9 +46,42 @@ export class ExtendVolume extends ModalAction {
|
||||
return t('After the volume is expanded, the volume cannot be reduced.');
|
||||
}
|
||||
|
||||
async getQuota() {
|
||||
await this.volumeStore.fetchQuota();
|
||||
this.updateDefaultValue();
|
||||
}
|
||||
|
||||
get isQuotaLimited() {
|
||||
const { gigabytes: { limit } = {} } = this.volumeStore.quotaSet || {};
|
||||
return limit !== -1;
|
||||
}
|
||||
|
||||
get leftSize() {
|
||||
const { gigabytes: { limit = 10, in_use = 0 } = {} } =
|
||||
this.volumeStore.quotaSet || {};
|
||||
return limit - in_use;
|
||||
}
|
||||
|
||||
get maxSize() {
|
||||
const { size: currentSize } = this.item;
|
||||
return currentSize + this.leftSize;
|
||||
}
|
||||
|
||||
isQuotaEnough() {
|
||||
return !this.isQuotaLimited || this.leftSize >= 1;
|
||||
}
|
||||
|
||||
get formItems() {
|
||||
const { size } = this.item;
|
||||
const minSize = size + 1;
|
||||
if (!this.isQuotaEnough()) {
|
||||
return [
|
||||
{
|
||||
type: 'label',
|
||||
component: t('Quota is not enough for extend volume.'),
|
||||
},
|
||||
];
|
||||
}
|
||||
return [
|
||||
{
|
||||
name: 'volume',
|
||||
@ -60,10 +93,19 @@ export class ExtendVolume extends ModalAction {
|
||||
name: 'new_size',
|
||||
label: t('Capacity (GB)'),
|
||||
type: 'slider-input',
|
||||
max: 500,
|
||||
max: this.maxSize,
|
||||
min: minSize,
|
||||
description: `${minSize}GB-500GB`,
|
||||
description: `${minSize}GB-${this.maxSize}GB`,
|
||||
required: true,
|
||||
display: this.isQuotaLimited,
|
||||
},
|
||||
{
|
||||
name: 'new_size',
|
||||
label: t('Capacity (GB)'),
|
||||
type: 'input-int',
|
||||
min: minSize,
|
||||
required: true,
|
||||
display: !this.isQuotaLimited,
|
||||
},
|
||||
];
|
||||
}
|
||||
@ -71,6 +113,9 @@ export class ExtendVolume extends ModalAction {
|
||||
init() {
|
||||
this.store = globalVolumeStore;
|
||||
this.state.showNotice = true;
|
||||
this.volumeStore = new VolumeStore();
|
||||
|
||||
this.getQuota();
|
||||
}
|
||||
|
||||
get showNotice() {
|
||||
@ -78,6 +123,13 @@ export class ExtendVolume extends ModalAction {
|
||||
}
|
||||
|
||||
onSubmit = async (values) => {
|
||||
if (!this.isQuotaEnough()) {
|
||||
this.setState({
|
||||
showNotice: false,
|
||||
});
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
const { new_size } = values;
|
||||
const { id } = this.item;
|
||||
|
||||
|
@ -16,7 +16,7 @@ import { action } from 'mobx';
|
||||
import client from 'client';
|
||||
import globalRootStore from 'stores/root';
|
||||
import globalUserStore from 'stores/keystone/user';
|
||||
import Base from '../base';
|
||||
import Base from 'stores/base';
|
||||
|
||||
export class CredentialStore extends Base {
|
||||
get isSubResource() {
|
||||
@ -29,7 +29,7 @@ export class CredentialStore extends Base {
|
||||
|
||||
get paramsFuncPage() {
|
||||
return (params) => {
|
||||
const { current, withPrice, id, ...rest } = params;
|
||||
const { current, id, ...rest } = params;
|
||||
return rest;
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user