Spaces:
Sleeping
Sleeping
Download src/lib/share-access.ts from ashnhash/UniHunt: direct link, hf CLI and curl.
- Browser
- Download file 840 Bytes
-
https://huggingface.co/spaces/ashnhash/UniHunt/resolve/main/src/lib/share-access.ts
- Command line
-
hf download hf://spaces/ashnhash/UniHunt/src/lib/share-access.ts
-
curl -L -o share-access.ts https://huggingface.co/spaces/ashnhash/UniHunt/resolve/main/src/lib/share-access.ts
840 Bytes
| export const SHARE_PERMISSIONS = ["read", "comment", "edit", "delete"] as const; | |
| export type SharePermission = (typeof SHARE_PERMISSIONS)[number]; | |
| export type ShortlistAccess = SharePermission | "owner"; | |
| const RANK: Record<ShortlistAccess, number> = { | |
| read: 1, | |
| comment: 2, | |
| edit: 3, | |
| delete: 4, | |
| owner: 5, | |
| }; | |
| export function permissionAllows( | |
| actual: ShortlistAccess | null | undefined, | |
| required: SharePermission | |
| ): boolean { | |
| if (!actual) return false; | |
| return RANK[actual] >= RANK[required]; | |
| } | |
| export function sharePermissionLabel(permission: SharePermission): string { | |
| switch (permission) { | |
| case "read": | |
| return "View only"; | |
| case "comment": | |
| return "View and comment"; | |
| case "edit": | |
| return "View, comment, and edit"; | |
| case "delete": | |
| return "View, comment, edit, and delete"; | |
| } | |
| } | |