projects
/
arvados-workbench2.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactor to apply global navigation actions
[arvados-workbench2.git]
/
src
/
models
/
resource.ts
diff --git
a/src/models/resource.ts
b/src/models/resource.ts
index 3b30b08898701b6f0b4107ac5ce481995d180078..ff95c1a9b8df59872d6819dccdbcfb2b8ee92441 100644
(file)
--- a/
src/models/resource.ts
+++ b/
src/models/resource.ts
@@
-30,16
+30,22
@@
export enum ResourceObjectType {
COLLECTION = '4zz18'
}
COLLECTION = '4zz18'
}
+export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
+export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
+
+export const isResourceUuid = (uuid: string) =>
+ RESOURCE_UUID_REGEX.test(uuid);
+
export const extractUuidObjectType = (uuid: string) => {
export const extractUuidObjectType = (uuid: string) => {
- const match =
/(.{5})-(.{5})-(.{15})/
.exec(uuid);
+ const match =
RESOURCE_UUID_REGEX
.exec(uuid);
return match
return match
- ? match[
2
]
+ ? match[
0].split('-')[1
]
: undefined;
};
export const extractUuidKind = (uuid: string = '') => {
const objectType = extractUuidObjectType(uuid);
: undefined;
};
export const extractUuidKind = (uuid: string = '') => {
const objectType = extractUuidObjectType(uuid);
- switch
(objectType)
{
+ switch
(objectType)
{
case ResourceObjectType.USER:
return ResourceKind.USER;
case ResourceObjectType.GROUP:
case ResourceObjectType.USER:
return ResourceKind.USER;
case ResourceObjectType.GROUP: