From 45178c2e1feb9c5ff05b2354161dcc86088aafe6 Mon Sep 17 00:00:00 2001 From: xusongfu Date: Tue, 23 Aug 2022 14:28:48 +0800 Subject: [PATCH] fix: fix the delete permission of volume snapshot No delete operation in detail page if the snapshot has created some volumes Change-Id: Iabe91d109c134b256360b377328f2055733ad987 --- src/locales/en.json | 1 + src/locales/zh.json | 1 + .../containers/Snapshot/Detail/BaseDetail.jsx | 11 +++++------ src/stores/cinder/snapshot.js | 15 ++++++++++----- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/locales/en.json b/src/locales/en.json index 5a1990fd..55fbc031 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -2140,6 +2140,7 @@ "Snapshot Failed": "Snapshot Failed", "Snapshot In Progress": "Snapshot In Progress", "Snapshot Instance": "Snapshot Instance", + "Snapshot Source": "Snapshot Source", "Snapshots can be converted into volume and used to create an instance from the volume.": "Snapshots can be converted into volume and used to create an instance from the volume.", "Snapshotting": "Snapshotting", "Soft Delete Instance": "Soft Delete Instance", diff --git a/src/locales/zh.json b/src/locales/zh.json index 1e2d7f33..359c9db1 100644 --- a/src/locales/zh.json +++ b/src/locales/zh.json @@ -2140,6 +2140,7 @@ "Snapshot Failed": "生成快照失败", "Snapshot In Progress": "快照进行中", "Snapshot Instance": "创建云主机快照", + "Snapshot Source": "快照源", "Snapshots can be converted into volume and used to create an instance from the volume.": "快照可以转换成云硬盘,用于从云硬盘启动云主机。", "Snapshotting": "创建快照中", "Soft Delete Instance": "软删除云主机", diff --git a/src/pages/storage/containers/Snapshot/Detail/BaseDetail.jsx b/src/pages/storage/containers/Snapshot/Detail/BaseDetail.jsx index 29cdfd57..82c24c9b 100644 --- a/src/pages/storage/containers/Snapshot/Detail/BaseDetail.jsx +++ b/src/pages/storage/containers/Snapshot/Detail/BaseDetail.jsx @@ -24,16 +24,15 @@ export class BaseDetail extends Base { const options = [ { label: t('Volume'), - dataIndex: 'volume', - render: (value) => { + dataIndex: 'volume_id', + render: (value, record) => { if (!value) { return '-'; } - const { id, name } = value; const link = this.getLinkRender( 'volumeDetail', - name || id, - { id }, + record.volume_name || value, + { id: value }, { tab: 'snapshot' } ); return link; @@ -41,7 +40,7 @@ export class BaseDetail extends Base { }, ]; return { - title: t('Volume Info'), + title: t('Snapshot Source'), options, }; } diff --git a/src/stores/cinder/snapshot.js b/src/stores/cinder/snapshot.js index 0cf42e3d..f16ab469 100644 --- a/src/stores/cinder/snapshot.js +++ b/src/stores/cinder/snapshot.js @@ -52,11 +52,16 @@ export class SnapshotStore extends Base { return data; } - async detailDidFetch(item) { - const { volume_id } = item; - const { volume } = await this.volumeClient.show(volume_id); - item.volume = volume; - return item; + async detailDidFetch(item, allProjects) { + const params = { + uuid: item.id, + }; + if (allProjects) { + params.all_projects = true; + } + const { volume_snapshots = [] } = await this.listFetchByClient(params); + const { child_volumes = [], volume_name } = volume_snapshots[0] || {}; + return { ...item, child_volumes, volume_name }; } updateParamsSortPage = (params, sortKey, sortOrder) => {