Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 20x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 21x 1x | import {model} from '@feasibleone/blong';
/**
* Tri-state ACL cell: clicking cycles allow → deny → blank (no rule — RBAC
* alone), so the matrix is edited without row-edit mode. `label` is the cell's
* accessible name and what the Playwright helper matches on.
*/
const ACL_MATRIX_CELL = {
type: 'cycle',
states: [
{value: 'allow', icon: 'pi pi-check text-green-500', label: 'Allow'},
{value: 'deny', icon: 'pi pi-times text-red-500', label: 'Deny'},
{value: null, label: 'Not set'},
],
};
/**
* accessRoleModel — role management (Browse/New/Open).
*
* `roleName` is the display name (lives in `core_resource.resourceName`, not a
* table column) and is provided by the custom `access.role.find/get/add/edit`
* handlers. The `capability` detail is a pivot grid over the
* `access.capability` dropdown backed by the `hasCapability` graph edges.
*/
export default model(
() =>
async function accessRoleModel() {
return {
subject: 'access',
object: 'role',
objectTitle: 'Role',
public: true,
nameField: 'role.roleName',
schema: {
properties: {
role: {
properties: {
roleName: {
title: 'Name',
filter: true,
sort: true,
},
roleBit: {
// No default on purpose: an empty field asks
// `access.role.add` to allocate a free bit,
// and a bit never moves once assigned.
title: 'Bit',
filter: true,
},
description: {
title: 'Description',
widget: {type: 'textArea'},
},
// server schema defined:
// roleId: {},
},
widget: {
columns: ['roleName', 'roleBit', 'description'],
},
},
capability: {
items: {
properties: {
capabilityId: {},
capabilityName: {
title: 'Capability',
readOnly: true,
// Filterable so a caller that means one
// capability can narrow the grid to it: the
// pivot's rows are the whole dropdown in
// whatever order the database returns them,
// so an unfiltered capture shows whichever
// row happens to be first (T-173's defect,
// and the reason `user.play.ts` names its
// role).
filter: true,
},
granted: {
title: 'Granted',
type: 'boolean',
},
},
},
widget: {
type: 'table',
pivot: {
dropdown: 'access.capability',
join: {
value: 'capabilityId',
label: 'capabilityName',
},
},
columns: ['capabilityName', 'granted'],
},
},
effective: {
title: 'Effective Access',
items: {
properties: {
principalName: {title: 'Granted via', readOnly: true},
source: {title: 'Source', readOnly: true},
actionName: {title: 'Action', readOnly: true},
targetKind: {title: 'Kind', readOnly: true},
targetName: {title: 'Target', readOnly: true},
effect: {title: 'Effect', readOnly: true},
},
},
widget: {
type: 'table',
columns: [
'principalName',
'source',
'actionName',
'targetKind',
'targetName',
'effect',
],
actions: {allowAdd: false, allowEdit: false, allowDelete: false},
},
},
matrix: {
title: 'Record Access (ACL)',
items: {
properties: {
targetId: {
title: 'Scope',
widget: {type: 'dropdown', dropdown: 'access.aclTarget'},
},
targetName: {title: 'Scope', readOnly: true, filter: true},
// Fixed per matrix: the row identity is the
// scope, the entity comes from the pivot
// defaults (`partyPerson`).
entityName: {title: 'Entity', readOnly: true, filter: true},
find: {title: 'Find', widget: ACL_MATRIX_CELL},
get: {title: 'Get', widget: ACL_MATRIX_CELL},
add: {title: 'Add', widget: ACL_MATRIX_CELL},
edit: {title: 'Edit', widget: ACL_MATRIX_CELL},
remove: {title: 'Remove', widget: ACL_MATRIX_CELL},
},
},
widget: {
type: 'table',
pivot: {
dropdown: 'access.aclTarget',
join: {value: 'targetId', label: 'targetName'},
defaults: {entityName: 'partyPerson'},
},
columns: [
'targetName',
'entityName',
'find',
'get',
'add',
'edit',
'remove',
],
},
},
},
},
details: [{object: 'capability'}],
cards: {
browse: {
label: 'Roles',
widgets: ['role'],
},
edit: {
label: 'Role Details',
widgets: ['role.roleName', 'role.roleBit', 'role.description'],
},
'details-effective': {label: 'Access', widgets: ['effective']},
'details-matrix': {label: 'Record Access', widgets: ['matrix']},
},
layouts: {
edit: {
items: [
{id: 'edit', label: 'Role', widgets: ['edit']},
{
id: 'capability',
label: 'Capability',
widgets: ['details-capability'],
},
{id: 'access', label: 'Access', widgets: ['details-effective']},
{
id: 'matrix',
label: 'Record Access',
widgets: ['details-matrix'],
},
],
},
},
browser: {
title: 'Roles',
icon: 'pi pi-key',
},
};
},
);
|