mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 00:37:47 +00:00
EZQMS-649: Moved some common utilities from Uberflow to Platform (#4927)
Signed-off-by: Petr Vyazovetskiy <develop.pit@gmail.com>
This commit is contained in:
parent
aac81144fe
commit
866b140a96
@ -49,6 +49,11 @@ export function generateId<T extends Doc> (join: string = ''): Ref<T> {
|
||||
return (timestamp() + join + random + join + count()) as Ref<T>
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export function isId (value: any): value is Ref<any> {
|
||||
return typeof value === 'string' && /^[0-9a-f]{24,24}$/.test(value)
|
||||
}
|
||||
|
||||
let currentAccount: Account
|
||||
|
||||
/**
|
||||
@ -531,3 +536,9 @@ export function cutObjectArray (obj: any): any {
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
export const isEnum =
|
||||
<T>(e: T) =>
|
||||
(token: any): token is T[keyof T] => {
|
||||
return typeof token === 'string' && Object.values(e as Record<string, any>).includes(token)
|
||||
}
|
||||
|
@ -132,6 +132,11 @@ if (!embeddedPlatform) {
|
||||
|
||||
export const location = derived(locationWritable, (loc) => justClone(loc))
|
||||
|
||||
/**
|
||||
* Unlike {@link location}, exposes raw browser location as seen in URL
|
||||
*/
|
||||
export const rawLocation = derived(locationWritable, () => getCurrentLocation())
|
||||
|
||||
export const workspaceId = derived(location, (loc) => loc.path[1])
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user