18559: Remove dead code
[arvados-workbench2.git] / src / store / search-bar / search-query / arv-parser.ts
index 3a52be6c822f5030cd842787a8e51afd2bacbccd..5331d2a19d011024de3c1127ed9f339d28c28976 100644 (file)
@@ -3,7 +3,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import * as parser from '~/store/search-bar/search-query/parser';
+import * as parser from 'store/search-bar/search-query/parser';
 
 interface Property {
     key: string;
@@ -19,6 +19,11 @@ export enum Keywords {
     TO = 'to',
 }
 
+export enum States {
+    TRASHED = 'trashed',
+    PAST_VERSION = 'pastVersion'
+}
+
 const keyValuePattern = (key: string) => new RegExp(`${key}:([^ ]*)`);
 const propertyPattern = /has:"(.*?)":"(.*?)"/;
 
@@ -54,3 +59,21 @@ export const getProperties = (tokens: string[]) =>
         }
         return properties;
     }, [] as Property[]);
+
+
+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 === state) {
+                return true;
+            }
+        }
+    }
+    return false;
+};