16583: Add "Intermediate" to collection type filters
[arvados-workbench2.git] / src / models / resource.ts
index 6f82402821ec26fc9c8cc5ea94876df6dfa4c508..fd86727782c2960b15ee78d4237da4dcc53363b4 100644 (file)
@@ -2,8 +2,6 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { ApiClientAuthorization } from '~/models/api-client-authorization';
-
 export interface Resource {
     uuid: string;
     ownerUuid: string;
@@ -16,7 +14,13 @@ export interface Resource {
     etag: string;
 }
 
-export type ResourceTypes = Resource | ApiClientAuthorization;
+export interface ResourceWithProperties extends Resource {
+    properties: any;
+}
+
+export interface EditableResource extends Resource {
+    isEditable: boolean;
+}
 
 export interface TrashableResource extends Resource {
     trashAt: string;
@@ -32,7 +36,6 @@ export enum ResourceKind {
     GROUP = "arvados#group",
     LINK = "arvados#link",
     LOG = "arvados#log",
-    NODE = "arvados#node",
     PROCESS = "arvados#containerRequest",
     PROJECT = "arvados#group",
     REPOSITORY = "arvados#repository",
@@ -57,12 +60,13 @@ export enum ResourceObjectType {
     VIRTUAL_MACHINE = '2x53u',
     WORKFLOW = '7fd4e',
     SSH_KEY = 'fngyi',
-    KEEP_SERVICE = 'bi6l4',
-    NODE = '7ekkf'
+    KEEP_SERVICE = 'bi6l4'
 }
 
-export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
-export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
+export const RESOURCE_UUID_PATTERN = '[a-z0-9]{5}-[a-z0-9]{5}-[a-z0-9]{15}';
+export const PORTABLE_DATA_HASH_PATTERN = '[a-f0-9]{32}\\+\\d+';
+export const RESOURCE_UUID_REGEX = new RegExp("^" + RESOURCE_UUID_PATTERN + "$");
+export const COLLECTION_PDH_REGEX = new RegExp("^" + PORTABLE_DATA_HASH_PATTERN + "$");
 
 export const isResourceUuid = (uuid: string) =>
     RESOURCE_UUID_REGEX.test(uuid);
@@ -99,13 +103,12 @@ export const extractUuidKind = (uuid: string = '') => {
             return ResourceKind.SSH_KEY;
         case ResourceObjectType.KEEP_SERVICE:
             return ResourceKind.KEEP_SERVICE;
-        case ResourceObjectType.NODE:
-            return ResourceKind.NODE;
         case ResourceObjectType.API_CLIENT_AUTHORIZATION:
             return ResourceKind.API_CLIENT_AUTHORIZATION;
         case ResourceObjectType.LINK:
             return ResourceKind.LINK;
         default:
-            return undefined;
+            const match = COLLECTION_PDH_REGEX.exec(uuid);
+            return match ? ResourceKind.COLLECTION : undefined;
     }
 };