[ARVADOS-WORKBENCH2] created: 1.2.0-867-gabee9c2
Git user
git at public.curoverse.com
Wed Nov 14 05:33:14 EST 2018
at abee9c2585e30a4217b5adc3b40d298227f6a650 (commit)
commit abee9c2585e30a4217b5adc3b40d298227f6a650
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Wed Nov 14 11:30:05 2018 +0100
Add related tree pickers to projects tree picker
Feature #14471
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/views-components/projects-tree-picker/projects-tree-picker.tsx b/src/views-components/projects-tree-picker/projects-tree-picker.tsx
index ba29be8..6c66d1a 100644
--- a/src/views-components/projects-tree-picker/projects-tree-picker.tsx
+++ b/src/views-components/projects-tree-picker/projects-tree-picker.tsx
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: AGPL-3.0
import * as React from 'react';
+import { values, memoize, pipe } from 'lodash/fp';
import { HomeTreePicker } from '~/views-components/projects-tree-picker/home-tree-picker';
import { SharedTreePicker } from '~/views-components/projects-tree-picker/shared-tree-picker';
import { FavoritesTreePicker } from '~/views-components/projects-tree-picker/favorites-tree-picker';
@@ -21,9 +22,12 @@ export interface ProjectsTreePickerProps {
export const ProjectsTreePicker = ({ pickerId, ...props }: ProjectsTreePickerProps) => {
const { home, shared, favorites } = getProjectsTreePickerIds(pickerId);
+ const relatedTreePickers = getRelatedTreePickers(pickerId);
return <div>
- <HomeTreePicker pickerId={home} {...props} />
- <SharedTreePicker pickerId={shared} {...props} />
- <FavoritesTreePicker pickerId={favorites} {...props} />
+ <HomeTreePicker pickerId={home} {...props} {...{ relatedTreePickers }} />
+ <SharedTreePicker pickerId={shared} {...props} {...{ relatedTreePickers }} />
+ <FavoritesTreePicker pickerId={favorites} {...props} {...{ relatedTreePickers }} />
</div>;
};
+
+const getRelatedTreePickers = memoize(pipe(getProjectsTreePickerIds, values));
commit 546052817ac18623f5389914a3077e8cc6a3d4f4
Author: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
Date: Thu Nov 1 19:06:48 2018 +0100
Hanle related tree pickers item deactivation
Feature #14471
Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski at contractors.roche.com>
diff --git a/src/store/tree-picker/tree-picker-actions.ts b/src/store/tree-picker/tree-picker-actions.ts
index f51dcac..ffc49bc 100644
--- a/src/store/tree-picker/tree-picker-actions.ts
+++ b/src/store/tree-picker/tree-picker-actions.ts
@@ -21,7 +21,7 @@ export const treePickerActions = unionize({
LOAD_TREE_PICKER_NODE: ofType<{ id: string, pickerId: string }>(),
LOAD_TREE_PICKER_NODE_SUCCESS: ofType<{ id: string, nodes: Array<TreeNode<any>>, pickerId: string }>(),
TOGGLE_TREE_PICKER_NODE_COLLAPSE: ofType<{ id: string, pickerId: string }>(),
- ACTIVATE_TREE_PICKER_NODE: ofType<{ id: string, pickerId: string }>(),
+ ACTIVATE_TREE_PICKER_NODE: ofType<{ id: string, pickerId: string, relatedTreePickers?: string[] }>(),
DEACTIVATE_TREE_PICKER_NODE: ofType<{ pickerId: string }>(),
TOGGLE_TREE_PICKER_NODE_SELECTION: ofType<{ id: string, pickerId: string }>(),
SELECT_TREE_PICKER_NODE: ofType<{ id: string | string[], pickerId: string }>(),
diff --git a/src/store/tree-picker/tree-picker-reducer.ts b/src/store/tree-picker/tree-picker-reducer.ts
index 846e445..341df7b 100644
--- a/src/store/tree-picker/tree-picker-reducer.ts
+++ b/src/store/tree-picker/tree-picker-reducer.ts
@@ -7,29 +7,46 @@ import { TreePicker } from "./tree-picker";
import { treePickerActions, TreePickerAction } from "./tree-picker-actions";
import { compose } from "redux";
import { activateNode, getNode, toggleNodeCollapse, toggleNodeSelection } from '~/models/tree';
+import { pipe } from 'lodash/fp';
export const treePickerReducer = (state: TreePicker = {}, action: TreePickerAction) =>
treePickerActions.match(action, {
LOAD_TREE_PICKER_NODE: ({ id, pickerId }) =>
updateOrCreatePicker(state, pickerId, setNodeStatus(id)(TreeNodeStatus.PENDING)),
+
LOAD_TREE_PICKER_NODE_SUCCESS: ({ id, nodes, pickerId }) =>
updateOrCreatePicker(state, pickerId, compose(receiveNodes(nodes)(id), setNodeStatus(id)(TreeNodeStatus.LOADED))),
+
TOGGLE_TREE_PICKER_NODE_COLLAPSE: ({ id, pickerId }) =>
updateOrCreatePicker(state, pickerId, toggleNodeCollapse(id)),
- ACTIVATE_TREE_PICKER_NODE: ({ id, pickerId }) =>
- updateOrCreatePicker(state, pickerId, activateNode(id)),
+
+ ACTIVATE_TREE_PICKER_NODE: ({ id, pickerId, relatedTreePickers = [] }) =>
+ pipe(
+ () => relatedTreePickers.reduce(
+ (state, relatedPickerId) => updateOrCreatePicker(state, relatedPickerId, deactivateNode),
+ state
+ ),
+ state => updateOrCreatePicker(state, pickerId, activateNode(id))
+ )(),
+
DEACTIVATE_TREE_PICKER_NODE: ({ pickerId }) =>
updateOrCreatePicker(state, pickerId, deactivateNode),
+
TOGGLE_TREE_PICKER_NODE_SELECTION: ({ id, pickerId }) =>
updateOrCreatePicker(state, pickerId, toggleNodeSelection(id)),
+
SELECT_TREE_PICKER_NODE: ({ id, pickerId }) =>
updateOrCreatePicker(state, pickerId, selectNodes(id)),
+
DESELECT_TREE_PICKER_NODE: ({ id, pickerId }) =>
updateOrCreatePicker(state, pickerId, deselectNodes(id)),
+
RESET_TREE_PICKER: ({ pickerId }) =>
updateOrCreatePicker(state, pickerId, createTree),
+
EXPAND_TREE_PICKER_NODES: ({ pickerId, ids }) =>
updateOrCreatePicker(state, pickerId, expandNode(...ids)),
+
default: () => state
});
diff --git a/src/views-components/projects-tree-picker/generic-projects-tree-picker.tsx b/src/views-components/projects-tree-picker/generic-projects-tree-picker.tsx
index 77f831f..d8a5d49 100644
--- a/src/views-components/projects-tree-picker/generic-projects-tree-picker.tsx
+++ b/src/views-components/projects-tree-picker/generic-projects-tree-picker.tsx
@@ -29,6 +29,7 @@ export interface ProjectsTreePickerDataProps {
includeFiles?: boolean;
rootItemIcon: IconType;
showSelection?: boolean;
+ relatedTreePickers?: string[];
loadRootItem: (item: TreeItem<ProjectsTreePickerRootItem>, pickerId: string, includeCollections?: boolean, inlcudeFiles?: boolean) => void;
}
@@ -39,10 +40,10 @@ const mapStateToProps = (_: any, { rootItemIcon, showSelection }: ProjectsTreePi
showSelection: isSelectionVisible(showSelection),
});
-const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollections, includeFiles, ...props }: ProjectsTreePickerProps): PickedTreePickerProps => ({
+const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollections, includeFiles, relatedTreePickers, ...props }: ProjectsTreePickerProps): PickedTreePickerProps => ({
onContextMenu: () => { return; },
toggleItemActive: (event, item, pickerId) => {
- dispatch(treePickerActions.ACTIVATE_TREE_PICKER_NODE({ id: item.id, pickerId }));
+ dispatch(treePickerActions.ACTIVATE_TREE_PICKER_NODE({ id: item.id, pickerId, relatedTreePickers }));
if (props.toggleItemActive) {
props.toggleItemActive(event, item, pickerId);
}
@@ -65,7 +66,7 @@ const mapDispatchToProps = (dispatch: Dispatch, { loadRootItem, includeCollectio
},
toggleItemSelection: (event, item, pickerId) => {
dispatch<any>(treePickerActions.TOGGLE_TREE_PICKER_NODE_SELECTION({ id: item.id, pickerId }));
- if(props.toggleItemSelection){
+ if (props.toggleItemSelection) {
props.toggleItemSelection(event, item, pickerId);
}
},
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list