Refactors custom components to enable shared state accessors (like `authState`) and helpers (like `api.fetch`.) Schemas are now defined with [zod](https://zod.dev/?id=basic-usage) which enables runtime schema validation. See subtasks for full description of change: - https://github.com/webrecorder/browsertrix/pull/1979 - https://github.com/webrecorder/browsertrix/pull/1981 - https://github.com/webrecorder/browsertrix/pull/1985 - https://github.com/webrecorder/browsertrix/pull/1986 --------- Co-authored-by: Emma Segal-Grossman <hi@emma.cafe>
34 lines
774 B
TypeScript
34 lines
774 B
TypeScript
import { AccessCode, type OrgData } from "@/types/org";
|
|
|
|
export * from "@/types/org";
|
|
|
|
export function isOwner(accessCode?: AccessCode): boolean {
|
|
if (!accessCode) return false;
|
|
|
|
return accessCode === AccessCode.owner;
|
|
}
|
|
|
|
export function isAdmin(accessCode?: AccessCode): boolean {
|
|
if (!accessCode) return false;
|
|
|
|
return accessCode >= AccessCode.owner;
|
|
}
|
|
|
|
export function isCrawler(accessCode?: AccessCode): boolean {
|
|
if (!accessCode) return false;
|
|
|
|
return accessCode >= AccessCode.crawler;
|
|
}
|
|
|
|
export function isArchivingDisabled(
|
|
org?: OrgData | null,
|
|
checkExecMinutesQuota = false,
|
|
): boolean {
|
|
return Boolean(
|
|
!org ||
|
|
org.readOnly ||
|
|
org.storageQuotaReached ||
|
|
(checkExecMinutesQuota ? org.execMinutesQuotaReached : false),
|
|
);
|
|
}
|