// What organization members may do (see lib/orgs.ts), shared with the pages that change it. /** From least to most. */ export const ORG_ROLES = ["read", "write", "admin", "owner"] as const; export type OrgRole = (typeof ORG_ROLES)[number]; export const ROLE_INFO: Record = { read: { title: "Read", description: "Sees all of the organization’s repositories, private ones too, and can open issues and comment." }, write: { title: "Write", description: "Also pushes to every repository and manages issues and pull requests." }, admin: { title: "Admin", description: "Also creates repositories, changes their settings and deletes them." }, owner: { title: "Owner", description: "Full control: also manages the organization, its members and invitations." }, }; export const isOrgRole = (value: unknown): value is OrgRole => ORG_ROLES.includes(value as OrgRole); export const roleAtLeast = (role: OrgRole | null, need: OrgRole) => !!role && ORG_ROLES.indexOf(role) >= ORG_ROLES.indexOf(need); /** What a role gives its member in each of the organization's repositories. */ export const repoAccessOfRole = (role: OrgRole) => (role === "owner" || role === "admin" ? "admin" : role);