import { type ReactNode } from 'react'; import { type AccessModel } from './model.js'; import type { SearchPrincipals } from './PrincipalPicker.js'; import { type AccessStrings } from './strings.js'; import type { AccessChange, AccessGrant, AccessGroupDetails, AccessInheritedGrant, AccessPermission, AccessPrincipal, AccessRole, AccessRule, AccessVisibility } from './types.js'; export type AccessArrangement = 'role' | 'principal'; /** What the drawer and the inline panel share: everything but where they sit. */ export interface AccessEditorProps { /** What access is to, as the reader knows it: "gpu-cluster-east". */ resourceName: string; /** Every role that can be granted here, in the order to list them, and any held here only * through somewhere else (`grantable: false`). */ roles: readonly AccessRole[]; /** Every person and group that holds a role here or owns it, the groups those people are in, * and everyone when the resource can be granted to everyone. Without `searchPrincipals`, * also everyone who can be granted one. */ principals: readonly AccessPrincipal[]; /** Who holds which role. The drawer shows these and never changes them itself. */ grants: readonly AccessGrant[]; /** The principal who owns it, among `principals`: it has every permission, always, and can't * be removed. */ owner?: string | undefined; /** Roles held through something the resource is part of, such as its organization: they * show, locked, and count toward what someone keeps. */ inherited?: readonly AccessInheritedGrant[] | undefined; /** Names the permissions roles list, for what someone loses when they lose a role. */ permissions?: readonly AccessPermission[] | undefined; /** Saves a change. Return a promise that settles once it is saved: until then its rows show * that they are saving, and when it rejects the drawer says that nothing changed and offers * to try again. Pass the new grants back through `grants`. */ onChange?: ((change: AccessChange) => void | Promise) | undefined; /** The grants are still loading: skeletons hold their place. */ loading?: boolean | undefined; /** Shows who has access without letting the reader change it. */ readOnly?: boolean | undefined; /** Who can change it, said in read-only mode: "Only people with the Admin role can change it." */ readOnlyReason?: ReactNode; /** More about a group, asked for when it is highlighted in the picker and kept while the * drawer is mounted. A highlight that moves on aborts `signal`. */ describeGroup?: ((groupId: string, signal: AbortSignal) => Promise) | undefined; /** Finds people and groups to grant to, for an organization with too many to pass in * `principals`. A newer query aborts `signal`. Without it, the picker filters `principals`. */ searchPrincipals?: SearchPrincipals | undefined; /** How many groups the organization has, for the picker's hint and heading. */ groupCount?: number | undefined; /** How many people the organization has, for the picker's hint and heading. */ peopleCount?: number | undefined; /** People and groups the reader granted to lately, listed first in the picker. */ recentPrincipalIds?: readonly string[] | undefined; /** How the list starts out: role by role, or person and group one by one. Person by person * where each holds one role, role by role otherwise. */ defaultArrangement?: AccessArrangement | undefined; /** A switch above the list between open to everyone who can see what the resource is in * and only those listed. It saves as a grant does, with Undo in a toast. */ visibility?: AccessVisibility | undefined; /** Reasons someone has access that no grant here changes, such as admins who always do: * locked rows ahead of the grants. */ rules?: readonly AccessRule[] | undefined; /** Each person and group holds one role here. Their row picks it from a list, a change * swaps the old role for the new one in a single change, and the grant form picks one. */ singleRole?: boolean | undefined; /** Why a save failed, in the reader's words, under "Couldn’t grant…": a fixed sentence, or * one made from what `onChange` rejected with, such as a localized message for its error * code. Without it, a generic sentence; the error's own message never shows, as a * server's words aren't the reader's. */ errorMessage?: string | ((error: unknown) => string | undefined) | undefined; /** Access here is set somewhere else, such as on what the resource is part of: the list * shows, read-only, under a note that says where, with a link there. */ managedElsewhere?: AccessManagedElsewhere | undefined; } export interface AccessManagedElsewhere { /** Where access is set and why: "This team follows the workspace’s access." Without it, a * generic sentence. */ reason?: ReactNode; /** Where to change it, through the host's router. */ href?: string | undefined; /** The link's text, which says where it goes: "Workspace access". Without it, "Manage * access". */ linkLabel?: string | undefined; } export interface AccessDrawerProps extends AccessEditorProps { open: boolean; onClose: () => void; /** As `Drawer`'s. */ width?: number | string | undefined; } export interface AccessPanelProps extends AccessEditorProps { /** On the panel's frame. */ className?: string | undefined; /** Under the list, inside the frame and ruled off from it: a note or actions about access * as a whole. The grant form takes its place while it shows. */ footer?: ReactNode; } /** Who has access to one resource, and the place to change it: roles granted to people and * groups. Overlapping roles are allowed and only redundant, which the drawer points out; taking * a role away first says exactly what is lost. The owner and roles granted above the resource * show, locked. Each change is saved as it is made, with Undo in a toast. `AccessPanel` is the * same editor inline on a page. */ export declare function AccessDrawer({ open, onClose, width, ...props }: AccessDrawerProps): import("react").JSX.Element; /** The access editor inline on a page, such as a settings section, rather than in a drawer: the * list in a frame, which the grant form takes over with a back arrow in its own header. */ export declare function AccessPanel({ className, footer, ...props }: AccessPanelProps): import("react").JSX.Element; type Match = (query: string, ...texts: (string | undefined)[]) => boolean; export declare function filterAccess(model: AccessModel, arrangement: AccessArrangement, query: string, match: Match, t: AccessStrings): { shown: Map; order: string[]; }; export {};