@zealamic/payload-auth-rbac-plugin 1.0.0-beta.1 → 1.0.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/cover-photo.jpg +0 -0
- package/dist/collections/permission-actions/default-data.d.ts +2 -0
- package/dist/collections/permission-actions/index.d.ts +3 -0
- package/dist/collections/permission-actions/types.d.ts +51 -0
- package/dist/collections/permission-features/default-data.d.ts +2 -0
- package/dist/collections/permission-features/index.d.ts +3 -0
- package/dist/collections/permission-features/types.d.ts +43 -0
- package/dist/collections/permissions/default-data.d.ts +2 -0
- package/dist/collections/permissions/index.d.ts +3 -0
- package/dist/collections/permissions/types.d.ts +54 -0
- package/dist/collections/roles/default-data.d.ts +2 -0
- package/dist/collections/roles/hooks/sync-permission-matrix-draft.d.ts +6 -0
- package/dist/collections/roles/index.d.ts +3 -0
- package/dist/collections/roles/types.d.ts +53 -0
- package/dist/collections/roles-permissions/default-data.d.ts +2 -0
- package/dist/collections/roles-permissions/index.d.ts +3 -0
- package/dist/collections/roles-permissions/types.d.ts +39 -0
- package/dist/collections/users/default-data.d.ts +2 -0
- package/dist/collections/users/index.d.ts +3 -0
- package/dist/collections/users/parent-path.d.ts +31 -0
- package/dist/collections/users/types.d.ts +23 -0
- package/dist/components/role-permission-matrix-client/default-data.d.ts +2 -0
- package/dist/components/role-permission-matrix-client/default-data.js +2 -1
- package/dist/components/role-permission-matrix-client/default-data.js.map +1 -1
- package/dist/components/role-permission-matrix-client/index.d.ts +1 -0
- package/dist/components/role-permission-matrix-client/index.js +18 -68
- package/dist/components/role-permission-matrix-client/index.js.map +1 -1
- package/dist/components/role-permission-matrix-client/matrix.module.scss +69 -0
- package/dist/components/role-permission-matrix-client/types.d.ts +18 -0
- package/dist/endpoints/customEndpointHandler.d.ts +2 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/lib/constants/general.d.ts +1 -0
- package/dist/lib/constants/index.d.ts +14 -0
- package/dist/lib/constants/permission-action.d.ts +8 -0
- package/dist/lib/constants/permission-feature.d.ts +4 -0
- package/dist/lib/constants/permission.d.ts +4 -0
- package/dist/lib/constants/role.d.ts +9 -0
- package/dist/lib/constants/user.d.ts +1 -0
- package/dist/lib/utils/access.d.ts +76 -0
- package/dist/lib/utils/data.d.ts +6 -0
- package/dist/lib/utils/fields.d.ts +18 -0
- package/dist/lib/utils/index.d.ts +4 -0
- package/dist/lib/utils/localization.d.ts +27 -0
- package/dist/styles/variables.scss +1 -0
- package/dist/types.d.ts +38 -0
- package/docs/COLLECTIONS.md +426 -0
- package/docs/TRANSLATIONS.md +462 -0
- package/docs/UTILS.md +221 -0
- package/package.json +21 -4
|
Binary file
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from "payload";
|
|
2
|
+
import { STATUS, TYPE } from "../../lib/constants/permission-action.js";
|
|
3
|
+
export type PermissionActionsCollectionTranslations = {
|
|
4
|
+
[locale: string]: {
|
|
5
|
+
labels?: {
|
|
6
|
+
singular?: string;
|
|
7
|
+
plural?: string;
|
|
8
|
+
};
|
|
9
|
+
admin?: {
|
|
10
|
+
group?: string;
|
|
11
|
+
};
|
|
12
|
+
fields?: {
|
|
13
|
+
code?: {
|
|
14
|
+
label?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
};
|
|
17
|
+
type?: {
|
|
18
|
+
label?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
mainLabel?: string;
|
|
21
|
+
subLabel?: string;
|
|
22
|
+
};
|
|
23
|
+
sortOrder?: {
|
|
24
|
+
label?: string;
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
};
|
|
27
|
+
status?: {
|
|
28
|
+
label?: string;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
activeLabel?: string;
|
|
31
|
+
inactiveLabel?: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
export type PermissionActionsCollectionParams = {
|
|
37
|
+
translations?: PermissionActionsCollectionTranslations;
|
|
38
|
+
fields?: Field[];
|
|
39
|
+
access?: CollectionConfig["access"];
|
|
40
|
+
labels?: CollectionConfig["labels"];
|
|
41
|
+
admin?: CollectionConfig["admin"];
|
|
42
|
+
};
|
|
43
|
+
export type PermissionActionStatus = (typeof STATUS)[keyof typeof STATUS];
|
|
44
|
+
export type PermissionActionType = (typeof TYPE)[keyof typeof TYPE];
|
|
45
|
+
export type PermissionAction = {
|
|
46
|
+
id: string | number;
|
|
47
|
+
code?: string | null;
|
|
48
|
+
sortOrder?: number | null;
|
|
49
|
+
type?: PermissionActionType | null;
|
|
50
|
+
status?: PermissionActionStatus | null;
|
|
51
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from "payload";
|
|
2
|
+
import { STATUS } from "../../lib/constants/permission-feature.js";
|
|
3
|
+
export type PermissionFeaturesCollectionTranslations = {
|
|
4
|
+
[locale: string]: {
|
|
5
|
+
labels?: {
|
|
6
|
+
singular?: string;
|
|
7
|
+
plural?: string;
|
|
8
|
+
};
|
|
9
|
+
admin?: {
|
|
10
|
+
group?: string;
|
|
11
|
+
};
|
|
12
|
+
fields?: {
|
|
13
|
+
code?: {
|
|
14
|
+
label?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
};
|
|
17
|
+
sortOrder?: {
|
|
18
|
+
label?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
};
|
|
21
|
+
status?: {
|
|
22
|
+
label?: string;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
activeLabel?: string;
|
|
25
|
+
inactiveLabel?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type PermissionFeaturesCollectionParams = {
|
|
31
|
+
translations?: PermissionFeaturesCollectionTranslations;
|
|
32
|
+
fields?: Field[];
|
|
33
|
+
access?: CollectionConfig["access"];
|
|
34
|
+
labels?: CollectionConfig["labels"];
|
|
35
|
+
admin?: CollectionConfig["admin"];
|
|
36
|
+
};
|
|
37
|
+
export type PermissionFeatureStatus = (typeof STATUS)[keyof typeof STATUS];
|
|
38
|
+
export type PermissionFeature = {
|
|
39
|
+
id: string | number;
|
|
40
|
+
code?: string | null;
|
|
41
|
+
sortOrder?: number | null;
|
|
42
|
+
status?: PermissionFeatureStatus | null;
|
|
43
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from "payload";
|
|
2
|
+
import { STATUS } from "src/lib/constants/permission.js";
|
|
3
|
+
export type PermissionsCollectionTranslations = {
|
|
4
|
+
[locale: string]: {
|
|
5
|
+
labels?: {
|
|
6
|
+
singular?: string;
|
|
7
|
+
plural?: string;
|
|
8
|
+
};
|
|
9
|
+
admin?: {
|
|
10
|
+
group?: string;
|
|
11
|
+
};
|
|
12
|
+
fields?: {
|
|
13
|
+
name?: {
|
|
14
|
+
label?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
};
|
|
17
|
+
permissionFeature?: {
|
|
18
|
+
label?: string;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
};
|
|
21
|
+
permissionAction?: {
|
|
22
|
+
label?: string;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
};
|
|
25
|
+
sortOrder?: {
|
|
26
|
+
label?: string;
|
|
27
|
+
placeholder?: string;
|
|
28
|
+
};
|
|
29
|
+
status?: {
|
|
30
|
+
label?: string;
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
activeLabel?: string;
|
|
33
|
+
inactiveLabel?: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
export type PermissionsCollectionParams = {
|
|
39
|
+
translations?: PermissionsCollectionTranslations;
|
|
40
|
+
fields?: Field[];
|
|
41
|
+
access?: CollectionConfig["access"];
|
|
42
|
+
labels?: CollectionConfig["labels"];
|
|
43
|
+
admin?: CollectionConfig["admin"];
|
|
44
|
+
};
|
|
45
|
+
export type PermissionItemRef = string | number | {
|
|
46
|
+
id?: string | number;
|
|
47
|
+
};
|
|
48
|
+
export type PermissionStatus = (typeof STATUS)[keyof typeof STATUS];
|
|
49
|
+
export type Permission = {
|
|
50
|
+
id: string | number;
|
|
51
|
+
permissionFeature?: PermissionItemRef;
|
|
52
|
+
permissionAction?: PermissionItemRef;
|
|
53
|
+
status?: PermissionStatus | null;
|
|
54
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CollectionAfterChangeHook } from "payload";
|
|
2
|
+
/**
|
|
3
|
+
* Persists `permissionMatrixDraft` on the role document into `roles-permissions` rows.
|
|
4
|
+
* RBAC checks use `roles-permissions`, not the JSON draft field.
|
|
5
|
+
*/
|
|
6
|
+
export declare const syncPermissionMatrixDraftAfterChange: CollectionAfterChangeHook;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from "payload";
|
|
2
|
+
import type { DATA_SCOPE, STATUS } from "../../lib/constants/role.js";
|
|
3
|
+
export type DataScope = (typeof DATA_SCOPE)[keyof typeof DATA_SCOPE];
|
|
4
|
+
export type RoleStatus = (typeof STATUS)[keyof typeof STATUS];
|
|
5
|
+
export type RolesCollectionTranslations = {
|
|
6
|
+
[locale: string]: {
|
|
7
|
+
labels?: {
|
|
8
|
+
singular?: string;
|
|
9
|
+
plural?: string;
|
|
10
|
+
};
|
|
11
|
+
admin?: {
|
|
12
|
+
group?: string;
|
|
13
|
+
};
|
|
14
|
+
fields?: {
|
|
15
|
+
code?: {
|
|
16
|
+
label?: string;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
};
|
|
19
|
+
name?: {
|
|
20
|
+
label?: string;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
};
|
|
23
|
+
description?: {
|
|
24
|
+
label?: string;
|
|
25
|
+
placeholder?: string;
|
|
26
|
+
};
|
|
27
|
+
status?: {
|
|
28
|
+
label?: string;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
activeLabel?: string;
|
|
31
|
+
inactiveLabel?: string;
|
|
32
|
+
};
|
|
33
|
+
dataScope?: {
|
|
34
|
+
label?: string;
|
|
35
|
+
placeholder?: string;
|
|
36
|
+
allLabel?: string;
|
|
37
|
+
ownLabel?: string;
|
|
38
|
+
hierarchyLabel?: string;
|
|
39
|
+
};
|
|
40
|
+
permissionMatrix?: {
|
|
41
|
+
label?: string;
|
|
42
|
+
placeholder?: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export type RolesCollectionParams = {
|
|
48
|
+
translations?: RolesCollectionTranslations;
|
|
49
|
+
fields?: Field[];
|
|
50
|
+
access?: CollectionConfig["access"];
|
|
51
|
+
labels?: CollectionConfig["labels"];
|
|
52
|
+
admin?: CollectionConfig["admin"];
|
|
53
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { CollectionConfig, Field } from "payload";
|
|
2
|
+
export type RolesPermissionsCollectionTranslations = {
|
|
3
|
+
[locale: string]: {
|
|
4
|
+
labels?: {
|
|
5
|
+
singular?: string;
|
|
6
|
+
plural?: string;
|
|
7
|
+
};
|
|
8
|
+
admin?: {
|
|
9
|
+
group?: string;
|
|
10
|
+
};
|
|
11
|
+
fields?: {
|
|
12
|
+
role?: {
|
|
13
|
+
label?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
};
|
|
16
|
+
permission?: {
|
|
17
|
+
label?: string;
|
|
18
|
+
placeholder?: string;
|
|
19
|
+
};
|
|
20
|
+
enabled?: {
|
|
21
|
+
label?: string;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type RolesPermissionsCollectionParams = {
|
|
28
|
+
translations?: RolesPermissionsCollectionTranslations;
|
|
29
|
+
fields?: Field[];
|
|
30
|
+
access?: CollectionConfig["access"];
|
|
31
|
+
labels?: CollectionConfig["labels"];
|
|
32
|
+
admin?: CollectionConfig["admin"];
|
|
33
|
+
};
|
|
34
|
+
export type RolePermission = {
|
|
35
|
+
id: string | number;
|
|
36
|
+
role?: string | number;
|
|
37
|
+
permission?: string | number;
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CollectionAfterChangeHook, CollectionAfterDeleteHook, CollectionBeforeChangeHook, PayloadRequest } from "payload";
|
|
2
|
+
type UserDoc = {
|
|
3
|
+
id?: string | number;
|
|
4
|
+
parent?: ItemRef;
|
|
5
|
+
parentPath?: string | null;
|
|
6
|
+
};
|
|
7
|
+
/** Ancestor IDs from root to parent (exclusive of self), e.g. `"1,2"`. */
|
|
8
|
+
export declare const buildParentPathFromParentDoc: (parent: UserDoc | null | undefined) => string;
|
|
9
|
+
export declare const computeParentPath: ({ parentId, req, userSlug, }: {
|
|
10
|
+
parentId?: string;
|
|
11
|
+
req: PayloadRequest;
|
|
12
|
+
userSlug: string;
|
|
13
|
+
}) => Promise<string>;
|
|
14
|
+
export declare const createUserParentPathHooks: (userSlug: string) => {
|
|
15
|
+
beforeChange: CollectionBeforeChangeHook;
|
|
16
|
+
afterChange: CollectionAfterChangeHook;
|
|
17
|
+
afterDelete: CollectionAfterDeleteHook;
|
|
18
|
+
};
|
|
19
|
+
export declare const mergeUserCollectionHooks: ({ existingHooks, userSlug, }: {
|
|
20
|
+
existingHooks?: {
|
|
21
|
+
beforeChange?: CollectionBeforeChangeHook[] | CollectionBeforeChangeHook;
|
|
22
|
+
afterChange?: CollectionAfterChangeHook[] | CollectionAfterChangeHook;
|
|
23
|
+
afterDelete?: CollectionAfterDeleteHook[] | CollectionAfterDeleteHook;
|
|
24
|
+
};
|
|
25
|
+
userSlug: string;
|
|
26
|
+
}) => {
|
|
27
|
+
beforeChange: CollectionBeforeChangeHook[];
|
|
28
|
+
afterChange: CollectionAfterChangeHook[];
|
|
29
|
+
afterDelete: CollectionAfterDeleteHook[];
|
|
30
|
+
};
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Field } from "payload";
|
|
2
|
+
export type UsersModificationTranslations = {
|
|
3
|
+
[locale: string]: {
|
|
4
|
+
fields?: {
|
|
5
|
+
isSuperAdmin?: {
|
|
6
|
+
label?: string;
|
|
7
|
+
};
|
|
8
|
+
roles?: {
|
|
9
|
+
label?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
};
|
|
12
|
+
parent?: {
|
|
13
|
+
label?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export type UsersModificationParams = {
|
|
20
|
+
translations?: UsersModificationTranslations;
|
|
21
|
+
fields?: Field[];
|
|
22
|
+
rolesSlug?: string;
|
|
23
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/role-permission-matrix-client/default-data.ts"],"sourcesContent":["import type { RolePermissionMatrixClientTranslations } from \"./types.js\"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/role-permission-matrix-client/default-data.ts"],"sourcesContent":["import type { RolePermissionMatrixClientTranslations } from \"./types.js\";\n\nexport const rolePermissionMatrixClientDefaultTranslations: RolePermissionMatrixClientTranslations =\n {\n en: {\n viewInUpdateScreenOnly: {\n label: \"View permission matrix in update screen only\",\n },\n loading: {\n placeholder: \"Loading permission matrix...\",\n },\n title: \"Permission Matrix\",\n features: {\n label: \"Features\",\n users: \"Users\",\n },\n actions: {\n label: \"Actions\",\n create: \"Create\",\n read: \"Read\",\n update: \"Update\",\n delete: \"Delete\",\n },\n },\n };\n"],"names":["rolePermissionMatrixClientDefaultTranslations","en","viewInUpdateScreenOnly","label","loading","placeholder","title","features","users","actions","create","read","update","delete"],"mappings":"AAEA,OAAO,MAAMA,gDACX;IACEC,IAAI;QACFC,wBAAwB;YACtBC,OAAO;QACT;QACAC,SAAS;YACPC,aAAa;QACf;QACAC,OAAO;QACPC,UAAU;YACRJ,OAAO;YACPK,OAAO;QACT;QACAC,SAAS;YACPN,OAAO;YACPO,QAAQ;YACRC,MAAM;YACNC,QAAQ;YACRC,QAAQ;QACV;IACF;AACF,EAAE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RolePermissionMatrixClient: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,6 +6,8 @@ import { STATUS as PERMISSION_STATUS } from "../../lib/constants/permission.js";
|
|
|
6
6
|
import { STATUS as PERMISSION_ACTION_STATUS, TYPE } from "../../lib/constants/permission-action.js";
|
|
7
7
|
import { STATUS as PERMISSION_FEATURE_STATUS } from "../../lib/constants/permission-feature.js";
|
|
8
8
|
import { toID } from "../../lib/utils/data.js";
|
|
9
|
+
import styles from "./matrix.module.scss";
|
|
10
|
+
const RBAC_PREFIX = "rbac";
|
|
9
11
|
export const RolePermissionMatrixClient = ()=>{
|
|
10
12
|
const checkboxId = useId();
|
|
11
13
|
const { config } = useConfig();
|
|
@@ -103,59 +105,36 @@ export const RolePermissionMatrixClient = ()=>{
|
|
|
103
105
|
]);
|
|
104
106
|
if (!id) {
|
|
105
107
|
return /*#__PURE__*/ _jsx("div", {
|
|
106
|
-
|
|
107
|
-
opacity: 0.8,
|
|
108
|
-
padding: "8px 0"
|
|
109
|
-
},
|
|
108
|
+
className: styles[`${RBAC_PREFIX}-component-placeholder`],
|
|
110
109
|
children: t(`components:rolePermissionMatrix:viewInUpdateScreenOnly:label`)
|
|
111
110
|
});
|
|
112
111
|
}
|
|
113
112
|
if (loading) {
|
|
114
113
|
return /*#__PURE__*/ _jsx("div", {
|
|
115
|
-
|
|
116
|
-
opacity: 0.8,
|
|
117
|
-
padding: "8px 0"
|
|
118
|
-
},
|
|
114
|
+
className: styles[`${RBAC_PREFIX}-component-placeholder`],
|
|
119
115
|
children: t(`components:rolePermissionMatrix:loading:placeholder`)
|
|
120
116
|
});
|
|
121
117
|
}
|
|
122
118
|
return /*#__PURE__*/ _jsxs("div", {
|
|
123
119
|
children: [
|
|
124
120
|
/*#__PURE__*/ _jsx("div", {
|
|
125
|
-
|
|
126
|
-
fontWeight: 600,
|
|
127
|
-
marginBottom: 8
|
|
128
|
-
},
|
|
121
|
+
className: styles[`${RBAC_PREFIX}-component-title`],
|
|
129
122
|
children: t(`components:rolePermissionMatrix:title`)
|
|
130
123
|
}),
|
|
131
124
|
/*#__PURE__*/ _jsx("div", {
|
|
132
|
-
|
|
133
|
-
border: "1px solid #333",
|
|
134
|
-
borderRadius: 8
|
|
135
|
-
},
|
|
125
|
+
className: styles[`${RBAC_PREFIX}-table-container`],
|
|
136
126
|
children: /*#__PURE__*/ _jsxs("table", {
|
|
137
|
-
|
|
138
|
-
borderCollapse: "collapse",
|
|
139
|
-
width: "100%"
|
|
140
|
-
},
|
|
127
|
+
className: styles[`${RBAC_PREFIX}-table`],
|
|
141
128
|
children: [
|
|
142
129
|
/*#__PURE__*/ _jsx("thead", {
|
|
143
130
|
children: /*#__PURE__*/ _jsxs("tr", {
|
|
144
131
|
children: [
|
|
145
132
|
/*#__PURE__*/ _jsx("th", {
|
|
146
|
-
|
|
147
|
-
padding: "8px",
|
|
148
|
-
textAlign: "left",
|
|
149
|
-
borderRight: "1px solid #333",
|
|
150
|
-
width: "25%"
|
|
151
|
-
},
|
|
133
|
+
className: styles[`${RBAC_PREFIX}-table-th-feature`],
|
|
152
134
|
children: t(`components:rolePermissionMatrix:features:label`)
|
|
153
135
|
}),
|
|
154
136
|
/*#__PURE__*/ _jsx("th", {
|
|
155
|
-
|
|
156
|
-
padding: "8px",
|
|
157
|
-
textAlign: "left"
|
|
158
|
-
},
|
|
137
|
+
className: styles[`${RBAC_PREFIX}-table-th-action`],
|
|
159
138
|
colSpan: actions.filter((action)=>action.type === TYPE.MAIN).length,
|
|
160
139
|
children: t(`components:rolePermissionMatrix:actions:label`)
|
|
161
140
|
})
|
|
@@ -172,36 +151,23 @@ export const RolePermissionMatrixClient = ()=>{
|
|
|
172
151
|
/*#__PURE__*/ _jsxs("tr", {
|
|
173
152
|
children: [
|
|
174
153
|
/*#__PURE__*/ _jsx("td", {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
padding: "0.5rem",
|
|
178
|
-
borderRight: "1px solid #333"
|
|
179
|
-
},
|
|
180
|
-
children: feature.code || feature.id
|
|
154
|
+
className: styles[`${RBAC_PREFIX}-table-td-feature`],
|
|
155
|
+
children: t(`components:rolePermissionMatrix:features:${feature.code}`) || feature.id
|
|
181
156
|
}),
|
|
182
157
|
mainActions.map((action)=>{
|
|
183
158
|
const matchedPermission = permissions.find((permission)=>toID(permission.permissionFeature) === String(feature.id) && toID(permission.permissionAction) === String(action.id));
|
|
184
159
|
if (!matchedPermission) {
|
|
185
160
|
return /*#__PURE__*/ _jsx("td", {
|
|
186
|
-
|
|
187
|
-
borderTop: "1px solid #333",
|
|
188
|
-
padding: "0.5rem"
|
|
189
|
-
},
|
|
161
|
+
className: styles[`${RBAC_PREFIX}-table-td-action`],
|
|
190
162
|
children: "-"
|
|
191
163
|
}, `${feature.id}-${action.id}`);
|
|
192
164
|
}
|
|
193
165
|
const permissionID = String(matchedPermission.id);
|
|
194
166
|
const checked = typeof draftValue[permissionID] === "boolean" ? draftValue[permissionID] : enabledByPermissionID.get(permissionID) ?? false;
|
|
195
167
|
return /*#__PURE__*/ _jsx("td", {
|
|
196
|
-
|
|
197
|
-
borderTop: "1px solid #333",
|
|
198
|
-
padding: "0.5rem"
|
|
199
|
-
},
|
|
168
|
+
className: styles[`${RBAC_PREFIX}-table-td-action`],
|
|
200
169
|
children: /*#__PURE__*/ _jsxs("div", {
|
|
201
|
-
|
|
202
|
-
display: "flex",
|
|
203
|
-
alignItems: "center"
|
|
204
|
-
},
|
|
170
|
+
className: styles[`${RBAC_PREFIX}-table-td-action-container`],
|
|
205
171
|
children: [
|
|
206
172
|
/*#__PURE__*/ _jsx("input", {
|
|
207
173
|
type: "checkbox",
|
|
@@ -215,19 +181,11 @@ export const RolePermissionMatrixClient = ()=>{
|
|
|
215
181
|
[permissionID]: event.target.checked
|
|
216
182
|
});
|
|
217
183
|
},
|
|
218
|
-
|
|
219
|
-
userSelect: "none",
|
|
220
|
-
cursor: "pointer"
|
|
221
|
-
}
|
|
184
|
+
className: styles[`${RBAC_PREFIX}-table-td-action-input`]
|
|
222
185
|
}),
|
|
223
186
|
/*#__PURE__*/ _jsx("label", {
|
|
224
187
|
htmlFor: `permission-matrix-checkbox-${checkboxId}-${feature.id}-${action.id}`,
|
|
225
|
-
|
|
226
|
-
display: "inline-block",
|
|
227
|
-
paddingLeft: "0.25rem",
|
|
228
|
-
userSelect: "none",
|
|
229
|
-
cursor: "pointer"
|
|
230
|
-
},
|
|
188
|
+
className: styles[`${RBAC_PREFIX}-table-td-action-label`],
|
|
231
189
|
children: t(`components:rolePermissionMatrix:actions:${action.code}`) || action.id
|
|
232
190
|
})
|
|
233
191
|
]
|
|
@@ -239,18 +197,10 @@ export const RolePermissionMatrixClient = ()=>{
|
|
|
239
197
|
isSubActionInPermission && /*#__PURE__*/ _jsxs("tr", {
|
|
240
198
|
children: [
|
|
241
199
|
/*#__PURE__*/ _jsx("td", {
|
|
242
|
-
|
|
243
|
-
borderRight: "1px solid #333",
|
|
244
|
-
padding: "8px",
|
|
245
|
-
textAlign: "right"
|
|
246
|
-
}
|
|
200
|
+
className: styles[`${RBAC_PREFIX}-table-td-feature`]
|
|
247
201
|
}),
|
|
248
202
|
/*#__PURE__*/ _jsx("td", {
|
|
249
|
-
|
|
250
|
-
borderTop: "1px solid #333",
|
|
251
|
-
padding: "8px",
|
|
252
|
-
textAlign: "left"
|
|
253
|
-
},
|
|
203
|
+
className: styles[`${RBAC_PREFIX}-table-td-action`],
|
|
254
204
|
colSpan: mainActions.length,
|
|
255
205
|
children: subActions.map((action)=>{
|
|
256
206
|
const matchedPermission = permissions.find((permission)=>toID(permission.permissionFeature) === String(feature.id) && toID(permission.permissionAction) === String(action.id));
|