[arvados] updated: 2.7.0-6050-gd53fb37a98

git repository hosting git at public.arvados.org
Fri Mar 15 18:59:56 UTC 2024


Summary of changes:
 .../src/components/data-explorer/data-explorer.tsx | 10 +++---
 .../src/components/data-table/data-table.tsx       | 21 +++++++-----
 .../multiselect-toolbar/MultiselectToolbar.tsx     | 21 ++++++------
 .../src/store/multiselect/multiselect-reducer.tsx  |  4 ---
 .../selected-resource/selected-resource-actions.ts |  2 +-
 services/workbench2/src/store/store.ts             |  2 +-
 .../data-explorer/data-explorer.tsx                | 37 ++++------------------
 .../details-panel/details-panel.tsx                | 28 ++--------------
 8 files changed, 40 insertions(+), 85 deletions(-)

       via  d53fb37a98b7d23cfefd6fe191ee182cdbf9ec91 (commit)
      from  16d131de262bbe7f5f04c2e66f906e5720caa7ed (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit d53fb37a98b7d23cfefd6fe191ee182cdbf9ec91
Author: Lisa Knox <lisaknox83 at gmail.com>
Date:   Fri Mar 15 14:59:50 2024 -0400

    21224: plugged global select into toolbarArvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox at curii.com>

diff --git a/services/workbench2/src/components/data-explorer/data-explorer.tsx b/services/workbench2/src/components/data-explorer/data-explorer.tsx
index c1b2fbe587..2d5a0b240e 100644
--- a/services/workbench2/src/components/data-explorer/data-explorer.tsx
+++ b/services/workbench2/src/components/data-explorer/data-explorer.tsx
@@ -95,7 +95,8 @@ interface DataExplorerDataProps<T> {
     title?: React.ReactNode;
     progressBar?: React.ReactNode;
     paperKey?: string;
-    currentItemUuid: string;
+    currentRouteUuid: string;
+    selectedResourceUuid: string;
     elementPath?: string;
     isMSToolbarVisible: boolean;
     checkedList: TCheckedList;
@@ -116,7 +117,7 @@ interface DataExplorerActionProps<T> {
     extractKey?: (item: T) => React.Key;
     toggleMSToolbar: (isVisible: boolean) => void;
     setCheckedListOnStore: (checkedList: TCheckedList) => void;
-    setSelectedUuid: (checkedList: TCheckedList) => void;
+    setSelectedUuid: (uuid: string) => void;
 }
 
 type DataExplorerProps<T> = DataExplorerDataProps<T> & DataExplorerActionProps<T> & WithStyles<CssRules> & MPVPanelProps;
@@ -197,7 +198,7 @@ export const DataExplorer = withStyles(styles)(
                 hideSearchInput,
                 paperKey,
                 fetchMode,
-                currentItemUuid,
+                selectedResourceUuid,
                 currentRoute,
                 title,
                 progressBar,
@@ -320,12 +321,13 @@ export const DataExplorer = withStyles(styles)(
                                 working={this.state.showLoading}
                                 defaultViewIcon={defaultViewIcon}
                                 defaultViewMessages={defaultViewMessages}
-                                currentItemUuid={currentItemUuid}
                                 currentRoute={paperKey}
                                 toggleMSToolbar={toggleMSToolbar}
                                 setCheckedListOnStore={setCheckedListOnStore}
                                 checkedList={checkedList}
+                                selectedResourceUuid={selectedResourceUuid}
                                 setSelectedUuid={this.props.setSelectedUuid}
+                                currentRouteUuid={this.props.currentRouteUuid}
                             />
                         </Grid>
                         <Grid
diff --git a/services/workbench2/src/components/data-table/data-table.tsx b/services/workbench2/src/components/data-table/data-table.tsx
index 2edd736b78..6808447df3 100644
--- a/services/workbench2/src/components/data-table/data-table.tsx
+++ b/services/workbench2/src/components/data-table/data-table.tsx
@@ -50,12 +50,13 @@ export interface DataTableDataProps<I> {
     working?: boolean;
     defaultViewIcon?: IconType;
     defaultViewMessages?: string[];
-    currentItemUuid?: string;
-    currentRoute?: string;
     toggleMSToolbar: (isVisible: boolean) => void;
     setCheckedListOnStore: (checkedList: TCheckedList) => void;
+    currentRoute?: string;
+    currentRouteUuid: string;
     checkedList: TCheckedList;
-    setSelectedUuid: (checkedList: TCheckedList) => void;
+    selectedResourceUuid: string;
+    setSelectedUuid: (uuid: string) => void;
 }
 
 type CssRules =
@@ -163,8 +164,9 @@ export const DataTable = withStyles(styles)(
         }
 
         componentDidUpdate(prevProps: Readonly<DataTableProps<T>>, prevState: DataTableState) {
-            const { items, setCheckedListOnStore } = this.props;
+            const { items, currentRouteUuid, setCheckedListOnStore } = this.props;
             const { isSelected } = this.state;
+            const singleSelected = isExactlyOneSelected(this.props.checkedList);
             if (prevProps.items !== items) {
                 if (isSelected === true) this.setState({ isSelected: false });
                 if (items.length) this.initializeCheckedList(items);
@@ -173,8 +175,11 @@ export const DataTable = withStyles(styles)(
             if (prevProps.currentRoute !== this.props.currentRoute) {
                 this.initializeCheckedList([])
             }
-            if (isExactlyOneSelected(prevProps.checkedList) !== isExactlyOneSelected(this.props.checkedList)) {
-                this.props.setSelectedUuid(this.props.checkedList)
+            if (singleSelected && singleSelected !== isExactlyOneSelected(prevProps.checkedList)) {
+                this.props.setSelectedUuid(singleSelected);
+            }
+            if (!singleSelected) {
+                this.props.setSelectedUuid(currentRouteUuid);
             }
         }
 
@@ -401,7 +406,7 @@ export const DataTable = withStyles(styles)(
         );
 
         renderBodyRow = (item: any, index: number) => {
-            const { onRowClick, onRowDoubleClick, extractKey, classes, currentItemUuid, currentRoute } = this.props;
+            const { onRowClick, onRowDoubleClick, extractKey, classes, selectedResourceUuid, currentRoute } = this.props;
             return (
                 <TableRow
                     data-cy={'data-table-row'}
@@ -410,7 +415,7 @@ export const DataTable = withStyles(styles)(
                     onClick={event => onRowClick && onRowClick(event, item)}
                     onContextMenu={this.handleRowContextMenu(item)}
                     onDoubleClick={event => onRowDoubleClick && onRowDoubleClick(event, item)}
-                    selected={item === currentItemUuid}>
+                    selected={item === selectedResourceUuid}>
                     {this.mapVisibleColumns((column, index) => (
                         <TableCell
                             key={column.key || index}
diff --git a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx
index 82c6f1bdc4..2a4f3f09e3 100644
--- a/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx
+++ b/services/workbench2/src/components/multiselect-toolbar/MultiselectToolbar.tsx
@@ -76,7 +76,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 
 export type MultiselectToolbarProps = {
     checkedList: TCheckedList;
-    selectedResource: string | null;
+    selectedResourceUuid: string | null;
     iconProps: IconProps
     user: User | null
     disabledButtons: Set<string>
@@ -96,8 +96,8 @@ export const MultiselectToolbar = connect(
     mapDispatchToProps
 )(
     withStyles(styles)((props: MultiselectToolbarProps & WithStyles<CssRules>) => {
-        const { classes, checkedList, iconProps, user, disabledButtons, selectedResource, location } = props;
-        const singleResourceKind = selectedResource ? [resourceToMsResourceKind(selectedResource, iconProps.resources, user)] : null
+        const { classes, checkedList, iconProps, user, disabledButtons, selectedResourceUuid, location } = props;
+        const singleResourceKind = selectedResourceUuid ? [resourceToMsResourceKind(selectedResourceUuid, iconProps.resources, user)] : null
         const currentResourceKinds = singleResourceKind ? singleResourceKind : Array.from(selectedToKindSet(checkedList));
         const currentPathIsTrash = location.includes("/trash");
         const [isTransitioning, setIsTransitioning] = useState(false);
@@ -122,7 +122,7 @@ export const MultiselectToolbar = connect(
             currentPathIsTrash && selectedToKindSet(checkedList).size
                 ? [msToggleTrashAction]
                 : selectActionsByKind(currentResourceKinds as string[], multiselectActionsFilters).filter((action) =>
-                        selectedResource === null ? action.isForMulti : true
+                        selectedResourceUuid === null ? action.isForMulti : true
                     );
 
         return (
@@ -140,7 +140,7 @@ export const MultiselectToolbar = connect(
                                 <Tooltip
                                     className={classes.button}
                                     data-targetid={name}
-                                    title={currentPathIsTrash || (useAlts && useAlts(selectedResource, iconProps)) ? altName : name}
+                                    title={currentPathIsTrash || (useAlts && useAlts(selectedResourceUuid, iconProps)) ? altName : name}
                                     key={i}
                                     disableFocusListener
                                     >
@@ -148,10 +148,10 @@ export const MultiselectToolbar = connect(
                                         <IconButton
                                             data-cy='multiselect-button'
                                             disabled={disabledButtons.has(name)}
-                                            onClick={() => props.executeMulti(action, selectedResource, checkedList, iconProps.resources)}
+                                            onClick={() => props.executeMulti(action, selectedResourceUuid, checkedList, iconProps.resources)}
                                             className={classes.icon}
                                         >
-                                            {currentPathIsTrash || (useAlts && useAlts(selectedResource, iconProps)) ? altIcon && altIcon({}) : icon({})}
+                                            {currentPathIsTrash || (useAlts && useAlts(selectedResourceUuid, iconProps)) ? altIcon && altIcon({}) : icon({})}
                                         </IconButton>
                                     </span>
                                 </Tooltip>
@@ -167,8 +167,7 @@ export const MultiselectToolbar = connect(
                                         <IconButton
                                             data-cy='multiselect-button'
                                             onClick={() => {
-                                                console.log('executing action', action.name, 'with checkedList', checkedList, 'and iconProps', iconProps.resources)
-                                                props.executeMulti(action, selectedResource, checkedList, iconProps.resources)}}
+                                                props.executeMulti(action, selectedResourceUuid, checkedList, iconProps.resources)}}
                                             className={classes.icon}
                                         >
                                             {action.icon({})}
@@ -328,13 +327,13 @@ function selectActionsByKind(currentResourceKinds: Array<string>, filterSet: TMu
 
 //--------------------------------------------------//
 
-function mapStateToProps({auth, multiselect, resources, favorites, publicFavorites, selectedResource}: RootState) {
+function mapStateToProps({auth, multiselect, resources, favorites, publicFavorites, selectedResourceUuid}: RootState) {
     return {
         checkedList: multiselect.checkedList as TCheckedList,
         user: auth && auth.user ? auth.user : null,
         disabledButtons: new Set<string>(multiselect.disabledButtons),
         auth,
-        selectedResource,
+        selectedResourceUuid,
         location: window.location.pathname,
         iconProps: {
             resources,
diff --git a/services/workbench2/src/store/multiselect/multiselect-reducer.tsx b/services/workbench2/src/store/multiselect/multiselect-reducer.tsx
index 39847f331f..4775beb184 100644
--- a/services/workbench2/src/store/multiselect/multiselect-reducer.tsx
+++ b/services/workbench2/src/store/multiselect/multiselect-reducer.tsx
@@ -8,14 +8,12 @@ import { TCheckedList } from "components/data-table/data-table";
 export type MultiselectToolbarState = {
     isVisible: boolean;
     checkedList: TCheckedList;
-    selectedUuid: string;
     disabledButtons: string[];
 };
 
 const multiselectToolbarInitialState = {
     isVisible: false,
     checkedList: {},
-    selectedUuid: '',
     disabledButtons: []
 };
 
@@ -49,8 +47,6 @@ export const multiselectReducer = (state: MultiselectToolbarState = multiselectT
             return { ...state, checkedList: uncheckAllOthers(state.checkedList, action.payload) };
         case TOGGLE_ONE:
             return { ...state, checkedList: toggleOneCheck(state.checkedList, action.payload) };
-        case SET_SELECTED_UUID:
-            return {...state, selectedUuid: action.payload || ''}
         case ADD_DISABLED:
             return { ...state, disabledButtons: [...state.disabledButtons, action.payload]}
         case REMOVE_DISABLED:
diff --git a/services/workbench2/src/store/selected-resource/selected-resource-actions.ts b/services/workbench2/src/store/selected-resource/selected-resource-actions.ts
index 0b119598c1..0c72cedf82 100644
--- a/services/workbench2/src/store/selected-resource/selected-resource-actions.ts
+++ b/services/workbench2/src/store/selected-resource/selected-resource-actions.ts
@@ -11,7 +11,7 @@ type SelectedResourceAction = {
     payload: string;
 };
 
-export const setSelectedResource = (resourceUuid: string): SelectedResourceAction => ({
+export const setSelectedResourceUuid = (resourceUuid: string): SelectedResourceAction => ({
     type: selectedResourceActions.SET_SELECTED_RESOURCE,
     payload: resourceUuid
 });
diff --git a/services/workbench2/src/store/store.ts b/services/workbench2/src/store/store.ts
index 05f402485d..6c6608e6cc 100644
--- a/services/workbench2/src/store/store.ts
+++ b/services/workbench2/src/store/store.ts
@@ -183,7 +183,7 @@ const createRootReducer = (services: ServiceRepository) =>
         properties: propertiesReducer,
         resources: resourcesReducer,
         router: routerReducer,
-        selectedResource: selectedResourceReducer,
+        selectedResourceUuid: selectedResourceReducer,
         snackbar: snackbarReducer,
         treePicker: treePickerReducer,
         treePickerSearch: treePickerSearchReducer,
diff --git a/services/workbench2/src/views-components/data-explorer/data-explorer.tsx b/services/workbench2/src/views-components/data-explorer/data-explorer.tsx
index 3de1948179..aa5040b3f4 100644
--- a/services/workbench2/src/views-components/data-explorer/data-explorer.tsx
+++ b/services/workbench2/src/views-components/data-explorer/data-explorer.tsx
@@ -12,8 +12,8 @@ import { DataColumn } from "components/data-table/data-column";
 import { DataColumns, TCheckedList } from "components/data-table/data-table";
 import { DataTableFilters } from "components/data-table-filters/data-table-filters-tree";
 import { LAST_REFRESH_TIMESTAMP } from "components/refresh-button/refresh-button";
-import { toggleMSToolbar, setCheckedListOnStore, setSelectedUuid, isExactlyOneSelected } from "store/multiselect/multiselect-actions";
-import { DetailsPanelState } from "store/details-panel/details-panel-reducer";
+import { toggleMSToolbar, setCheckedListOnStore } from "store/multiselect/multiselect-actions";
+import { setSelectedResourceUuid } from "store/selected-resource/selected-resource-actions";
 
 interface Props {
     id: string;
@@ -23,34 +23,11 @@ interface Props {
     extractKey?: (item: any) => React.Key;
 }
 
-const getCurrentItemUuid = (
-    currentRoute: string,
-    workflowPanelDetailsUuid: string,
-    isDetailsResourceChecked: boolean,
-    isOnlyOneSelected: boolean,
-    detailsPanel: DetailsPanelState,
-    multiselectSelectedUuid: string
-) => {
-    if(currentRoute === '/workflows') {
-        return workflowPanelDetailsUuid;
-    }
-    if(isDetailsResourceChecked && isOnlyOneSelected) {
-        return detailsPanel.resourceUuid;
-    }
-    if(!detailsPanel.isOpened){
-        return multiselectSelectedUuid;
-    }
-    return detailsPanel.resourceUuid;
-};
-
-const mapStateToProps = ({ progressIndicator, dataExplorer, router, multiselect, detailsPanel, properties}: RootState, { id }: Props) => {
+const mapStateToProps = ({ progressIndicator, dataExplorer, router, multiselect, properties, selectedResourceUuid}: RootState, { id }: Props) => {
     const progress = progressIndicator.find(p => p.id === id);
     const dataExplorerState = getDataExplorer(dataExplorer, id);
     const currentRoute = router.location ? router.location.pathname : "";
     const currentRefresh = localStorage.getItem(LAST_REFRESH_TIMESTAMP) || "";
-    const isDetailsResourceChecked = multiselect.checkedList[detailsPanel.resourceUuid]
-    const isOnlyOneSelected = Object.values(multiselect.checkedList).filter(x => x === true).length === 1;
-    const currentItemUuid = getCurrentItemUuid(currentRoute, properties.workflowPanelDetailsUuid, isDetailsResourceChecked, isOnlyOneSelected, detailsPanel, multiselect.selectedUuid);
     const isMSToolbarVisible = multiselect.isVisible;
     return {
         ...dataExplorerState,
@@ -58,7 +35,8 @@ const mapStateToProps = ({ progressIndicator, dataExplorer, router, multiselect,
         currentRefresh: currentRefresh,
         currentRoute: currentRoute,
         paperKey: currentRoute,
-        currentItemUuid,
+        currentRouteUuid: properties.currentRouteUuid,
+        selectedResourceUuid: selectedResourceUuid,
         isMSToolbarVisible,
         checkedList: multiselect.checkedList,
     };
@@ -106,11 +84,10 @@ const mapDispatchToProps = () => {
             dispatch<any>(setCheckedListOnStore(checkedList));
         },
 
-        setSelectedUuid: (checkedList: TCheckedList) => {
-            dispatch<any>(setSelectedUuid(isExactlyOneSelected(checkedList)))
+        setSelectedUuid: (uuid: string) => {
+            dispatch<any>(setSelectedResourceUuid(uuid));
         },
         
-
         onRowClick,
 
         onRowDoubleClick,
diff --git a/services/workbench2/src/views-components/details-panel/details-panel.tsx b/services/workbench2/src/views-components/details-panel/details-panel.tsx
index e86d1bd477..d8c8be09fd 100644
--- a/services/workbench2/src/views-components/details-panel/details-panel.tsx
+++ b/services/workbench2/src/views-components/details-panel/details-panel.tsx
@@ -28,8 +28,6 @@ import { toggleDetailsPanel, SLIDE_TIMEOUT, openDetailsPanel } from 'store/detai
 import { FileDetails } from 'views-components/details-panel/file-details';
 import { getNode } from 'models/tree';
 import { resourceIsFrozen } from 'common/frozen-resources';
-import { DetailsPanelState } from 'store/details-panel/details-panel-reducer';
-import { MultiselectToolbarState } from 'store/multiselect/multiselect-reducer';
 import { CLOSE_DRAWER } from 'store/details-panel/details-panel-action';
 
 type CssRules = 'root' | 'container' | 'opened' | 'headerContainer' | 'headerIcon' | 'tabContainer';
@@ -86,27 +84,8 @@ const getItem = (res: DetailsResource): DetailsData => {
     }
 };
 
-const getCurrentItemUuid = (
-    isDetailsResourceChecked: boolean,
-    currentRoute: string,
-    detailsPanel: DetailsPanelState,
-    multiselect: MultiselectToolbarState,
-    currentRouteSplit: string[]
-) => {
-    if (isDetailsResourceChecked || currentRoute.includes('collections') || detailsPanel.isOpened) {
-        return detailsPanel.resourceUuid;
-    }
-    if (!!multiselect.selectedUuid) {
-        return multiselect.selectedUuid;
-    }
-    return currentRouteSplit[currentRouteSplit.length - 1];
-};
-
-const mapStateToProps = ({ auth, detailsPanel, resources, collectionPanelFiles, multiselect, router }: RootState) => {
-    const isDetailsResourceChecked = multiselect.checkedList[detailsPanel.resourceUuid] === true;
-    const currentRoute = router.location ? router.location.pathname : "";
-    const currentRouteSplit = currentRoute.split('/');
-    const currentItemUuid = getCurrentItemUuid(isDetailsResourceChecked, currentRoute, detailsPanel, multiselect, currentRouteSplit);
+const mapStateToProps = ({ auth, detailsPanel, resources, collectionPanelFiles, selectedResourceUuid: selectedResource }: RootState) => {
+    const currentItemUuid = selectedResource;
     const resource = getResource(currentItemUuid)(resources) as DetailsResource | undefined;
     const file = resource
         ? undefined
@@ -127,8 +106,6 @@ const mapStateToProps = ({ auth, detailsPanel, resources, collectionPanelFiles,
     };
 };
 
-// export const CLOSE_DRAWER = 'CLOSE_DRAWER'
-
 const mapDispatchToProps = (dispatch: Dispatch) => ({
     onCloseDrawer: (currentItemId) => {
         dispatch<any>(toggleDetailsPanel(currentItemId));
@@ -146,7 +123,6 @@ export interface DetailsPanelDataProps {
     tabNr: number;
     res: DetailsResource;
     isFrozen: boolean;
-    currentItemUuid: string;
 }
 
 type DetailsPanelProps = DetailsPanelDataProps & WithStyles<CssRules>;

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list