Merge "fix: Fix extend volume with large volume size"
This commit is contained in:
commit
f15ea203a2
@ -1285,6 +1285,7 @@
|
|||||||
"Queued": "Queued",
|
"Queued": "Queued",
|
||||||
"Quota Overview": "Quota Overview",
|
"Quota Overview": "Quota Overview",
|
||||||
"Quota exceeded": "Quota exceeded",
|
"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: 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",
|
"Quota: Project quotas sufficient resources can be created": "Quota: Project quotas sufficient resources can be created",
|
||||||
"RAM": "RAM",
|
"RAM": "RAM",
|
||||||
|
@ -1285,6 +1285,7 @@
|
|||||||
"Queued": "已排队",
|
"Queued": "已排队",
|
||||||
"Quota Overview": "配额概况",
|
"Quota Overview": "配额概况",
|
||||||
"Quota exceeded": "配额用尽",
|
"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: 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": "配额:项目配额充足,可创建资源",
|
"Quota: Project quotas sufficient resources can be created": "配额:项目配额充足,可创建资源",
|
||||||
"RAM": "内存",
|
"RAM": "内存",
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import { inject, observer } from 'mobx-react';
|
import { inject, observer } from 'mobx-react';
|
||||||
import { ModalAction } from 'containers/Action';
|
import { ModalAction } from 'containers/Action';
|
||||||
import globalVolumeStore from 'stores/cinder/volume';
|
import globalVolumeStore, { VolumeStore } from 'stores/cinder/volume';
|
||||||
import { isAvailableOrInUse } from 'resources/volume';
|
import { isAvailableOrInUse } from 'resources/volume';
|
||||||
import { get } from 'lodash';
|
import { get } from 'lodash';
|
||||||
import client from 'client';
|
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.');
|
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() {
|
get formItems() {
|
||||||
const { size } = this.item;
|
const { size } = this.item;
|
||||||
const minSize = size + 1;
|
const minSize = size + 1;
|
||||||
|
if (!this.isQuotaEnough()) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
type: 'label',
|
||||||
|
component: t('Quota is not enough for extend volume.'),
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
name: 'volume',
|
name: 'volume',
|
||||||
@ -60,10 +93,19 @@ export class ExtendVolume extends ModalAction {
|
|||||||
name: 'new_size',
|
name: 'new_size',
|
||||||
label: t('Capacity (GB)'),
|
label: t('Capacity (GB)'),
|
||||||
type: 'slider-input',
|
type: 'slider-input',
|
||||||
max: 500,
|
max: this.maxSize,
|
||||||
min: minSize,
|
min: minSize,
|
||||||
description: `${minSize}GB-500GB`,
|
description: `${minSize}GB-${this.maxSize}GB`,
|
||||||
required: true,
|
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() {
|
init() {
|
||||||
this.store = globalVolumeStore;
|
this.store = globalVolumeStore;
|
||||||
this.state.showNotice = true;
|
this.state.showNotice = true;
|
||||||
|
this.volumeStore = new VolumeStore();
|
||||||
|
|
||||||
|
this.getQuota();
|
||||||
}
|
}
|
||||||
|
|
||||||
get showNotice() {
|
get showNotice() {
|
||||||
@ -78,6 +123,13 @@ export class ExtendVolume extends ModalAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onSubmit = async (values) => {
|
onSubmit = async (values) => {
|
||||||
|
if (!this.isQuotaEnough()) {
|
||||||
|
this.setState({
|
||||||
|
showNotice: false,
|
||||||
|
});
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
|
||||||
const { new_size } = values;
|
const { new_size } = values;
|
||||||
const { id } = this.item;
|
const { id } = this.item;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ import { action } from 'mobx';
|
|||||||
import client from 'client';
|
import client from 'client';
|
||||||
import globalRootStore from 'stores/root';
|
import globalRootStore from 'stores/root';
|
||||||
import globalUserStore from 'stores/keystone/user';
|
import globalUserStore from 'stores/keystone/user';
|
||||||
import Base from '../base';
|
import Base from 'stores/base';
|
||||||
|
|
||||||
export class CredentialStore extends Base {
|
export class CredentialStore extends Base {
|
||||||
get isSubResource() {
|
get isSubResource() {
|
||||||
@ -29,7 +29,7 @@ export class CredentialStore extends Base {
|
|||||||
|
|
||||||
get paramsFuncPage() {
|
get paramsFuncPage() {
|
||||||
return (params) => {
|
return (params) => {
|
||||||
const { current, withPrice, id, ...rest } = params;
|
const { current, id, ...rest } = params;
|
||||||
return rest;
|
return rest;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user