21128: disabled trash button during async op Arvados-DCO-1.1-Signed-off-by: Lisa...
authorLisa Knox <lisaknox83@gmail.com>
Mon, 4 Dec 2023 16:45:50 +0000 (11:45 -0500)
committerLisa Knox <lisaknox83@gmail.com>
Mon, 4 Dec 2023 16:45:50 +0000 (11:45 -0500)
src/store/favorites/favorites-actions.ts
src/store/multiselect/multiselect-actions.tsx
src/store/project-panel/project-panel-middleware-service.ts
src/store/public-favorites/public-favorites-actions.ts
src/store/trash-panel/trash-panel-middleware-service.ts
src/store/trash/trash-actions.ts
src/views-components/multiselect-toolbar/ms-menu-actions.ts

index bd4d878ed59d95556033b36a1a144082268c6d97..a1667326324a7b38485acbc5d9f0e3e6743ab869 100644 (file)
@@ -10,6 +10,8 @@ import { checkFavorite } from "./favorites-reducer";
 import { snackbarActions, SnackbarKind } from "../snackbar/snackbar-actions";
 import { ServiceRepository } from "services/services";
 import { progressIndicatorActions } from "store/progress-indicator/progress-indicator-actions";
+import { MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-actions";
+import { addDisabledButton, removeDisabledButton } from "store/multiselect/multiselect-actions";
 
 export const favoritesActions = unionize({
     TOGGLE_FAVORITE: ofType<{ resourceUuid: string }>(),
@@ -26,6 +28,7 @@ export const toggleFavorite = (resource: { uuid: string; name: string }) =>
             return Promise.reject("No user");
         }
         dispatch(progressIndicatorActions.START_WORKING("toggleFavorite"));
+        dispatch<any>(addDisabledButton(MultiSelectMenuActionNames.ADD_TO_FAVORITES))
         dispatch(favoritesActions.TOGGLE_FAVORITE({ resourceUuid: resource.uuid }));
         const isFavorite = checkFavorite(resource.uuid, getState().favorites);
         dispatch(snackbarActions.OPEN_SNACKBAR({
@@ -50,6 +53,7 @@ export const toggleFavorite = (resource: { uuid: string; name: string }) =>
                     hideDuration: 2000,
                     kind: SnackbarKind.SUCCESS
                 }));
+                dispatch<any>(removeDisabledButton(MultiSelectMenuActionNames.ADD_TO_FAVORITES))
                 dispatch(progressIndicatorActions.STOP_WORKING("toggleFavorite"));
             })
             .catch((e: any) => {
index 091d3ef611eddb73bb17ada9d67d198aaeb6cb1e..9b564486f9ab5cb3c80f402775be19f5c4d3b627 100644 (file)
@@ -53,7 +53,7 @@ export const setSelectedUuid = (uuid: string | null) => {
     };
 };
 
-export const setDisabledButton = (buttonName: string) => {
+export const addDisabledButton = (buttonName: string) => {
     return dispatch => {
         dispatch({ type: multiselectActionContants.ADD_DISABLED, payload: buttonName });
     };
@@ -72,6 +72,6 @@ export const multiselectActions = {
     deselectOne,
     toggleOne,
     setSelectedUuid,
-    setDisabledButton,
+    addDisabledButton,
     removeDisabledButton,
 };
index b72058d56e81dd0ed4a42dce663357ffcaea4dd9..08eead97c8b21b8f4da98f3458795061d9893870 100644 (file)
@@ -35,6 +35,8 @@ import { updatePublicFavorites } from "store/public-favorites/public-favorites-a
 import { selectedFieldsOfGroup } from "models/group";
 import { defaultCollectionSelectedFields } from "models/collection";
 import { containerRequestFieldsNoMounts } from "models/container-request";
+import { MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-actions";
+import { removeDisabledButton } from "store/multiselect/multiselect-actions";
 
 export class ProjectPanelMiddlewareService extends DataExplorerMiddlewareService {
     constructor(private services: ServiceRepository, id: string) {
@@ -76,7 +78,10 @@ export class ProjectPanelMiddlewareService extends DataExplorerMiddlewareService
                     api.dispatch(couldNotFetchProjectContents());
                 }
             } finally {
-                if (!background) { api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId())); }
+                if (!background) { 
+                    api.dispatch(progressIndicatorActions.PERSIST_STOP_WORKING(this.getId()));
+                    api.dispatch<any>(removeDisabledButton(MultiSelectMenuActionNames.ADD_TO_TRASH))
+                }
             }
         }
     }
