17098: Improves wording on the "Restore version" action.
[arvados-workbench2.git] / src / store / collections / collection-version-actions.ts
index 007dedcdf45d95c594bdceb11b44167cf8760f74..5bf474979a92178c8a042f73453f0140e9dd8e65 100644 (file)
@@ -8,8 +8,24 @@ import { ServiceRepository } from '~/services/services';
 import { snackbarActions, SnackbarKind } from "../snackbar/snackbar-actions";
 import { resourcesActions } from "../resources/resources-actions";
 import { navigateTo } from "../navigation/navigation-action";
+import { dialogActions } from "../dialog/dialog-actions";
 
-export const recoverVersion = (resourceUuid: string) =>
+export const COLLECTION_RESTORE_VERSION_DIALOG = 'collectionRestoreVersionDialog';
+
+export const openRestoreCollectionVersionDialog = (uuid: string) =>
+    (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+        dispatch(dialogActions.OPEN_DIALOG({
+            id: COLLECTION_RESTORE_VERSION_DIALOG,
+            data: {
+                title: 'Restore version',
+                text: "This will copy the content of the selected version to the head. To make a new collection with the content of the selected version, use 'Make a copy' instead.",
+                confirmButtonLabel: 'Restore',
+                uuid
+            }
+        }));
+    };
+
+export const restoreVersion = (resourceUuid: string) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         try {
             // Request que entire record because stored old versions usually
@@ -24,7 +40,7 @@ export const recoverVersion = (resourceUuid: string) =>
             dispatch<any>(navigateTo(headVersion.uuid));
         } catch (e) {
             dispatch(snackbarActions.OPEN_SNACKBAR({
-                message: `Couldn't recover version: ${e.errors[0]}`,
+                message: `Couldn't restore version: ${e.errors[0]}`,
                 hideDuration: 2000,
                 kind: SnackbarKind.ERROR
             }));