PermissionState
ComplexAccess
<co-permission-state>PermissionState renders the four role-based states with the screens' exact wording: lock (view only), denied (no access), patient preview, and hidden.
import { PermissionState } from 'health-components';
Examples
Showcase
Lock
Denied
Preview
Hidden
PermissionDenied
Usage
{access === "view" && <PermissionState kind="lock" role="Biller" permission="Edit clinical chart" />}
{access === "none" && <PermissionState kind="denied" role="Front Desk" permission="Manage claims" />}
When to use
- Top of any screen the role can only view (lock), in place of a screen the role cannot open (denied), staff looking at portal screens (preview).
When not to use
- Errors from the server: Alert error.
Variants and states
| Variant | What it is |
|---|---|
| lock | View level: banner, fields read-only, save buttons hidden. |
| denied | None level reached by link: full card with Go to my home screen and Compare roles. |
| preview | Staff viewing patient screens. |
| hidden | None level inside a screen: render nothing. Shown here only as a note. |
Accessibility
- denied is role alert; lock is role status.
Do and don't
- Do: Always name the role and the permission.
- Don't: Disable buttons without saying why.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
kind | PermissionStateKind | 'lock' | 'lock' | 'denied' | 'preview' | 'hidden' |
role * | string | — | The viewer's role ("Biller", "Front Desk"). Required |
permission | string | "Manage claims" | Permission the role lacks; required for lock and denied |
home | string | none | Href of the staff home: "Back to staff app" (preview) and "Go to my home screen" (denied) |
onHome | (event: MouseEvent<HTMLElement>) => void | none | "Go to my home screen" (denied) or "Back to staff app" (preview) clicked |
onCompareRoles | () => void | none | "Compare roles" clicked (denied) |
Also accepts native attributes, including defaultChecked, defaultValue, autoFocus, plus className and event handlers on the root element.
Angular, Vue and HTML
Register the elements once (Angular guide), then use <co-permission-state>. Attributes take strings; arrays and objects are set as properties (Angular [prop], Vue :prop) or as JSON attributes. Callbacks are DOM events with the value in event.detail.
Angular template
<co-permission-state kind="…" role="…" [defaultValue]="defaultValue" (co-home)="onHome($event.detail)"></co-permission-state>
| Kind | Name | Description |
|---|---|---|
| attribute | kind | 'lock' | 'denied' | 'preview' | 'hidden'; default 'lock' |
| attribute | role | The viewer's role ("Biller", "Front Desk"). Required |
| attribute | permission | Permission the role lacks; required for lock and denied; default "Manage claims" |
| attribute | home | Href of the staff home: "Back to staff app" (preview) and "Go to my home screen" (denied); default none |
| attribute | default-checked / defaultChecked | |
| property / JSON attribute | default-value / defaultValue | |
| attribute | auto-focus / autoFocus | |
| event | co-home | "Go to my home screen" (denied) or "Back to staff app" (preview) clicked; default none (React: onHome) |
| event | co-compare-roles | "Compare roles" clicked (denied); default none (React: onCompareRoles) |