[ARVADOS-WORKBENCH2] created: 1.4.1-72-gc5419107

Git user git at public.curoverse.com
Mon Oct 28 19:36:08 UTC 2019


        at  c541910768512998c6e7b31d7f128837772b4ed1 (commit)


commit c541910768512998c6e7b31d7f128837772b4ed1
Author: Peter Amstutz <pamstutz at veritasgenetics.com>
Date:   Mon Oct 28 15:35:05 2019 -0400

    15669: Store and retrieve search value in location 'search' part

diff --git a/src/models/resource.ts b/src/models/resource.ts
index 239a67cc..4708a9da 100644
--- a/src/models/resource.ts
+++ b/src/models/resource.ts
@@ -58,8 +58,8 @@ export enum ResourceObjectType {
 }
 
 export const RESOURCE_UUID_PATTERN = '[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}';
-export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
-export const COLLECTION_PDH_REGEX = /[a-f0-9]{32}\+\d+/;
+export const RESOURCE_UUID_REGEX = new RegExp("^" + RESOURCE_UUID_PATTERN + "$");
+export const COLLECTION_PDH_REGEX = /^[a-f0-9]{32}\+\d+$/;
 
 export const isResourceUuid = (uuid: string) =>
     RESOURCE_UUID_REGEX.test(uuid);
diff --git a/src/store/navigation/navigation-action.ts b/src/store/navigation/navigation-action.ts
index f2f1cea6..f60f37f9 100644
--- a/src/store/navigation/navigation-action.ts
+++ b/src/store/navigation/navigation-action.ts
@@ -69,7 +69,13 @@ export const navigateToSharedWithMe = push(Routes.SHARED_WITH_ME);
 
 export const navigateToRunProcess = push(Routes.RUN_PROCESS);
 
-export const navigateToSearchResults = push(Routes.SEARCH_RESULTS);
+export const navigateToSearchResults = (searchValue: string) => {
+    if (searchValue !== "") {
+        return push({ pathname: Routes.SEARCH_RESULTS, search: '?q=' + encodeURIComponent(searchValue) });
+    } else {
+        return push({ pathname: Routes.SEARCH_RESULTS });
+    }
+};
 
 export const navigateToUserVirtualMachines = push(Routes.VIRTUAL_MACHINES_USER);
 
diff --git a/src/store/search-bar/search-bar-actions.ts b/src/store/search-bar/search-bar-actions.ts
index e1551c23..11dc1ef5 100644
--- a/src/store/search-bar/search-bar-actions.ts
+++ b/src/store/search-bar/search-bar-actions.ts
@@ -70,9 +70,9 @@ export const searchData = (searchValue: string) =>
             dispatch<any>(searchGroups(searchValue, 5));
             if (currentView === SearchView.BASIC) {
                 dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
-                dispatch(navigateToSearchResults);
+                dispatch(navigateToSearchResults(searchValue));
             }
-        }
+	}
     };
 
 export const searchAdvanceData = (data: SearchBarAdvanceFormData) =>
@@ -81,7 +81,7 @@ export const searchAdvanceData = (data: SearchBarAdvanceFormData) =>
         dispatch(searchResultsPanelActions.CLEAR());
         dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.BASIC));
         dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
-        dispatch(navigateToSearchResults);
+        dispatch(navigateToSearchResults(""));
     };
 
 export const setSearchValueFromAdvancedData = (data: SearchBarAdvanceFormData, prevData?: SearchBarAdvanceFormData) =>
@@ -197,7 +197,7 @@ export const submitData = (event: React.FormEvent<HTMLFormElement>) =>
             dispatch(searchBarActions.SET_SEARCH_VALUE(searchValue));
             dispatch(searchBarActions.SET_SEARCH_RESULTS([]));
             dispatch(searchResultsPanelActions.CLEAR());
-            dispatch(navigateToSearchResults);
+            dispatch(navigateToSearchResults(searchValue));
         }
     };
 
@@ -231,15 +231,15 @@ const buildQueryFromKeyMap = (data: any, keyMap: string[][], mode: 'rebuild' | '
 
         if (data.hasOwnProperty(key)) {
             const pattern = v === false
-                ? `${field.replace(':', '\\:\\s*')}\\s*`
-                : `${field.replace(':', '\\:\\s*')}\\:\\s*"[\\w|\\#|\\-|\\/]*"\\s*`;
+                          ? `${field.replace(':', '\\:\\s*')}\\s*`
+                          : `${field.replace(':', '\\:\\s*')}\\:\\s*"[\\w|\\#|\\-|\\/]*"\\s*`;
             value = value.replace(new RegExp(pattern), '');
         }
 
         if (v) {
             const nv = v === true
-                ? `${field}`
-                : `${field}:${v}`;
+                     ? `${field}`
+                     : `${field}:${v}`;
 
             if (mode === 'rebuild') {
                 value = value + ' ' + nv;
@@ -280,7 +280,7 @@ export const getQueryFromAdvancedData = (data: SearchBarAdvanceFormData, prevDat
         ['to', 'dateTo']
     ];
     _.union(data.properties, prevData ? prevData.properties : [])
-        .forEach(p => keyMap.push([`has:"${p.key}"`, `prop-"${p.key}"`]));
+     .forEach(p => keyMap.push([`has:"${p.key}"`, `prop-"${p.key}"`]));
 
     if (prevData) {
         const obj = getModifiedKeysValues(flatData(data), flatData(prevData));
diff --git a/src/store/search-results-panel/search-results-panel-actions.ts b/src/store/search-results-panel/search-results-panel-actions.ts
index d41191c0..20a14b2e 100644
--- a/src/store/search-results-panel/search-results-panel-actions.ts
+++ b/src/store/search-results-panel/search-results-panel-actions.ts
@@ -7,6 +7,7 @@ import { RootState } from '~/store/store';
 import { ServiceRepository } from '~/services/services';
 import { bindDataExplorerActions } from '~/store/data-explorer/data-explorer-action';
 import { setBreadcrumbs } from '~/store/breadcrumbs/breadcrumbs-actions';
+import { searchBarActions } from '~/store/search-bar/search-bar-actions';
 
 export const SEARCH_RESULTS_PANEL_ID = "searchResultsPanel";
 export const searchResultsPanelActions = bindDataExplorerActions(SEARCH_RESULTS_PANEL_ID);
@@ -14,5 +15,15 @@ export const searchResultsPanelActions = bindDataExplorerActions(SEARCH_RESULTS_
 export const loadSearchResultsPanel = () =>
     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
         dispatch(setBreadcrumbs([{ label: 'Search results' }]));
+        const loc = getState().router.location;
+        if (loc !== null) {
+            const search = new URLSearchParams(loc.search);
+            const q = search.get('q');
+            if (q !== null) {
+                dispatch(searchBarActions.SET_SEARCH_VALUE(q));
+            }
+        }
+        dispatch(searchBarActions.SET_SEARCH_RESULTS([]));
+        dispatch(searchResultsPanelActions.CLEAR());
         dispatch(searchResultsPanelActions.REQUEST_ITEMS(true));
-    };
\ No newline at end of file
+    };

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list