16718: Adds option to search for collection's past versions.
authorLucas Di Pentima <lucas@di-pentima.com.ar>
Mon, 5 Oct 2020 16:13:52 +0000 (13:13 -0300)
committerLucas Di Pentima <lucas@di-pentima.com.ar>
Tue, 6 Oct 2020 17:42:30 +0000 (14:42 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <lucas@di-pentima.com.ar>

src/models/search-bar.ts
src/store/search-bar/search-bar-actions.test.ts
src/store/search-bar/search-bar-actions.ts
src/store/search-bar/search-query/arv-parser.ts
src/store/search-results-panel/search-results-middleware-service.ts
src/views-components/form-fields/search-bar-form-fields.tsx
src/views-components/search-bar/search-bar-advanced-view.tsx

index c71faf2ff47c132453e923a8d021816865ef67ee..09b8b6b70d02670f115ab58f218c06253c630652 100644 (file)
@@ -9,6 +9,7 @@ export type SearchBarAdvancedFormData = {
     cluster?: string;
     projectUuid?: string;
     inTrash: boolean;
+    pastVersions: boolean;
     dateFrom: string;
     dateTo: string;
     saveQuery: boolean;
index 68804dfb6393e885de4bf91b0f3041a4ff46fac2..a579183cf00f2c7e1e980c641568c843eb49c17c 100644 (file)
@@ -15,6 +15,7 @@ describe('search-bar-actions', () => {
                 cluster: undefined,
                 projectUuid: undefined,
                 inTrash: true,
+                pastVersions: false,
                 dateFrom: '',
                 dateTo: '',
                 properties: [{
@@ -37,6 +38,7 @@ describe('search-bar-actions', () => {
                 cluster: 'c97qx',
                 projectUuid: undefined,
                 inTrash: true,
+                pastVersions: false,
                 dateFrom: '2017-08-01',
                 dateTo: '',
                 properties: [{
@@ -57,6 +59,7 @@ describe('search-bar-actions', () => {
                 cluster: 'c97qx',
                 projectUuid: undefined,
                 inTrash: true,
+                pastVersions: false,
                 dateFrom: '2017-08-01',
                 dateTo: '',
                 properties: [
@@ -78,6 +81,7 @@ describe('search-bar-actions', () => {
                 cluster: undefined,
                 projectUuid: undefined,
                 inTrash: false,
+                pastVersions: false,
                 dateFrom: '',
                 dateTo: '',
                 properties: [
@@ -107,6 +111,7 @@ describe('search-bar-actions', () => {
                 cluster: undefined,
                 projectUuid: undefined,
                 inTrash: false,
+                pastVersions: false,
                 dateFrom: '',
                 dateTo: '',
                 properties: [
@@ -134,6 +139,7 @@ describe('search-bar-actions', () => {
                 cluster: undefined,
                 projectUuid: undefined,
                 inTrash: false,
+                pastVersions: false,
                 dateFrom: '',
                 dateTo: '',
                 properties: [
index d9dc0a64905aa5c3596e244f36b935e53bc7d4f4..b010af1448d9c410a64883c4863c0fc2e90b1a2f 100644 (file)
@@ -268,6 +268,7 @@ export const getQueryFromAdvancedData = (data: SearchBarAdvancedFormData, prevDa
             cluster: data.cluster,
             projectUuid: data.projectUuid,
             inTrash: data.inTrash,
+            pastVersions: data.pastVersions,
             dateFrom: data.dateFrom,
             dateTo: data.dateTo,
         };
@@ -282,6 +283,7 @@ export const getQueryFromAdvancedData = (data: SearchBarAdvancedFormData, prevDa
         ['cluster', 'cluster'],
         ['project', 'projectUuid'],
         [`is:${parser.States.TRASHED}`, 'inTrash'],
+        [`is:${parser.States.PAST_VERSION}`, 'pastVersions'],
         ['from', 'dateFrom'],
         ['to', 'dateTo']
     ];
@@ -307,6 +309,7 @@ export const getAdvancedDataFromQuery = (query: string, vocabulary?: Vocabulary)
         cluster: getValue(Keywords.CLUSTER),
         projectUuid: getValue(Keywords.PROJECT),
         inTrash: parser.isTrashed(tokens),
+        pastVersions: parser.isPastVersion(tokens),
         dateFrom: getValue(Keywords.FROM) || '',
         dateTo: getValue(Keywords.TO) || '',
         properties: vocabulary
index c9b7024b921ecb4e1c232779df420ce25c1fa34b..1d0618c6fcc936b1a8cc05db5b7716f0ceecee62 100644 (file)
@@ -20,7 +20,8 @@ export enum Keywords {
 }
 
 export enum States {
-    TRASHED = 'trashed'
+    TRASHED = 'trashed',
+    PAST_VERSION = 'pastVersion'
 }
 
 const keyValuePattern = (key: string) => new RegExp(`${key}:([^ ]*)`);
@@ -60,12 +61,16 @@ export const getProperties = (tokens: string[]) =>
     }, [] as Property[]);
 
 
-export const isTrashed = (tokens: string[]) => {
+export const isTrashed = (tokens: string[]) => isSomeState(States.TRASHED, tokens);
+
+export const isPastVersion = (tokens: string[]) => isSomeState(States.PAST_VERSION, tokens);
+
+const isSomeState = (state: string, tokens: string[]) => {
     for (const token of tokens) {
         const match = token.match(keyValuePattern(Keywords.IS)) || ['', ''];
         if (match) {
             const [, value] = match;
-            if(value === States.TRASHED) {
+            if(value === state) {
                 return true;
             }
         }
index f054a4e4e83637949ad60665ca17647fbbc7f7c4..6d2dce7ceae48662e2c177e9c95834b7ade1408e 100644 (file)
@@ -77,7 +77,8 @@ const getParams = (dataExplorer: DataExplorer, query: string, apiRevision: numbe
         typeFilters(dataExplorer.columns)
     ),
     order: getOrder(dataExplorer),
-    includeTrash: getAdvancedDataFromQuery(query).inTrash
+    includeTrash: getAdvancedDataFromQuery(query).inTrash,
+    includeOldVersions: getAdvancedDataFromQuery(query).pastVersions
 });
 
 const getOrder = (dataExplorer: DataExplorer) => {
index 837f13cb548b3144e8677f086030665cd02a366f..2eea38c4c85827466d2fcb1344432c20a714a702 100644 (file)
@@ -71,6 +71,12 @@ export const SearchBarTrashField = () =>
         component={CheckboxField}
         label="In trash" />;
 
+export const SearchBarPastVersionsField = () =>
+    <Field
+        name='pastVersions'
+        component={CheckboxField}
+        label="Past versions" />;
+
 export const SearchBarDateFromField = () =>
     <Field
         name='dateFrom'
index 71d32ad7e95dd51efa91ee4794b6e4172154cbc1..9f9688c345ad4f08c41b700901b9bb5eb73b8f88 100644 (file)
@@ -17,7 +17,7 @@ import { SearchBarAdvancedFormData } from '~/models/search-bar';
 import {
     SearchBarTypeField, SearchBarClusterField, SearchBarProjectField, SearchBarTrashField,
     SearchBarDateFromField, SearchBarDateToField, SearchBarPropertiesField,
-    SearchBarSaveSearchField, SearchBarQuerySearchField
+    SearchBarSaveSearchField, SearchBarQuerySearchField, SearchBarPastVersionsField
 } from '~/views-components/form-fields/search-bar-form-fields';
 import { treePickerActions } from "~/store/tree-picker/tree-picker-actions";
 
@@ -141,6 +141,9 @@ export const SearchBarAdvancedView = compose(
                                 <Grid item xs={5}>
                                     <SearchBarTrashField />
                                 </Grid>
+                                <Grid item xs={5}>
+                                    <SearchBarPastVersionsField />
+                                </Grid>
                             </Grid>
                             <IconButton onClick={closeAdvanceView} className={classes.closeIcon}>
                                 <CloseIcon />