diff --git a/src/components/Tables/Base/Download/index.jsx b/src/components/Tables/Base/Download/index.jsx index 408b8de3..fcbdf6e4 100644 --- a/src/components/Tables/Base/Download/index.jsx +++ b/src/components/Tables/Base/Download/index.jsx @@ -91,11 +91,13 @@ export default class index extends Component { } if (isObject(value)) { if (React.isValidElement(value)) { - return (data[dataIndex] && data[dataIndex].toString()) || '-'; + return [undefined, '', null].includes(data[dataIndex]) + ? '-' + : data[dataIndex].toString(); } return data[dataIndex]; } - return value; + return [undefined, '', null].includes(value) ? '-' : value; }; getColumnData = (data, column) => { diff --git a/src/components/Tables/Base/index.jsx b/src/components/Tables/Base/index.jsx index 5e7676fc..4dcc1a5b 100644 --- a/src/components/Tables/Base/index.jsx +++ b/src/components/Tables/Base/index.jsx @@ -543,6 +543,40 @@ export default class BaseTable extends React.Component { } }; + filterDownloadColumns(columns) { + const { rowKey } = this.props; + const downloadColumns = columns + .filter((it) => !it.hidden) + .map((it) => { + if (it.title.includes('/')) { + const [fTitle, sTitle] = it.title.split('/'); + let sName = sTitle; + if (fTitle.length > 2) { + sName = `${fTitle.split('ID')[0]}${sTitle}`; + } + let fIndex = it.idKey || rowKey; + if ( + it.title.includes(t('Project')) && + it.dataIndex === 'project_name' + ) { + fIndex = 'project_id'; + } + return [ + { + title: fTitle, + dataIndex: fIndex, + }, + { + ...it, + title: sName, + }, + ]; + } + return it; + }); + return [].concat(...downloadColumns); + } + renderBatchActions() { const { batchActions, @@ -717,7 +751,7 @@ export default class BaseTable extends React.Component { return null; } const { total } = pagination; - const downloadColumns = columns.filter((it) => !it.hidden); + const downloadColumns = this.filterDownloadColumns(columns); const props = { datas, columns: downloadColumns, diff --git a/src/pages/storage/containers/Backup/index.jsx b/src/pages/storage/containers/Backup/index.jsx index 73883798..0ac34976 100644 --- a/src/pages/storage/containers/Backup/index.jsx +++ b/src/pages/storage/containers/Backup/index.jsx @@ -12,14 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -import React from 'react'; import { observer, inject } from 'mobx-react'; -import { Link } from 'react-router-dom'; import Base from 'containers/List'; import globalBackupStore, { BackupStore } from 'stores/cinder/backup'; import CreateBackup from 'pages/storage/containers/Volume/actions/CreateBackup'; -import { FolderOutlined, FolderAddOutlined } from '@ant-design/icons'; -import { backupStatus } from 'resources/backup'; import actionConfigs from './actions'; @inject('rootStore') @@ -84,47 +80,26 @@ export default class Backup extends Base { sortKey: 'project_id', }, { - title: t('Size'), - dataIndex: 'size', - isHideable: true, - render: (value) => `${value} GB`, - }, - { - title: t('Status'), - dataIndex: 'status', - render: (value) => backupStatus[value] || value, + title: t('Volume ID/Name'), + dataIndex: 'volume_name', + isName: true, + linkFunc: (value, record) => + `/storage/${this.getUrl('volume')}/detail/${ + record.volume_id + }?tab=backup`, + idKey: 'volume_id', + sortKey: 'volume_id', }, { title: t('Backup Mode'), - dataIndex: 'is_incremental', - isHideable: true, - render: (value) => { - if (value) { - return ( - <> - - {t('Incremental Backup')} - - ); - } - return ( - <> - - {t('Full Backup')} - - ); + dataIndex: 'backup_node', + render: (_, record) => { + const { + metadata: { auto = false }, + } = record; + return auto ? t('Automatic backup') : t('Manual backup'); }, - stringify: (value) => - value ? t('Incremental Backup') : t('Full Backup'), - }, - { - title: t('Volume ID'), - dataIndex: 'volume_id', - render: (value) => ( - - {value} - - ), + sorter: false, }, { title: t('Created At'), @@ -145,10 +120,6 @@ export default class Backup extends Base { label: t('Name'), name: 'name', }, - { - label: t('Volume ID'), - name: 'volume_id', - }, ]; } diff --git a/src/pages/storage/containers/Snapshot/index.jsx b/src/pages/storage/containers/Snapshot/index.jsx index 9b631403..19bae1ff 100644 --- a/src/pages/storage/containers/Snapshot/index.jsx +++ b/src/pages/storage/containers/Snapshot/index.jsx @@ -124,10 +124,6 @@ export default class Snapshots extends Base { }?tab=snapshot`, isHideable: true, sorter: false, - stringify: (value, record) => { - const { volume_name } = record; - return `${volume_name || value.volume_id}`; - }, }, { title: t('Created At'),