From 4a1c0c64bea3e6ad00d9bcea530f25efbe1c4387 Mon Sep 17 00:00:00 2001 From: Radoslaw Szwajkowski Date: Thu, 14 Jul 2022 12:57:14 +0200 Subject: [PATCH] Lock snapshot during restore operation The snapshot is locked on the backend during the restore but the UI needs to wait until the next refresh to receive this status change. To provide better user experience we can lock the snapshot right after restore is triggered. The next refresh will confirm or clear the status (according to restore operation progress). --- src/components/VmDetails/cards/SnapshotsCard/sagas.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/VmDetails/cards/SnapshotsCard/sagas.js b/src/components/VmDetails/cards/SnapshotsCard/sagas.js index c9256fc4d..3cc84444d 100644 --- a/src/components/VmDetails/cards/SnapshotsCard/sagas.js +++ b/src/components/VmDetails/cards/SnapshotsCard/sagas.js @@ -70,12 +70,16 @@ function* deleteVmSnapshot (action) { function* restoreVmSnapshot (action) { const { vmId, snapshotId } = action.payload - const [{ description: snapshotName } = {}, vmName] = yield select(({ vms }) => [ + const [snapshot = {}, vmName] = yield select(({ vms }) => [ toJS(vms.getIn(['vms', vmId, 'snapshots'], [])).find(({ id }) => id === snapshotId), vms.getIn(['vms', vmId, 'name']), ]) + const { description: snapshotName = '' } = snapshot + yield put(addSnapshotRestorePendingTask(vmId, snapshotId)) yield put(startActionInProgress({ vmId, name: 'restoreSnapshot' })) + // snapshot will be unlocked on the next refresh together with the VM + yield put(updateVmSnapshot({ vmId, snapshot: { ...snapshot, status: 'locked' } })) const result = yield callExternalAction(Api.restoreSnapshot, action)