Skip to content

Commit 88b1d86

Browse files
committed
Display notification after successful snapshot restore
1 parent d24c6c8 commit 88b1d86

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

src/components/VmDetails/cards/SnapshotsCard/actions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ export function addVmSnapshot ({ vmId, snapshot }) {
2020
}
2121
}
2222

23-
export function restoreVmSnapshot ({ vmId, snapshotId }) {
23+
export function restoreVmSnapshot ({ vmId, vmName, snapshotId, snapshotName }) {
2424
return {
2525
type: RESTORE_VM_SNAPSHOT,
2626
payload: {
2727
vmId,
2828
snapshotId,
29+
vmName,
30+
snapshotName,
2931
},
3032
}
3133
}

src/components/VmDetails/cards/SnapshotsCard/sagas.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { takeEvery, put } from 'redux-saga/effects'
1+
import { takeEvery, put, select } from 'redux-saga/effects'
22

33
import Api, { Transforms } from '_/ovirtapi'
44
import { callExternalAction, delay, delayInMsSteps } from '_/sagas/utils'
@@ -13,9 +13,11 @@ import {
1313
updateVmSnapshot,
1414
startActionInProgress,
1515
stopActionInProgress,
16+
addUserMessage,
1617
} from '_/actions'
1718

1819
import { ADD_VM_SNAPSHOT, DELETE_VM_SNAPSHOT, RESTORE_VM_SNAPSHOT } from './constants'
20+
import { toJS } from '_/helpers'
1921

2022
function* addVmSnapshot (action) {
2123
const { vmId } = action.payload
@@ -68,13 +70,21 @@ function* deleteVmSnapshot (action) {
6870

6971
function* restoreVmSnapshot (action) {
7072
const { vmId, snapshotId } = action.payload
73+
const [{ description: snapshotName } = {}, vmName] = yield select(({ vms }) => [
74+
toJS(vms.getIn(['vms', vmId, 'snapshots'], [])).find(({ id }) => id === snapshotId),
75+
vms.getIn(['vms', vmId, 'name']),
76+
])
7177
yield put(addSnapshotRestorePendingTask(vmId, snapshotId))
7278
yield put(startActionInProgress({ vmId, name: 'restoreSnapshot' }))
7379

7480
const result = yield callExternalAction(Api.restoreSnapshot, action)
7581

7682
yield put(stopActionInProgress({ vmId, name: 'restoreSnapshot', result }))
7783
yield put(removeSnapshotRestorePendingTask(vmId, snapshotId))
84+
if (!result.error) {
85+
// restore is synchronous operation so we can interpret completed operation as success
86+
yield put(addUserMessage({ messageDescriptor: { id: 'restoredSnapshot', params: { snapshotName, vmName } }, type: 'SUCCESS' }))
87+
}
7888
}
7989

8090
export default [

src/intl/messages.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ export const messages: { [messageId: string]: MessageType } = {
609609
description: 'Confirmation modal action button label for a Restore operation',
610610
},
611611
restoreSnapshot: 'Restore Snapshot?',
612+
restoredSnapshot: 'Finished restoring snapshot {snapshotName} of VM {vmName}',
612613
results: {
613614
message: '{total} Results',
614615
description: 'Number of filtered fetched VMs (including pools)',

0 commit comments

Comments
 (0)