From f71a96348a9bb3715e9b79112cc083054dc8451f Mon Sep 17 00:00:00 2001 From: Scott Dickerson Date: Jun 14 2022 20:15:14 +0000 Subject: Merge pull request #1594 from rszwajko/restoreSnapshot Display notification after successful snapshot restore --- diff --git a/src/components/VmDetails/cards/SnapshotsCard/sagas.js b/src/components/VmDetails/cards/SnapshotsCard/sagas.js index c9163d5..c9256fc 100644 --- a/src/components/VmDetails/cards/SnapshotsCard/sagas.js +++ b/src/components/VmDetails/cards/SnapshotsCard/sagas.js @@ -1,4 +1,4 @@ -import { takeEvery, put } from 'redux-saga/effects' +import { takeEvery, put, select } from 'redux-saga/effects' import Api, { Transforms } from '_/ovirtapi' import { callExternalAction, delay, delayInMsSteps } from '_/sagas/utils' @@ -13,9 +13,11 @@ import { updateVmSnapshot, startActionInProgress, stopActionInProgress, + addUserMessage, } from '_/actions' import { ADD_VM_SNAPSHOT, DELETE_VM_SNAPSHOT, RESTORE_VM_SNAPSHOT } from './constants' +import { toJS } from '_/helpers' function* addVmSnapshot (action) { const { vmId } = action.payload @@ -68,6 +70,10 @@ function* deleteVmSnapshot (action) { function* restoreVmSnapshot (action) { const { vmId, snapshotId } = action.payload + const [{ description: snapshotName } = {}, vmName] = yield select(({ vms }) => [ + toJS(vms.getIn(['vms', vmId, 'snapshots'], [])).find(({ id }) => id === snapshotId), + vms.getIn(['vms', vmId, 'name']), + ]) yield put(addSnapshotRestorePendingTask(vmId, snapshotId)) yield put(startActionInProgress({ vmId, name: 'restoreSnapshot' })) @@ -75,6 +81,10 @@ function* restoreVmSnapshot (action) { yield put(stopActionInProgress({ vmId, name: 'restoreSnapshot', result })) yield put(removeSnapshotRestorePendingTask(vmId, snapshotId)) + if (!result.error) { + // restore is synchronous operation so we can interpret completed operation as success + yield put(addUserMessage({ messageDescriptor: { id: 'restoredSnapshot', params: { snapshotName, vmName } }, type: 'SUCCESS' })) + } } export default [ diff --git a/src/intl/messages.js b/src/intl/messages.js index e7c03f6..7d27d5d 100644 --- a/src/intl/messages.js +++ b/src/intl/messages.js @@ -596,6 +596,7 @@ export const messages: { [messageId: string]: MessageType } = { description: 'Confirmation modal action button label for a Restore operation', }, restoreSnapshot: 'Restore Snapshot?', + restoredSnapshot: 'Finished restoring snapshot {snapshotName} of VM {vmName}.', results: { message: '{total} Results', description: 'Number of filtered fetched VMs (including pools)',