diff --git a/src/models/backup.js b/src/models/backup.js index 9415397d..e8060faa 100644 --- a/src/models/backup.js +++ b/src/models/backup.js @@ -1,4 +1,4 @@ -import { query, queryBackupList, execAction, restore, deleteBackup, createVolume, deleteAllBackups, getNodeTags, getDiskTags, queryTarget } from '../services/backup' +import { query, queryBackupList, execAction, restore, deleteBackup, syncBackupVolume, syncAllBackupVolumes, createVolume, deleteAllBackups, getNodeTags, getDiskTags, queryTarget } from '../services/backup' import { message } from 'antd' import { wsChanges } from '../utils/websocket' import queryString from 'query-string' @@ -246,6 +246,23 @@ export default { const search = yield select(store => { return store.backup.search }) yield put({ type: 'query', payload: { ...search } }) }, + *syncBackupVolume({ + payload, + }, { call }) { + const backVolName = payload.name + const resp = yield call(syncBackupVolume, backVolName) + if (resp && resp.status === 200) { + message.success(`Successfully trigger backup volume ${backVolName} synchronization`, 5) + } + }, + *syncAllBackupVolumes({ + // eslint-disable-next-line no-unused-vars + _payload }, { call }) { + const resp = yield call(syncAllBackupVolumes) + if (resp && resp.status === 200) { + message.success('Successfully trigger all backup volumes synchronization', 5) + } + }, *bulkCreateVolume({ payload, }, { call, put, select }) { diff --git a/src/routes/backup/BackupBulkActions.js b/src/routes/backup/BackupBulkActions.js index d791e7bf..1a750081 100644 --- a/src/routes/backup/BackupBulkActions.js +++ b/src/routes/backup/BackupBulkActions.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types' import { Button } from 'antd' import style from './BackupBulkActions.less' -function bulkActions({ selectedRows, restoreLatestBackup, showBulkCreateDisasterRecoveryVolume }) { +function bulkActions({ selectedRows, backupVolumes, restoreLatestBackup, showBulkCreateDisasterRecoveryVolume, syncAllBackupVolumes }) { const handleClick = (action) => { switch (action) { case 'restoreLatestBackup': @@ -12,6 +12,9 @@ function bulkActions({ selectedRows, restoreLatestBackup, showBulkCreateDisaster case 'bulkCreateDisasterRecoveryVolume': showBulkCreateDisasterRecoveryVolume(selectedRows) break + case 'syncAllBackupVolumes': + syncAllBackupVolumes() + break default: } } @@ -19,6 +22,7 @@ function bulkActions({ selectedRows, restoreLatestBackup, showBulkCreateDisaster const allActions = [ { key: 'restoreLatestBackup', name: 'Restore Latest Backup', disabled() { return selectedRows.length === 0 || selectedRows.some(record => !record.lastBackupName || (record.messages && record.messages.error)) } }, { key: 'bulkCreateDisasterRecoveryVolume', name: 'Create Disaster Recovery Volume', disabled() { return selectedRows.length === 0 || selectedRows.some(record => !record.lastBackupName || (record.messages && record.messages.error)) } }, + { key: 'syncAllBackupVolumes', name: 'Sync All Backup Volumes', disabled() { return backupVolumes.length === 0 } }, ] return ( @@ -37,6 +41,7 @@ function bulkActions({ selectedRows, restoreLatestBackup, showBulkCreateDisaster bulkActions.propTypes = { selectedRows: PropTypes.array, + backupVolumes: PropTypes.array, restoreLatestBackup: PropTypes.func, showBulkCreateDisasterRecoveryVolume: PropTypes.func, } diff --git a/src/routes/backup/BackupVolumeList.js b/src/routes/backup/BackupVolumeList.js index 6232b5b3..4dd8feca 100644 --- a/src/routes/backup/BackupVolumeList.js +++ b/src/routes/backup/BackupVolumeList.js @@ -87,6 +87,8 @@ class List extends React.Component { this.props.DeleteAllBackups(record) } else if (e.key === 'restoreLatestBackup') { this.props.restoreLatestBackup(record) + } else if (e.key === 'syncBackupVolume') { + this.props.syncBackupVolume(record) } else if (e.key === 'backingImageInfo') { this.props.showBackingImageInfo(record) } @@ -248,6 +250,7 @@ class List extends React.Component {