permission-matrix
Builds Avatar Button ButtonGroup Checkbox CommandPalette ContextMenu DescriptionList Divider EmptyState GradientSpinner Icon IconButton List Menu PermissionMatrix Popover ProgressBar PulseLoader Skeleton SplitButton Tag Timeline


The code that drew it
A still frame holds a repeating animation at its first frame and a one-shot at its last, because a still of a moving thing is not reproducible. Run the gallery to review motion.
fn permission_matrix(_window: &mut Window, cx: &mut App) -> AnyElement {
let theme = cx.theme().clone();
let actions = [
PermissionAction::new("read", "Read files"),
PermissionAction::new("write", "Write files"),
PermissionAction::new("network", "Reach the network"),
];
let subjects = [
PermissionSubject::new("workspace", "This workspace")
.cell("read", PermissionEntry::new(PermissionState::Allowed))
.cell("write", PermissionEntry::new(PermissionState::Ask))
.cell(
"network",
PermissionEntry::inherited(PermissionState::Denied, "the organisation policy"),
),
PermissionSubject::new("scratch", "The scratch directory")
.cell(
"read",
PermissionEntry::inherited(PermissionState::Allowed, "this workspace"),
)
.cell("write", PermissionEntry::new(PermissionState::Allowed))
.cell(
"network",
PermissionEntry::inherited(PermissionState::Denied, "the organisation policy"),
),
// A calculator has no files to read, which is not the same as being
// refused them.
PermissionSubject::new("calculator", "The calculator tool")
.cell("network", PermissionEntry::new(PermissionState::Denied)),
];
stack(&theme)
.w(px(720.0))
.child(
PermissionMatrix::new("scene.permission.editable")
.actions(actions.clone())
.subjects(subjects.clone())
.on_change(|_change, _window, _cx| {}),
)
.child(
Divider::new()
.id("scene.permission.rule.read-only")
.label("The same permissions, shown rather than offered"),
)
.child(
PermissionMatrix::new("scene.permission.read-only")
.actions(actions)
.subjects(subjects),
)
.into_any_element()
}