index 7fb087883bf9e6f0cae9d292f988f903ad791f92..5bf5078d30a9a198d77f3e6fd0f40923a168c9db 100644 (file)
@@ -9,7 +9,7 @@ import { checkPublicFavorite } from "./public-favorites-reducer";
 import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions";
 import { ServiceRepository } from "services/services";
 import { progressIndicatorActions } from "store/progress-indicator/progress-indicator-actions";
-import { setDisabledButton, removeDisabledButton } from "store/multiselect/multiselect-actions";
+import { addDisabledButton, removeDisabledButton } from "store/multiselect/multiselect-actions";
 import { MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-actions";
 
 export const publicFavoritesActions = unionize({
@@ -23,7 +23,7 @@ export type PublicFavoritesAction = UnionOf<typeof publicFavoritesActions>;
 export const togglePublicFavorite = (resource: { uuid: string; name: string }) =>
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository): Promise<any> => {
         dispatch(progressIndicatorActions.START_WORKING("togglePublicFavorite"));
-        dispatch<any>(setDisabledButton(MultiSelectMenuActionNames.ADD_TO_PUBLIC_FAVORITES))
+        dispatch<any>(addDisabledButton(MultiSelectMenuActionNames.ADD_TO_PUBLIC_FAVORITES))
         const uuidPrefix = getState().auth.config.uuidPrefix;
         const uuid = `${uuidPrefix}-j7d0g-publicfavorites`;
         dispatch(publicFavoritesActions.TOGGLE_PUBLIC_FAVORITE({ resourceUuid: resource.uuid }));
index d72b6ad7a1ab62ee59c83ce5e765ff6d5177de44..8b760ebb84804cc575989a44c72fd444b62651fd 100644 (file)
@@ -27,7 +27,8 @@ import { serializeResourceTypeFilters } from 'store//resource-type-filters/resou
 import { getDataExplorerColumnFilters } from 'store/data-explorer/data-explorer-middleware-service';
 import { joinFilters } from 'services/api/filter-builder';
 import { CollectionResource } from "models/collection";
-
+import { MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-actions";
+import { removeDisabledButton } from "store/multiselect/multiselect-actions";
 export class TrashPanelMiddlewareService extends DataExplorerMiddlewareService {
     constructor(private services: ServiceRepository, id: string) {
         super(id);
@@ -84,6 +85,7 @@ export class TrashPanelMiddlewareService extends DataExplorerMiddlewareService {
             }));
             api.dispatch(couldNotFetchTrashContents());
         }
+        api.dispatch<any>(removeDisabledButton(MultiSelectMenuActionNames.ADD_TO_TRASH))
     }
 }
 
index 62b669220e68e2e6d3089f878f7fe4e73f29b962..50ac31c8f92d9ebbaab00a0915a11f22970aff66 100644 (file)
@@ -13,6 +13,8 @@ import { sharedWithMePanelActions } from "store/shared-with-me-panel/shared-with
 import { ResourceKind } from "models/resource";
 import { navigateTo, navigateToTrash } from "store/navigation/navigation-action";
 import { matchCollectionRoute, matchSharedWithMeRoute } from "routes/routes";
+import { MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-actions";
+import { addDisabledButton } from "store/multiselect/multiselect-actions";
 
 export const toggleProjectTrashed =
     (uuid: string, ownerUuid: string, isTrashed: boolean, isMulti: boolean) =>
@@ -20,11 +22,12 @@ export const toggleProjectTrashed =
             let errorMessage = "";
             let successMessage = "";
             let untrashedResource;
+            dispatch<any>(addDisabledButton(MultiSelectMenuActionNames.ADD_TO_TRASH))
             try {
                 if (isTrashed) {
                     errorMessage = "Could not restore project from trash";
                     successMessage = "Restored project from trash";
-                    untrashedResource = await services.groupsService.untrash(uuid);
+                     untrashedResource = await services.groupsService.untrash(uuid);
                     dispatch<any>(isMulti || !untrashedResource ? navigateToTrash : navigateTo(uuid));
                     dispatch<any>(activateSidePanelTreeItem(uuid));
                 } else {
@@ -32,7 +35,7 @@ export const toggleProjectTrashed =
                     successMessage = "Added project to trash";
                     await services.groupsService.trash(uuid);
                     dispatch<any>(loadSidePanelTreeProjects(ownerUuid));
-
+                    
                     const { location } = getState().router;
                     if (matchSharedWithMeRoute(location ? location.pathname : "")) {
                         dispatch(sharedWithMePanelActions.REQUEST_ITEMS());
@@ -42,7 +45,7 @@ export const toggleProjectTrashed =
                     }
                 }
                 if (untrashedResource) {
-                    dispatch(
+                        dispatch(
                         snackbarActions.OPEN_SNACKBAR({
                             message: successMessage,
                             hideDuration: 2000,
index e5673453beb080904981d439797224d228158843..b01a5e1733ea06878bb2146d5f5be40708ddebe8 100644 (file)
@@ -20,25 +20,25 @@ import { togglePublicFavorite } from "store/public-favorites/public-favorites-ac
 import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action";
 import { PublicFavoritesState } from 'store/public-favorites/public-favorites-reducer';
 
-export const MultiSelectMenuActionNames: Record<string, string> = {
-    ADD_TO_FAVORITES: 'Add to Favorites',
-    ADD_TO_TRASH: 'Add to Trash',
-    ADD_TO_PUBLIC_FAVORITES: 'Add to public favorites',
-    API_DETAILS: 'API Details',
-    COPY_AND_RERUN_PROCESS: 'Copy and re-run process',
-    COPY_TO_CLIPBOARD: 'Copy to clipboard',
-    DELETE_WORKFLOW: 'Delete Worflow',
-    EDIT_PPROJECT: 'Edit project',
-    FREEZE_PROJECT: 'Freeze Project',
-    MAKE_A_COPY: 'Make a copy',
-    MOVE_TO: 'Move to',
-    NEW_PROJECT: 'New project',
-    OPEN_IN_NEW_TAB: 'Open in new tab',
-    OPEN_W_3RD_PARTY_CLIENT: 'Open with 3rd party client',
-    REMOVE: 'Remove',
-    RUN_WORKFLOW: 'Run Workflow',
-    SHARE: 'Share',
-    VIEW_DETAILS: 'View details',
+export enum MultiSelectMenuActionNames {
+    ADD_TO_FAVORITES = 'Add to Favorites',
+    ADD_TO_TRASH = 'Add to Trash',
+    ADD_TO_PUBLIC_FAVORITES = 'Add to public favorites',
+    API_DETAILS = 'API Details',
+    COPY_AND_RERUN_PROCESS = 'Copy and re-run process',
+    COPY_TO_CLIPBOARD = 'Copy to clipboard',
+    DELETE_WORKFLOW = 'Delete Worflow',
+    EDIT_PPROJECT = 'Edit project',
+    FREEZE_PROJECT = 'Freeze Project',
+    MAKE_A_COPY = 'Make a copy',
+    MOVE_TO = 'Move to',
+    NEW_PROJECT = 'New project',
+    OPEN_IN_NEW_TAB = 'Open in new tab',
+    OPEN_W_3RD_PARTY_CLIENT = 'Open with 3rd party client',
+    REMOVE = 'Remove',
+    RUN_WORKFLOW = 'Run Workflow',
+    SHARE = 'Share',
+    VIEW_DETAILS = 'View details',
 };
 
 export type MultiSelectMenuAction = {