@webbio/strapi-plugin-page-builder 0.9.1-platform → 0.9.3-platform
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.
|
@@ -7,9 +7,15 @@ import { PAGE_TYPE_UID } from '../../../../shared/utils/constants';
|
|
|
7
7
|
import { TemplatePlatformSelect } from './TemplatePlatformSelect';
|
|
8
8
|
import { Wrapper } from '../EditView/wrapper';
|
|
9
9
|
import SinglePlatformFilteredSelectField from '../PlatformFilteredSelectField/Single';
|
|
10
|
+
import { useRelationLoad } from '../PlatformFilteredSelectField/hooks/useRelationLoad';
|
|
10
11
|
|
|
11
12
|
export const PageTypeEditView = () => {
|
|
12
13
|
const { layout } = useCMEditViewDataManager() as any;
|
|
14
|
+
const name = 'defaultParent';
|
|
15
|
+
const attribute = { pluginOptions: { filteredSelect: { targetField: 'defaultParent' } } };
|
|
16
|
+
|
|
17
|
+
// This is to load the initial relations
|
|
18
|
+
useRelationLoad({ name, attribute });
|
|
13
19
|
|
|
14
20
|
const isPageTypeCollectionType = layout.uid === PAGE_TYPE_UID;
|
|
15
21
|
|
|
@@ -18,10 +24,7 @@ export const PageTypeEditView = () => {
|
|
|
18
24
|
<Wrapper title="Instellingen">
|
|
19
25
|
<Stack spacing={4} width="100%">
|
|
20
26
|
<TemplatePlatformSelect />
|
|
21
|
-
<SinglePlatformFilteredSelectField
|
|
22
|
-
name="defaultParent"
|
|
23
|
-
attribute={{ pluginOptions: { filteredSelect: { targetField: 'defaultParent' } } }}
|
|
24
|
-
/>
|
|
27
|
+
<SinglePlatformFilteredSelectField name={name} attribute={attribute} />
|
|
25
28
|
</Stack>
|
|
26
29
|
</Wrapper>
|
|
27
30
|
);
|
package/dist/package.json
CHANGED
|
@@ -2,99 +2,127 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const constants_1 = require("../../shared/utils/constants");
|
|
4
4
|
exports.default = async ({ strapi }) => {
|
|
5
|
-
var _a
|
|
5
|
+
var _a;
|
|
6
6
|
try {
|
|
7
|
-
const
|
|
8
|
-
limit: -1
|
|
9
|
-
})));
|
|
10
|
-
const platforms = (await ((_b = strapi.entityService) === null || _b === void 0 ? void 0 : _b.findMany(constants_1.PLATFORM_UID, {
|
|
7
|
+
const platforms = (await ((_a = strapi.entityService) === null || _a === void 0 ? void 0 : _a.findMany(constants_1.PLATFORM_UID, {
|
|
11
8
|
limit: -1
|
|
12
9
|
})));
|
|
13
10
|
const platformPagePermissions = platforms.map((platform) => {
|
|
14
|
-
return pageTypes.map((pageType) => {
|
|
15
|
-
const name = `platform-is-${platform.title}-${pageType.uid}`;
|
|
16
|
-
const displayName = `${platform.title}-${pageType.title}`;
|
|
17
|
-
return {
|
|
18
|
-
plugin: 'page-builder',
|
|
19
|
-
name,
|
|
20
|
-
displayName,
|
|
21
|
-
category: `${platform.title} Page roles`,
|
|
22
|
-
handler: async () => {
|
|
23
|
-
return {
|
|
24
|
-
$and: [
|
|
25
|
-
{
|
|
26
|
-
'platform.id': {
|
|
27
|
-
$eq: platform.id
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
'pageType.uid': {
|
|
32
|
-
$eq: pageType.uid
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
uid: {
|
|
37
|
-
$eq: pageType.uid
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
const pageTypePermissions = pageTypes.map((pageType) => {
|
|
47
|
-
const name = `pageType-permission-${pageType.uid}`;
|
|
48
|
-
const displayName = `pageType ${pageType.title}`;
|
|
49
|
-
return {
|
|
50
|
-
plugin: 'page-builder',
|
|
51
|
-
name,
|
|
52
|
-
displayName,
|
|
53
|
-
category: `Platform pageType roles`,
|
|
54
|
-
handler: async () => {
|
|
55
|
-
return {
|
|
56
|
-
uid: {
|
|
57
|
-
$eq: pageType.uid
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
});
|
|
63
|
-
const platformCollectiontypePermissions = platforms.map((platform) => {
|
|
64
11
|
const name = `platform-is-${platform.title}`;
|
|
65
12
|
const displayName = platform.title;
|
|
66
13
|
return {
|
|
67
14
|
plugin: 'page-builder',
|
|
68
15
|
name,
|
|
69
16
|
displayName,
|
|
70
|
-
category:
|
|
71
|
-
handler: async () => {
|
|
17
|
+
category: `Platform`,
|
|
18
|
+
handler: async (x) => {
|
|
19
|
+
var _a, _b, _c, _d;
|
|
20
|
+
if (((_a = x === null || x === void 0 ? void 0 : x.permission) === null || _a === void 0 ? void 0 : _a.subject) === 'api::platform.platform') {
|
|
21
|
+
return {
|
|
22
|
+
id: {
|
|
23
|
+
$eq: platform.id
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
if (((_b = x === null || x === void 0 ? void 0 : x.permission) === null || _b === void 0 ? void 0 : _b.subject) === 'api::page.page') {
|
|
28
|
+
try {
|
|
29
|
+
const roles = (await ((_c = strapi.entityService) === null || _c === void 0 ? void 0 : _c.findMany('admin::role', {
|
|
30
|
+
limit: -1,
|
|
31
|
+
populate: '*'
|
|
32
|
+
})));
|
|
33
|
+
// checks which role the user has
|
|
34
|
+
const foundRole = roles.filter((role) => {
|
|
35
|
+
return x.roles.find((userRole) => userRole.name === role.name);
|
|
36
|
+
});
|
|
37
|
+
// get the right platform permissions, and filters out the platform
|
|
38
|
+
// this is neccesary because of multiple platforms. if you can see Vacancy from platform 1 and collegue from platform 2
|
|
39
|
+
// it will show both at page level, so this filters out the wrong page
|
|
40
|
+
const platformPermission = (_d = foundRole === null || foundRole === void 0 ? void 0 : foundRole[0]) === null || _d === void 0 ? void 0 : _d.permissions.map((permission) => {
|
|
41
|
+
return {
|
|
42
|
+
permission: permission.subject,
|
|
43
|
+
condition: permission.conditions.filter((condition) => condition.includes(platform.title))
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
// get the right permission for platform
|
|
47
|
+
const permissions = platformPermission.map((permission) => {
|
|
48
|
+
if (permission.condition.length > 0) {
|
|
49
|
+
return permission.permission;
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
return {
|
|
53
|
+
$and: [
|
|
54
|
+
{
|
|
55
|
+
'platform.id': {
|
|
56
|
+
$eq: platform.id
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
'pageType.uid': {
|
|
61
|
+
$in: permissions
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.log(error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
72
71
|
return {
|
|
73
|
-
$
|
|
72
|
+
$and: [
|
|
74
73
|
{
|
|
75
74
|
'platform.id': {
|
|
76
75
|
$eq: platform.id
|
|
77
76
|
}
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
id: {
|
|
81
|
-
$eq: platform.id
|
|
82
|
-
}
|
|
83
77
|
}
|
|
84
78
|
]
|
|
85
79
|
};
|
|
86
80
|
}
|
|
87
81
|
};
|
|
82
|
+
// });
|
|
88
83
|
});
|
|
89
|
-
const allPermissions = [
|
|
90
|
-
...platformPagePermissions.flat(),
|
|
91
|
-
...pageTypePermissions.flat(),
|
|
92
|
-
...platformCollectiontypePermissions
|
|
93
|
-
];
|
|
84
|
+
const allPermissions = [...platformPagePermissions.flat()];
|
|
94
85
|
// @ts-ignore shitty types
|
|
95
86
|
await strapi.admin.services.permission.conditionProvider.registerMany(allPermissions);
|
|
96
87
|
}
|
|
97
|
-
catch {
|
|
88
|
+
catch (error) {
|
|
98
89
|
console.log('Cannot set page permissions');
|
|
99
90
|
}
|
|
100
91
|
};
|
|
92
|
+
// Leave this commented code here, This might be used in the future to change up the permissions IF needed
|
|
93
|
+
// const platformPagePermissions = platforms.map((platform) => {
|
|
94
|
+
// const platformPageTypes = pageTypes.filter((pageType) => pageType.platform.id === platform.id);
|
|
95
|
+
// return platformPageTypes.map((pageType) => {
|
|
96
|
+
// const name = `platform-is-${platform.title}-${pageType.uid}`;
|
|
97
|
+
// const displayName = pageType.title;
|
|
98
|
+
// return {
|
|
99
|
+
// plugin: 'page-builder',
|
|
100
|
+
// name,
|
|
101
|
+
// displayName,
|
|
102
|
+
// category: `${platform.title} pageTypes`,
|
|
103
|
+
// handler: async (x) => {
|
|
104
|
+
// if (x?.permission?.subject === 'api::platform.platform') {
|
|
105
|
+
// return {
|
|
106
|
+
// id: {
|
|
107
|
+
// $eq: platform.id
|
|
108
|
+
// }
|
|
109
|
+
// };
|
|
110
|
+
// }
|
|
111
|
+
// return {
|
|
112
|
+
// $and: [
|
|
113
|
+
// {
|
|
114
|
+
// 'platform.id': {
|
|
115
|
+
// $eq: platform.id
|
|
116
|
+
// }
|
|
117
|
+
// },
|
|
118
|
+
// {
|
|
119
|
+
// 'pageType.uid': {
|
|
120
|
+
// $eq: pageType.uid
|
|
121
|
+
// }
|
|
122
|
+
// }
|
|
123
|
+
// ]
|
|
124
|
+
// };
|
|
125
|
+
// }
|
|
126
|
+
// };
|
|
127
|
+
// });
|
|
128
|
+
// });
|