[arvados] created: 2.7.0-5776-gd6fb6f1ee8

git repository hosting git at public.arvados.org
Mon Jan 8 16:42:14 UTC 2024


        at  d6fb6f1ee88f743332da0c16775f080cba89a019 (commit)


commit d6fb6f1ee88f743332da0c16775f080cba89a019
Author: Lisa Knox <lisaknox83 at gmail.com>
Date:   Mon Jan 8 11:41:57 2024 -0500

    21315: rows now deselect properly, fixed some spelling errors Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>

diff --git a/services/workbench2/src/store/multiselect/multiselect-actions.tsx b/services/workbench2/src/store/multiselect/multiselect-actions.tsx
index a246ddbcc0..cc24ba3dde 100644
--- a/services/workbench2/src/store/multiselect/multiselect-actions.tsx
+++ b/services/workbench2/src/store/multiselect/multiselect-actions.tsx
@@ -12,11 +12,12 @@ import { ServiceRepository } from "services/services";
 import { SnackbarKind } from "store/snackbar/snackbar-actions";
 import { ContextMenuResource } from 'store/context-menu/context-menu-actions';
 
-export const multiselectActionContants = {
+export const multiselectActionConstants = {
     TOGGLE_VISIBLITY: "TOGGLE_VISIBLITY",
     SET_CHECKEDLIST: "SET_CHECKEDLIST",
     SELECT_ONE: 'SELECT_ONE',
     DESELECT_ONE: "DESELECT_ONE",
+    DESELECT_ALL_OTHERS: 'DESELECT_ALL_OTHERS',
     TOGGLE_ONE: 'TOGGLE_ONE',
     SET_SELECTED_UUID: 'SET_SELECTED_UUID',
     ADD_DISABLED: 'ADD_DISABLED',
@@ -46,60 +47,56 @@ export const isExactlyOneSelected = (checkedList: TCheckedList) => {
 
 export const toggleMSToolbar = (isVisible: boolean) => {
     return dispatch => {
-        dispatch({ type: multiselectActionContants.TOGGLE_VISIBLITY, payload: isVisible });
+        dispatch({ type: multiselectActionConstants.TOGGLE_VISIBLITY, payload: isVisible });
     };
 };
 
 export const setCheckedListOnStore = (checkedList: TCheckedList) => {
     return dispatch => {
         dispatch(setSelectedUuid(isExactlyOneSelected(checkedList)))
-        dispatch({ type: multiselectActionContants.SET_CHECKEDLIST, payload: checkedList });
+        dispatch({ type: multiselectActionConstants.SET_CHECKEDLIST, payload: checkedList });
     };
 };
 
 export const selectOne = (uuid: string) => {
     return dispatch => {
-        dispatch({ type: multiselectActionContants.SELECT_ONE, payload: uuid });
+        dispatch({ type: multiselectActionConstants.SELECT_ONE, payload: uuid });
     };
 };
 
 export const deselectOne = (uuid: string) => {
     return dispatch => {
-        dispatch({ type: multiselectActionContants.DESELECT_ONE, payload: uuid });
+        dispatch({ type: multiselectActionConstants.DESELECT_ONE, payload: uuid });
+    };
+};
+
+export const deselectAllOthers = (uuid: string) => {
+    return dispatch => {
+        dispatch({ type: multiselectActionConstants.DESELECT_ALL_OTHERS, payload: uuid });
     };
 };
 
 export const toggleOne = (uuid: string) => {
     return dispatch => {
-        dispatch({ type: multiselectActionContants.TOGGLE_ONE, payload: uuid });
+        dispatch({ type: multiselectActionConstants.TOGGLE_ONE, payload: uuid });
     };
 };
 
 export const setSelectedUuid = (uuid: string | null) => {
     return dispatch => {
-        dispatch({ type: multiselectActionContants.SET_SELECTED_UUID, payload: uuid });
+        dispatch({ type: multiselectActionConstants.SET_SELECTED_UUID, payload: uuid });
     };
 };
 
 export const addDisabledButton = (buttonName: string) => {
     return dispatch => {
-        dispatch({ type: multiselectActionContants.ADD_DISABLED, payload: buttonName });
+        dispatch({ type: multiselectActionConstants.ADD_DISABLED, payload: buttonName });
     };
 };
 
 export const removeDisabledButton = (buttonName: string) => {
     return dispatch => {
-        dispatch({ type: multiselectActionContants.REMOVE_DISABLED, payload: buttonName });
+        dispatch({ type: multiselectActionConstants.REMOVE_DISABLED, payload: buttonName });
     };
 };
 
-export const multiselectActions = {
-    toggleMSToolbar,
-    setCheckedListOnStore,
-    selectOne,
-    deselectOne,
-    toggleOne,
-    setSelectedUuid,
-    addDisabledButton,
-    removeDisabledButton,
-};
diff --git a/services/workbench2/src/store/multiselect/multiselect-reducer.tsx b/services/workbench2/src/store/multiselect/multiselect-reducer.tsx
index 26b853933c..9bcb46d018 100644
--- a/services/workbench2/src/store/multiselect/multiselect-reducer.tsx
+++ b/services/workbench2/src/store/multiselect/multiselect-reducer.tsx
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { multiselectActionContants } from "./multiselect-actions";
+import { multiselectActionConstants } from "./multiselect-actions";
 import { TCheckedList } from "components/data-table/data-table";
 
 type MultiselectToolbarState = {
@@ -19,7 +19,21 @@ const multiselectToolbarInitialState = {
     disabledButtons: []
 };
 
-const { TOGGLE_VISIBLITY, SET_CHECKEDLIST, SELECT_ONE, DESELECT_ONE, TOGGLE_ONE, SET_SELECTED_UUID, ADD_DISABLED, REMOVE_DISABLED } = multiselectActionContants;
+const uncheckAllOthers = (inputList: TCheckedList, uuid: string) => {
+    const checkedlist = {...inputList}
+    for (const key in checkedlist) {
+        if (key !== uuid) checkedlist[key] = false;
+    }
+    return checkedlist;
+};
+
+const toggleOneCheck = (inputList: TCheckedList, uuid: string)=>{
+    const checkedlist = { ...inputList };
+    const isOnlyOneSelected = Object.values(checkedlist).filter(x => x === true).length === 1;
+    return { ...inputList, [uuid]: (checkedlist[uuid] && checkedlist[uuid] === true) && isOnlyOneSelected ? false : true };
+}
+
+const { TOGGLE_VISIBLITY, SET_CHECKEDLIST, SELECT_ONE, DESELECT_ONE, DESELECT_ALL_OTHERS, TOGGLE_ONE, SET_SELECTED_UUID, ADD_DISABLED, REMOVE_DISABLED } = multiselectActionConstants;
 
 export const multiselectReducer = (state: MultiselectToolbarState = multiselectToolbarInitialState, action) => {
     switch (action.type) {
@@ -31,8 +45,10 @@ export const multiselectReducer = (state: MultiselectToolbarState = multiselectT
             return { ...state, checkedList: { ...state.checkedList, [action.payload]: true } };
         case DESELECT_ONE:
             return { ...state, checkedList: { ...state.checkedList, [action.payload]: false } };
+        case DESELECT_ALL_OTHERS:
+            return { ...state, checkedList: uncheckAllOthers(state.checkedList, action.payload) };
         case TOGGLE_ONE:
-            return { ...state, checkedList: { ...state.checkedList, [action.payload]: !state.checkedList[action.payload] } };
+            return { ...state, checkedList: toggleOneCheck(state.checkedList, action.payload) };
         case SET_SELECTED_UUID:
             return {...state, selectedUuid: action.payload || ''}
         case ADD_DISABLED:
diff --git a/services/workbench2/src/store/workbench/workbench-actions.ts b/services/workbench2/src/store/workbench/workbench-actions.ts
index b286186aba..ed05c0b172 100644
--- a/services/workbench2/src/store/workbench/workbench-actions.ts
+++ b/services/workbench2/src/store/workbench/workbench-actions.ts
@@ -101,7 +101,7 @@ import { loadAllProcessesPanel, allProcessesPanelActions } from "../all-processe
 import { allProcessesPanelColumns } from "views/all-processes-panel/all-processes-panel";
 import { userProfileGroupsColumns } from "views/user-profile-panel/user-profile-panel-root";
 import { selectedToArray, selectedToKindSet } from "components/multiselect-toolbar/MultiselectToolbar";
-import { multiselectActions } from "store/multiselect/multiselect-actions";
+import { deselectOne } from "store/multiselect/multiselect-actions";
 import { treePickerActions } from "store/tree-picker/tree-picker-actions";
 
 export const WORKBENCH_LOADING_SCREEN = "workbenchLoadingScreen";
@@ -477,7 +477,7 @@ export const copyCollection = (data: CopyFormDialogData) => async (dispatch: Dis
                         link: collection.ownerUuid,
                     })
                 );
-                dispatch<any>(multiselectActions.deselectOne(copyToProject.uuid));
+                dispatch<any>(deselectOne(copyToProject.uuid));
             }
         } catch (e) {
             dispatch(
diff --git a/services/workbench2/src/views/favorite-panel/favorite-panel.tsx b/services/workbench2/src/views/favorite-panel/favorite-panel.tsx
index aa4f2c1a20..2409870a2d 100644
--- a/services/workbench2/src/views/favorite-panel/favorite-panel.tsx
+++ b/services/workbench2/src/views/favorite-panel/favorite-panel.tsx
@@ -38,7 +38,7 @@ import { GroupClass, GroupResource } from 'models/group';
 import { getProperty } from 'store/properties/properties';
 import { PROJECT_PANEL_CURRENT_UUID } from 'store/project-panel/project-panel-action';
 import { CollectionResource } from 'models/collection';
-import { toggleOne } from 'store/multiselect/multiselect-actions';
+import { toggleOne, deselectAllOthers } from 'store/multiselect/multiselect-actions';
 
 type CssRules = "toolbar" | "button" | "root";
 
@@ -173,6 +173,7 @@ export const FavoritePanel = withStyles(styles)(
 
             handleRowClick = (uuid: string) => {
                 this.props.dispatch<any>(toggleOne(uuid))
+                this.props.dispatch<any>(deselectAllOthers(uuid))
                 this.props.dispatch<any>(loadDetailsPanel(uuid));
             }
 
diff --git a/services/workbench2/src/views/project-panel/project-panel.tsx b/services/workbench2/src/views/project-panel/project-panel.tsx
index efaf53eb49..83b6c8ba47 100644
--- a/services/workbench2/src/views/project-panel/project-panel.tsx
+++ b/services/workbench2/src/views/project-panel/project-panel.tsx
@@ -52,7 +52,7 @@ import { CollectionResource } from 'models/collection';
 import { resourceIsFrozen } from 'common/frozen-resources';
 import { ProjectResource } from 'models/project';
 import { NotFoundView } from 'views/not-found-panel/not-found-panel';
-import { toggleOne } from 'store/multiselect/multiselect-actions';
+import { deselectAllOthers, toggleOne } from 'store/multiselect/multiselect-actions';
 
 type CssRules = 'root' | 'button';
 
@@ -325,6 +325,7 @@ export const ProjectPanel = withStyles(styles)(
 
             handleRowClick = (uuid: string) => {
                 this.props.dispatch<any>(toggleOne(uuid))
+                this.props.dispatch<any>(deselectAllOthers(uuid))
                 this.props.dispatch<any>(loadDetailsPanel(uuid));
             };
         }
diff --git a/services/workbench2/src/views/public-favorites-panel/public-favorites-panel.tsx b/services/workbench2/src/views/public-favorites-panel/public-favorites-panel.tsx
index 5cb10c4c66..a0c4675f74 100644
--- a/services/workbench2/src/views/public-favorites-panel/public-favorites-panel.tsx
+++ b/services/workbench2/src/views/public-favorites-panel/public-favorites-panel.tsx
@@ -36,7 +36,7 @@ import { PublicFavoritesState } from 'store/public-favorites/public-favorites-re
 import { getResource, ResourcesState } from 'store/resources/resources';
 import { GroupContentsResource } from 'services/groups-service/groups-service';
 import { CollectionResource } from 'models/collection';
-import { toggleOne } from 'store/multiselect/multiselect-actions';
+import { toggleOne, deselectAllOthers } from 'store/multiselect/multiselect-actions';
 
 type CssRules = "toolbar" | "button" | "root";
 
@@ -147,6 +147,7 @@ const mapDispatchToProps = (dispatch: Dispatch): PublicFavoritePanelActionProps
     onDialogOpen: (ownerUuid: string) => { return; },
     onItemClick: (uuid: string) => {
                 dispatch<any>(toggleOne(uuid))
+                dispatch<any>(deselectAllOthers(uuid))
                 dispatch<any>(loadDetailsPanel(uuid));
     },
     onItemDoubleClick: uuid => {
diff --git a/services/workbench2/src/views/search-results-panel/search-results-panel.tsx b/services/workbench2/src/views/search-results-panel/search-results-panel.tsx
index 320e85cb99..0b69ff246a 100644
--- a/services/workbench2/src/views/search-results-panel/search-results-panel.tsx
+++ b/services/workbench2/src/views/search-results-panel/search-results-panel.tsx
@@ -13,7 +13,7 @@ import { SearchBarAdvancedFormData } from 'models/search-bar';
 import { User } from "models/user";
 import { Config } from 'common/config';
 import { Session } from "models/session";
-import { toggleOne } from "store/multiselect/multiselect-actions";
+import { toggleOne, deselectAllOthers } from "store/multiselect/multiselect-actions";
 
 export interface SearchResultsPanelDataProps {
     data: SearchBarAdvancedFormData;
@@ -48,6 +48,7 @@ const mapDispatchToProps = (dispatch: Dispatch): SearchResultsPanelActionProps =
     onDialogOpen: (ownerUuid: string) => { return; },
     onItemClick: (resourceUuid: string) => {
         dispatch<any>(toggleOne(resourceUuid))
+        dispatch<any>(deselectAllOthers(resourceUuid))
         dispatch<any>(loadDetailsPanel(resourceUuid));
     },
     onItemDoubleClick: uuid => {
diff --git a/services/workbench2/src/views/shared-with-me-panel/shared-with-me-panel.tsx b/services/workbench2/src/views/shared-with-me-panel/shared-with-me-panel.tsx
index f3f827d146..e8f80d6774 100644
--- a/services/workbench2/src/views/shared-with-me-panel/shared-with-me-panel.tsx
+++ b/services/workbench2/src/views/shared-with-me-panel/shared-with-me-panel.tsx
@@ -41,7 +41,7 @@ import {
 } from 'views-components/data-explorer/renderers';
 import { DataTableFilterItem } from 'components/data-table-filters/data-table-filters';
 import { GroupContentsResource } from 'services/groups-service/groups-service';
-import { toggleOne } from 'store/multiselect/multiselect-actions';
+import { toggleOne, deselectAllOthers } from 'store/multiselect/multiselect-actions';
 import { DataColumns } from 'components/data-table/data-table';
 import { ContainerRequestState } from 'models/container-request';
 import { ProjectResource } from 'models/project';
@@ -282,6 +282,7 @@ export const SharedWithMePanel = withStyles(styles)(
 
             handleRowClick = (uuid: string) => {
                 this.props.dispatch<any>(toggleOne(uuid))
+                this.props.dispatch<any>(deselectAllOthers(uuid))
                 this.props.dispatch<any>(loadDetailsPanel(uuid));
             }
         }
diff --git a/services/workbench2/src/views/subprocess-panel/subprocess-panel.tsx b/services/workbench2/src/views/subprocess-panel/subprocess-panel.tsx
index 684e1fd2b9..a4eb5e67a7 100644
--- a/services/workbench2/src/views/subprocess-panel/subprocess-panel.tsx
+++ b/services/workbench2/src/views/subprocess-panel/subprocess-panel.tsx
@@ -10,7 +10,7 @@ import { RootState } from "store/store";
 import { navigateTo } from "store/navigation/navigation-action";
 import { loadDetailsPanel } from "store/details-panel/details-panel-action";
 import { getProcess } from "store/processes/process";
-import { toggleOne } from 'store/multiselect/multiselect-actions';
+import { toggleOne, deselectAllOthers } from 'store/multiselect/multiselect-actions';
 
 const mapDispatchToProps = (dispatch: Dispatch): SubprocessPanelActionProps => ({
     onContextMenu: (event, resourceUuid, resources) => {
@@ -21,6 +21,7 @@ const mapDispatchToProps = (dispatch: Dispatch): SubprocessPanelActionProps => (
     },
     onRowClick: (uuid: string) => {
         dispatch<any>(toggleOne(uuid))
+        dispatch<any>(deselectAllOthers(uuid))
         dispatch<any>(loadDetailsPanel(uuid));
     },
     onItemDoubleClick: uuid => {
diff --git a/services/workbench2/src/views/trash-panel/trash-panel.tsx b/services/workbench2/src/views/trash-panel/trash-panel.tsx
index 2a96ffe0d7..ac11bb7195 100644
--- a/services/workbench2/src/views/trash-panel/trash-panel.tsx
+++ b/services/workbench2/src/views/trash-panel/trash-panel.tsx
@@ -35,7 +35,7 @@ import {
     getTrashPanelTypeFilters
 } from 'store/resource-type-filters/resource-type-filters';
 import { CollectionResource } from 'models/collection';
-import { toggleOne } from 'store/multiselect/multiselect-actions';
+import { toggleOne, deselectAllOthers } from 'store/multiselect/multiselect-actions';
 
 type CssRules = "toolbar" | "button" | "root";
 
@@ -180,6 +180,7 @@ export const TrashPanel = withStyles(styles)(
 
             handleRowClick = (uuid: string) => {
                 this.props.dispatch<any>(toggleOne(uuid))
+                this.props.dispatch<any>(deselectAllOthers(uuid))
                 this.props.dispatch<any>(loadDetailsPanel(uuid));
             }
         }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list