Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display notification after successful snapshot restore #1594

Merged
merged 1 commit into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/components/VmDetails/cards/SnapshotsCard/sagas.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down Expand Up @@ -68,13 +70,21 @@ 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' }))

const result = yield callExternalAction(Api.restoreSnapshot, 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
sjd78 marked this conversation as resolved.
Show resolved Hide resolved
yield put(addUserMessage({ messageDescriptor: { id: 'restoredSnapshot', params: { snapshotName, vmName } }, type: 'SUCCESS' }))
}
}

export default [
Expand Down
1 change: 1 addition & 0 deletions src/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)',
Expand Down