feat: show volume list in volume snapshot detail
Show the volumes which are created by the snapshot Change-Id: I4d6fd2ba6b0e56bc22a55971ee482ca4f372ef11
This commit is contained in:
parent
b159d3fb67
commit
35c2a2a2fb
@ -539,6 +539,7 @@
|
|||||||
"Created": "Created",
|
"Created": "Created",
|
||||||
"Created At": "Created At",
|
"Created At": "Created At",
|
||||||
"Created Time": "Created Time",
|
"Created Time": "Created Time",
|
||||||
|
"Created Volumes": "Created Volumes",
|
||||||
"Creating": "Creating",
|
"Creating": "Creating",
|
||||||
"Creating From Snapshot": "Creating From Snapshot",
|
"Creating From Snapshot": "Creating From Snapshot",
|
||||||
"Creation Timeout (Minutes)": "Creation Timeout (Minutes)",
|
"Creation Timeout (Minutes)": "Creation Timeout (Minutes)",
|
||||||
|
@ -539,6 +539,7 @@
|
|||||||
"Created": "已创建",
|
"Created": "已创建",
|
||||||
"Created At": "创建于",
|
"Created At": "创建于",
|
||||||
"Created Time": "创建时间",
|
"Created Time": "创建时间",
|
||||||
|
"Created Volumes": "创建的云硬盘",
|
||||||
"Creating": "创建中",
|
"Creating": "创建中",
|
||||||
"Creating From Snapshot": "正在从快照创建共享",
|
"Creating From Snapshot": "正在从快照创建共享",
|
||||||
"Creation Timeout (Minutes)": "创建超时(分钟)",
|
"Creation Timeout (Minutes)": "创建超时(分钟)",
|
||||||
|
@ -16,6 +16,7 @@ import { inject, observer } from 'mobx-react';
|
|||||||
import { SnapshotStore } from 'stores/cinder/snapshot';
|
import { SnapshotStore } from 'stores/cinder/snapshot';
|
||||||
import Base from 'containers/TabDetail';
|
import Base from 'containers/TabDetail';
|
||||||
import { volumeStatus } from 'resources/cinder/volume';
|
import { volumeStatus } from 'resources/cinder/volume';
|
||||||
|
import Volumes from 'pages/storage/containers/Volume';
|
||||||
import BaseDetail from './BaseDetail';
|
import BaseDetail from './BaseDetail';
|
||||||
import actionConfigs from '../actions';
|
import actionConfigs from '../actions';
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ export class Detail extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get tabs() {
|
get tabs() {
|
||||||
|
const { child_volumes = [] } = this.detailData || {};
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{
|
{
|
||||||
title: t('Detail'),
|
title: t('Detail'),
|
||||||
@ -75,6 +77,13 @@ export class Detail extends Base {
|
|||||||
component: BaseDetail,
|
component: BaseDetail,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
if (child_volumes && child_volumes.length) {
|
||||||
|
tabs.push({
|
||||||
|
title: t('Created Volumes'),
|
||||||
|
key: 'volumes',
|
||||||
|
component: Volumes,
|
||||||
|
});
|
||||||
|
}
|
||||||
return tabs;
|
return tabs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,16 @@ import {
|
|||||||
getVolumeColumnsList,
|
getVolumeColumnsList,
|
||||||
} from 'resources/cinder/volume';
|
} from 'resources/cinder/volume';
|
||||||
import globalVolumeStore, { VolumeStore } from 'stores/cinder/volume';
|
import globalVolumeStore, { VolumeStore } from 'stores/cinder/volume';
|
||||||
|
import { SnapshotVolumeStore } from 'stores/cinder/snapshot-volume';
|
||||||
import { InstanceVolumeStore } from 'stores/nova/instance-volume';
|
import { InstanceVolumeStore } from 'stores/nova/instance-volume';
|
||||||
import { emptyActionConfig } from 'utils/constants';
|
import { emptyActionConfig } from 'utils/constants';
|
||||||
import actionConfigs from './actions';
|
import actionConfigs from './actions';
|
||||||
|
|
||||||
export class Volume extends Base {
|
export class Volume extends Base {
|
||||||
init() {
|
init() {
|
||||||
if (this.inDetailPage) {
|
if (this.isVolumeSnapshotDetail) {
|
||||||
|
this.store = new SnapshotVolumeStore();
|
||||||
|
} else if (this.inDetailPage) {
|
||||||
this.store = new InstanceVolumeStore();
|
this.store = new InstanceVolumeStore();
|
||||||
this.downloadStore = this.store;
|
this.downloadStore = this.store;
|
||||||
} else {
|
} else {
|
||||||
@ -47,12 +50,16 @@ export class Volume extends Base {
|
|||||||
return this.inDetailPage && this.path.includes('recycle-bin');
|
return this.inDetailPage && this.path.includes('recycle-bin');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get isVolumeSnapshotDetail() {
|
||||||
|
return this.inDetailPage && this.path.includes('storage/snapshot');
|
||||||
|
}
|
||||||
|
|
||||||
get actionConfigs() {
|
get actionConfigs() {
|
||||||
if (this.isRecycleBinDetail) {
|
if (this.isRecycleBinDetail) {
|
||||||
return emptyActionConfig;
|
return emptyActionConfig;
|
||||||
}
|
}
|
||||||
if (this.isAdminPage) {
|
if (this.isAdminPage) {
|
||||||
return this.inDetailPage
|
return this.inDetailPage && !this.isVolumeSnapshotDetail
|
||||||
? actionConfigs.instanceDetailAdminConfig
|
? actionConfigs.instanceDetailAdminConfig
|
||||||
: actionConfigs.adminConfig;
|
: actionConfigs.adminConfig;
|
||||||
}
|
}
|
||||||
@ -90,6 +97,15 @@ export class Volume extends Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateFetchParams = (params) => {
|
updateFetchParams = (params) => {
|
||||||
|
if (this.isVolumeSnapshotDetail) {
|
||||||
|
const { child_volumes = [] } = this.props.detail || {};
|
||||||
|
const volumeIds = child_volumes.map((it) => it.volume_id);
|
||||||
|
const { id, ...rest } = params;
|
||||||
|
return {
|
||||||
|
...rest,
|
||||||
|
volumeIds,
|
||||||
|
};
|
||||||
|
}
|
||||||
if (this.inDetailPage) {
|
if (this.inDetailPage) {
|
||||||
const { id, ...rest } = params;
|
const { id, ...rest } = params;
|
||||||
return {
|
return {
|
||||||
|
46
src/stores/cinder/snapshot-volume.js
Normal file
46
src/stores/cinder/snapshot-volume.js
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
// Copyright 2021 99cloud
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
import Base from 'stores/base';
|
||||||
|
import { groupArray } from 'utils/index';
|
||||||
|
import { updateVolume } from 'resources/cinder/volume';
|
||||||
|
|
||||||
|
export class SnapshotVolumeStore extends Base {
|
||||||
|
get mapper() {
|
||||||
|
return (volume) => updateVolume(volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
get groupArraySize() {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
async requestList(params, filters) {
|
||||||
|
const { volumeIds = [] } = filters;
|
||||||
|
const idArray = groupArray(volumeIds, this.groupArraySize);
|
||||||
|
const results = await Promise.all(
|
||||||
|
idArray.map((it) => {
|
||||||
|
const newParams = { uuid: it, ...params };
|
||||||
|
return this.skylineClient.extension.volumes(newParams);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
const resultVolumes = [];
|
||||||
|
results.forEach((result) => {
|
||||||
|
resultVolumes.push(...result.volumes);
|
||||||
|
});
|
||||||
|
return resultVolumes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const globalSnapshotVolumeStore = new SnapshotVolumeStore();
|
||||||
|
export default globalSnapshotVolumeStore;
|
Loading…
Reference in New Issue
Block a user