[ARVADOS-WORKBENCH2] updated: 1.2.1-1019-g52b507c
Git user
git at public.curoverse.com
Wed Nov 28 16:57:07 EST 2018
Summary of changes:
src/store/search-bar/search-bar-actions.ts | 17 ++--
src/store/search-bar/search-bar-tree-actions.ts | 101 +++++++++++++++++++++
.../search-bar/search-bar-advanced-view.tsx | 4 +-
3 files changed, 113 insertions(+), 9 deletions(-)
create mode 100644 src/store/search-bar/search-bar-tree-actions.ts
via 52b507cead2443e6566fb8679df71ef9cf8dbe5c (commit)
from 2b3f667039ba2e7efe0852d58ae2c62899b773f0 (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 52b507cead2443e6566fb8679df71ef9cf8dbe5c
Author: Daniel Kos <daniel.kos at contractors.roche.com>
Date: Wed Nov 28 22:56:26 2018 +0100
Add populating search bar project tree and auto selecting project, fix clearing selection on advanced view close
Feature #14280
Arvados-DCO-1.1-Signed-off-by: Daniel Kos <daniel.kos at contractors.roche.com>
diff --git a/src/store/search-bar/search-bar-actions.ts b/src/store/search-bar/search-bar-actions.ts
index a2eed93..a4abfed 100644
--- a/src/store/search-bar/search-bar-actions.ts
+++ b/src/store/search-bar/search-bar-actions.ts
@@ -7,7 +7,7 @@ import { GroupContentsResource, GroupContentsResourcePrefix } from '~/services/g
import { Dispatch } from 'redux';
import { arrayPush, change, initialize } from 'redux-form';
import { RootState } from '~/store/store';
-import { initUserProject } from '~/store/tree-picker/tree-picker-actions';
+import { initUserProject, treePickerActions } from '~/store/tree-picker/tree-picker-actions';
import { ServiceRepository } from '~/services/services';
import { FilterBuilder } from "~/services/api/filter-builder";
import { getResourceKind, ResourceKind } from '~/models/resource';
@@ -19,6 +19,7 @@ import { getClusterObjectType, PropertyValues, SearchBarAdvanceFormData } from '
import { debounce } from 'debounce';
import * as _ from "lodash";
import { getModifiedKeysValues } from "~/common/objects";
+import { activateSearchBarProject } from "~/store/search-bar/search-bar-tree-actions";
export const searchBarActions = unionize({
SET_CURRENT_VIEW: ofType<string>(),
@@ -89,9 +90,13 @@ export const setSearchValueFromAdvancedData = (data: SearchBarAdvanceFormData, p
};
export const setAdvancedDataFromSearchValue = (search: string) =>
- (dispatch: Dispatch) => {
+ async (dispatch: Dispatch) => {
const data = getAdvancedDataFromQuery(search);
dispatch<any>(initialize(SEARCH_BAR_ADVANCE_FORM_NAME, data));
+ if (data.projectUuid) {
+ await dispatch<any>(activateSearchBarProject(data.projectUuid));
+ dispatch(treePickerActions.ACTIVATE_TREE_PICKER_NODE({ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID, id: data.projectUuid }));
+ }
};
const saveQuery = (data: SearchBarAdvanceFormData) =>
@@ -145,6 +150,7 @@ export const closeSearchView = () =>
export const closeAdvanceView = () =>
(dispatch: Dispatch<any>) => {
dispatch(searchBarActions.SET_SEARCH_VALUE(''));
+ dispatch(treePickerActions.DEACTIVATE_TREE_PICKER_NODE({ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID }));
dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.BASIC));
};
@@ -212,9 +218,6 @@ const searchGroups = (searchValue: string, limit: number) =>
const buildQueryFromKeyMap = (data: any, keyMap: string[][], mode: 'rebuild' | 'reuse') => {
let value = data.searchValue;
- const rem = (field: string, fieldValue: any, value: string) => {
- };
-
const addRem = (field: string, key: string) => {
const v = data[key];
@@ -285,7 +288,7 @@ export const getQueryFromAdvancedData = (data: SearchBarAdvanceFormData, prevDat
return value;
};
-export interface ParsedSearchQuery {
+export interface ParseSearchQuery {
hasKeywords: boolean;
values: string[];
properties: {
@@ -293,7 +296,7 @@ export interface ParsedSearchQuery {
};
}
-export const parseSearchQuery: (query: string) => { hasKeywords: boolean; values: string[]; properties: any } = (searchValue: string): ParsedSearchQuery => {
+export const parseSearchQuery: (query: string) => { hasKeywords: boolean; values: string[]; properties: any } = (searchValue: string): ParseSearchQuery => {
const keywords = [
'type:',
'cluster:',
diff --git a/src/store/search-bar/search-bar-tree-actions.ts b/src/store/search-bar/search-bar-tree-actions.ts
new file mode 100644
index 0000000..8df4d61
--- /dev/null
+++ b/src/store/search-bar/search-bar-tree-actions.ts
@@ -0,0 +1,101 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { getTreePicker, TreePicker } from "~/store/tree-picker/tree-picker";
+import { getNode, getNodeAncestorsIds, initTreeNode, TreeNodeStatus } from "~/models/tree";
+import { Dispatch } from "redux";
+import { RootState } from "~/store/store";
+import { ServiceRepository } from "~/services/services";
+import { treePickerActions } from "~/store/tree-picker/tree-picker-actions";
+import { FilterBuilder } from "~/services/api/filter-builder";
+import { OrderBuilder } from "~/services/api/order-builder";
+import { ProjectResource } from "~/models/project";
+import { resourcesActions } from "~/store/resources/resources-actions";
+import { SEARCH_BAR_ADVANCE_FORM_PICKER_ID } from "~/store/search-bar/search-bar-actions";
+
+const getSearchBarTreeNode = (id: string) => (treePicker: TreePicker) => {
+ const searchTree = getTreePicker(SEARCH_BAR_ADVANCE_FORM_PICKER_ID)(treePicker);
+ return searchTree
+ ? getNode(id)(searchTree)
+ : undefined;
+};
+
+export const loadSearchBarTreeProjects = (projectUuid: string) =>
+ async (dispatch: Dispatch, getState: () => RootState) => {
+ const treePicker = getTreePicker(SEARCH_BAR_ADVANCE_FORM_PICKER_ID)(getState().treePicker);
+ const node = treePicker ? getNode(projectUuid)(treePicker) : undefined;
+ if (node || projectUuid === '') {
+ await dispatch<any>(loadSearchBarProject(projectUuid));
+ }
+ };
+
+export const getSearchBarTreeNodeAncestorsIds = (id: string) => (treePicker: TreePicker) => {
+ const searchTree = getTreePicker(SEARCH_BAR_ADVANCE_FORM_PICKER_ID)(treePicker);
+ return searchTree
+ ? getNodeAncestorsIds(id)(searchTree)
+ : [];
+};
+
+export const activateSearchBarTreeBranch = (id: string) =>
+ async (dispatch: Dispatch, _: void, services: ServiceRepository) => {
+ const ancestors = await services.ancestorsService.ancestors(id, services.authService.getUuid() || '');
+
+ for (const ancestor of ancestors) {
+ await dispatch<any>(loadSearchBarTreeProjects(ancestor.uuid));
+ }
+ dispatch(treePickerActions.EXPAND_TREE_PICKER_NODES({
+ ids: [
+ ...[],
+ ...ancestors.map(ancestor => ancestor.uuid)
+ ],
+ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID
+ }));
+ dispatch(treePickerActions.ACTIVATE_TREE_PICKER_NODE({ id, pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID }));
+ };
+
+export const expandSearchBarTreeItem = (id: string) =>
+ async (dispatch: Dispatch, getState: () => RootState) => {
+ const node = getSearchBarTreeNode(id)(getState().treePicker);
+ if (node && !node.expanded) {
+ dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_COLLAPSE({ id, pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID }));
+ }
+ };
+
+export const activateSearchBarProject = (id: string) =>
+ async (dispatch: Dispatch, getState: () => RootState) => {
+ const { treePicker } = getState();
+ const node = getSearchBarTreeNode(id)(treePicker);
+ if (node && node.status !== TreeNodeStatus.LOADED) {
+ await dispatch<any>(loadSearchBarTreeProjects(id));
+ } else if (node === undefined) {
+ await dispatch<any>(activateSearchBarTreeBranch(id));
+ }
+ dispatch(treePickerActions.EXPAND_TREE_PICKER_NODES({
+ ids: getSearchBarTreeNodeAncestorsIds(id)(treePicker),
+ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID
+ }));
+ dispatch<any>(expandSearchBarTreeItem(id));
+ };
+
+
+const loadSearchBarProject = (projectUuid: string) =>
+ async (dispatch: Dispatch, _: () => RootState, services: ServiceRepository) => {
+ dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: projectUuid, pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID }));
+ const params = {
+ filters: new FilterBuilder()
+ .addEqual('ownerUuid', projectUuid)
+ .getFilters(),
+ order: new OrderBuilder<ProjectResource>()
+ .addAsc('name')
+ .getOrder()
+ };
+ const { items } = await services.projectService.list(params);
+ dispatch(treePickerActions.LOAD_TREE_PICKER_NODE_SUCCESS({
+ id: projectUuid,
+ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID,
+ nodes: items.map(item => initTreeNode({ id: item.uuid, value: item })),
+ }));
+ dispatch(resourcesActions.SET_RESOURCES(items));
+ };
+// project:c97qk-j7d0g-ib8mwrhxirrfhma
diff --git a/src/views-components/search-bar/search-bar-advanced-view.tsx b/src/views-components/search-bar/search-bar-advanced-view.tsx
index f0dffa5..05bdb97 100644
--- a/src/views-components/search-bar/search-bar-advanced-view.tsx
+++ b/src/views-components/search-bar/search-bar-advanced-view.tsx
@@ -105,11 +105,11 @@ export const SearchBarAdvancedView = compose(
onSubmit: (data: SearchBarAdvanceFormData, dispatch: Dispatch) => {
dispatch<any>(searchAdvanceData(data));
dispatch(reset(SEARCH_BAR_ADVANCE_FORM_NAME));
- dispatch(treePickerActions.ACTIVATE_TREE_PICKER_NODE({ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID, id: "" }));
+ dispatch(treePickerActions.DEACTIVATE_TREE_PICKER_NODE({ pickerId: SEARCH_BAR_ADVANCE_FORM_PICKER_ID }));
},
onChange: (data: SearchBarAdvanceFormData, dispatch: Dispatch, props: any, prevData: SearchBarAdvanceFormData) => {
dispatch<any>(setSearchValueFromAdvancedData(data, prevData));
- }
+ },
}),
withStyles(styles))(
({ classes, closeAdvanceView, handleSubmit, submitting, invalid, pristine, tags, saveQuery }: SearchBarAdvancedViewFormProps) =>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list