[arvados-workbench2] updated: 2.4.0-363-gd3c1b53b

git repository hosting git at public.arvados.org
Fri Dec 9 04:32:33 UTC 2022


Summary of changes:
 src/store/tree-picker/tree-picker-middleware.ts    | 118 +++++++++++++++++++++
 ...-tree-picker.tsx => search-projects-picker.tsx} |  10 +-
 2 files changed, 123 insertions(+), 5 deletions(-)
 create mode 100644 src/store/tree-picker/tree-picker-middleware.ts
 copy src/views-components/projects-tree-picker/{shared-tree-picker.tsx => search-projects-picker.tsx} (63%)

       via  d3c1b53b3190a0b61772e0c0c52d0671f11b1047 (commit)
      from  be5e418e1bb0ff54401b71c2cf6865222d182c18 (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 d3c1b53b3190a0b61772e0c0c52d0671f11b1047
Author: Peter Amstutz <peter.amstutz at curii.com>
Date:   Thu Dec 8 23:32:22 2022 -0500

    19783: Add missing files
    
    Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <peter.amstutz at curii.com>

diff --git a/src/store/tree-picker/tree-picker-middleware.ts b/src/store/tree-picker/tree-picker-middleware.ts
new file mode 100644
index 00000000..8fa3ee4a
--- /dev/null
+++ b/src/store/tree-picker/tree-picker-middleware.ts
@@ -0,0 +1,118 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from 'redux';
+import { RootState } from 'store/store';
+import { ServiceRepository } from 'services/services';
+import { Middleware } from "redux";
+import { getNode, getNodeDescendantsIds, TreeNodeStatus } from 'models/tree';
+import { getTreePicker } from './tree-picker';
+import {
+    treePickerSearchActions, loadProject, loadFavoritesProject, loadPublicFavoritesProject,
+    SHARED_PROJECT_ID, FAVORITES_PROJECT_ID, PUBLIC_FAVORITES_PROJECT_ID, SEARCH_PROJECT_ID
+} from "./tree-picker-actions";
+import { LinkResource } from "models/link";
+import { GroupContentsResource } from 'services/groups-service/groups-service';
+import { CollectionDirectory, CollectionFile } from 'models/collection-file';
+
+export interface ProjectsTreePickerRootItem {
+    id: string;
+    name: string;
+}
+
+export type ProjectsTreePickerItem = ProjectsTreePickerRootItem | GroupContentsResource | CollectionDirectory | CollectionFile | LinkResource;
+
+export const treePickerSearchMiddleware: Middleware = store => next => action => {
+    let isSearchAction = false;
+    let searchChanged = false;
+
+    treePickerSearchActions.match(action, {
+        SET_TREE_PICKER_PROJECT_SEARCH: ({ pickerId, projectSearchValue }) => {
+            isSearchAction = true;
+            searchChanged = store.getState().treePickerSearch.projectSearchValues[pickerId] !== projectSearchValue;
+        },
+
+        SET_TREE_PICKER_COLLECTION_FILTER: ({ pickerId, collectionFilterValue }) => {
+            isSearchAction = true;
+            searchChanged = store.getState().treePickerSearch.collectionFilterValues[pickerId] !== collectionFilterValue;
+        },
+        default: () => { }
+    });
+
+    if (isSearchAction && !searchChanged) {
+        return;
+    }
+
+    // pass it on to the reducer
+    const r = next(action);
+
+    treePickerSearchActions.match(action, {
+        SET_TREE_PICKER_PROJECT_SEARCH: ({ pickerId }) =>
+            store.dispatch<any>((dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+                const picker = getTreePicker<ProjectsTreePickerItem>(pickerId)(getState().treePicker);
+                if (picker) {
+                    const loadParams = getState().treePickerSearch.loadProjectParams[pickerId];
+                    dispatch<any>(loadProject({
+                        ...loadParams,
+                        id: SEARCH_PROJECT_ID,
+                        pickerId: pickerId,
+                        searchProjects: true
+                    }));
+                }
+            }),
+
+        SET_TREE_PICKER_COLLECTION_FILTER: ({ pickerId }) =>
+            store.dispatch<any>((dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
+                const picker = getTreePicker<ProjectsTreePickerItem>(pickerId)(getState().treePicker);
+                if (picker) {
+                    const loadParams = getState().treePickerSearch.loadProjectParams[pickerId];
+                    getNodeDescendantsIds('')(picker)
+                        .map(id => {
+                            const node = getNode(id)(picker);
+                            if (node && node.status !== TreeNodeStatus.INITIAL) {
+                                if (node.id.substring(6, 11) === 'tpzed' || node.id.substring(6, 11) === 'j7d0g') {
+                                    dispatch<any>(loadProject({
+                                        ...loadParams,
+                                        id: node.id,
+                                        pickerId: pickerId,
+                                    }));
+                                }
+                                if (node.id === SHARED_PROJECT_ID) {
+                                    dispatch<any>(loadProject({
+                                        ...loadParams,
+                                        id: node.id,
+                                        pickerId: pickerId,
+                                        loadShared: true
+                                    }));
+                                }
+                                if (node.id === SEARCH_PROJECT_ID) {
+                                    dispatch<any>(loadProject({
+                                        ...loadParams,
+                                        id: node.id,
+                                        pickerId: pickerId,
+                                        searchProjects: true
+                                    }));
+                                }
+                                if (node.id === FAVORITES_PROJECT_ID) {
+                                    dispatch<any>(loadFavoritesProject({
+                                        ...loadParams,
+                                        pickerId: pickerId,
+                                    }));
+                                }
+                                if (node.id === PUBLIC_FAVORITES_PROJECT_ID) {
+                                    dispatch<any>(loadPublicFavoritesProject({
+                                        ...loadParams,
+                                        pickerId: pickerId,
+                                    }));
+                                }
+                            }
+                            return id;
+                        });
+                }
+            }),
+        default: () => { }
+    });
+
+    return r;
+}
diff --git a/src/views-components/projects-tree-picker/search-projects-picker.tsx b/src/views-components/projects-tree-picker/search-projects-picker.tsx
new file mode 100644
index 00000000..7bad8ef7
--- /dev/null
+++ b/src/views-components/projects-tree-picker/search-projects-picker.tsx
@@ -0,0 +1,18 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { connect } from 'react-redux';
+import { ProjectsTreePicker, ProjectsTreePickerProps } from 'views-components/projects-tree-picker/generic-projects-tree-picker';
+import { Dispatch } from 'redux';
+import { SearchIcon } from 'components/icon/icon';
+import { loadProject } from 'store/tree-picker/tree-picker-actions';
+import { SEARCH_PROJECT_ID } from 'store/tree-picker/tree-picker-actions';
+
+export const SearchProjectsPicker = connect(() => ({
+    rootItemIcon: SearchIcon,
+}), (dispatch: Dispatch): Pick<ProjectsTreePickerProps, 'loadRootItem'> => ({
+    loadRootItem: (_, pickerId, includeCollections, includeFiles, options) => {
+        dispatch<any>(loadProject({ id: SEARCH_PROJECT_ID, pickerId, includeCollections, includeFiles, searchProjects: true, options }));
+    },
+}))(ProjectsTreePicker);

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list