@webbio/strapi-plugin-page-builder 0.12.7-platform → 0.13.0-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.
- package/README.md +5 -1
- package/admin/src/api/page-type-exists.ts +44 -0
- package/admin/src/api/search-filtered-entity.ts +22 -6
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +17 -6
- package/admin/src/components/EditView/Details/styles.ts +11 -1
- package/admin/src/components/PageFilters/filters.tsx +18 -10
- package/admin/src/components/PlatformFilteredSelectField/Multi/index.tsx +10 -8
- package/admin/src/components/PlatformFilteredSelectField/Single/index.tsx +31 -17
- package/admin/src/components/PlatformFilteredSelectField/styles.tsx +20 -1
- package/admin/src/components/PlatformFilteredSelectField/utils/relation-helper.ts +5 -1
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/RelationInput.tsx +41 -15
- package/admin/src/utils/hooks/useQueryParams.ts +52 -0
- package/dist/package.json +1 -1
- package/dist/server/bootstrap/permissions.js +19 -16
- package/dist/server/bootstrap.js +17 -15
- package/dist/server/content-types/user-categories/schema.json +18 -0
- package/dist/server/controllers/private-content.js +1 -1
- package/dist/server/services/email.js +2 -0
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/server/bootstrap/permissions.ts +21 -17
- package/server/bootstrap.ts +25 -16
- package/server/controllers/private-content.ts +1 -1
- package/server/services/email.ts +2 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { parse, stringify } from 'qs';
|
|
2
|
+
import { useMemo, useCallback } from 'react';
|
|
3
|
+
import { useLocation, useHistory } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
interface IUseQueryParamsObj {
|
|
6
|
+
query: Record<string, any>;
|
|
7
|
+
rawQuery: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type ISetQuery = (nextParams: Record<string, any>, method?: string, routerMethod?: string) => void;
|
|
11
|
+
|
|
12
|
+
// We created this as a copy of the useQueryParams hook from the Strapi plugin
|
|
13
|
+
// This one however supports the replace and push methods from the useHistory hook
|
|
14
|
+
const useQueryParams = (initialParams?: Record<string, any>): [IUseQueryParamsObj, ISetQuery] => {
|
|
15
|
+
const { search } = useLocation();
|
|
16
|
+
const { replace, push } = useHistory();
|
|
17
|
+
|
|
18
|
+
const query = useMemo(() => {
|
|
19
|
+
const searchQuery = search.substring(1);
|
|
20
|
+
if (!search) {
|
|
21
|
+
return initialParams || {};
|
|
22
|
+
}
|
|
23
|
+
return parse(searchQuery);
|
|
24
|
+
}, [search, initialParams]);
|
|
25
|
+
|
|
26
|
+
const setQuery = useCallback(
|
|
27
|
+
(nextParams: Record<string, any>, method = 'push', routerMethod = 'push') => {
|
|
28
|
+
let nextQuery = { ...query };
|
|
29
|
+
if (method === 'remove') {
|
|
30
|
+
Object.keys(nextParams).forEach((key) => {
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(nextQuery, key)) {
|
|
32
|
+
delete nextQuery[key];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
} else {
|
|
36
|
+
nextQuery = { ...query, ...nextParams };
|
|
37
|
+
}
|
|
38
|
+
const props = { search: stringify(nextQuery, { encode: false }) };
|
|
39
|
+
|
|
40
|
+
if (routerMethod === 'replace') {
|
|
41
|
+
replace(props);
|
|
42
|
+
} else {
|
|
43
|
+
push(props);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
[push, replace, query]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return [{ query, rawQuery: search }, setQuery];
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export { useQueryParams };
|
package/dist/package.json
CHANGED
|
@@ -20,7 +20,7 @@ exports.default = async ({ strapi }) => {
|
|
|
20
20
|
displayName,
|
|
21
21
|
category: 'Platform',
|
|
22
22
|
handler: async (x) => {
|
|
23
|
-
var _a, _b, _c
|
|
23
|
+
var _a, _b, _c;
|
|
24
24
|
if (((_a = x === null || x === void 0 ? void 0 : x.permission) === null || _a === void 0 ? void 0 : _a.subject) === 'api::platform.platform') {
|
|
25
25
|
return {
|
|
26
26
|
id: {
|
|
@@ -34,25 +34,28 @@ exports.default = async ({ strapi }) => {
|
|
|
34
34
|
limit: -1,
|
|
35
35
|
populate: '*'
|
|
36
36
|
})));
|
|
37
|
-
// checks which
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
// checks which roles the user has
|
|
38
|
+
const foundRoles = roles.filter((role) => x.roles.find((userRole) => userRole.name === role.name));
|
|
39
|
+
// Get all permissions from the roles the user has
|
|
40
|
+
const allPermissions = [foundRoles === null || foundRoles === void 0 ? void 0 : foundRoles[0]]
|
|
41
|
+
.map((role) => role === null || role === void 0 ? void 0 : role.permissions)
|
|
42
|
+
.flat()
|
|
43
|
+
.filter(Boolean);
|
|
41
44
|
// get the right platform permissions, and filters out the platform
|
|
42
45
|
// this is neccesary because of multiple platforms. if you can see Vacancy from platform 1 and collegue from platform 2
|
|
43
46
|
// it will show both at page level, so this filters out the wrong page
|
|
44
|
-
const platformPermission =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return permission.permission;
|
|
47
|
+
const platformPermission = allPermissions.map((permission) => ({
|
|
48
|
+
subject: permission.subject,
|
|
49
|
+
conditions: permission === null || permission === void 0 ? void 0 : permission.conditions.filter((condition) => condition.includes(platform.title))
|
|
50
|
+
}));
|
|
51
|
+
// Get the right permission for platform
|
|
52
|
+
const permissions = platformPermission
|
|
53
|
+
.map((permission) => {
|
|
54
|
+
if (permission.conditions.length > 0) {
|
|
55
|
+
return permission.subject;
|
|
54
56
|
}
|
|
55
|
-
})
|
|
57
|
+
})
|
|
58
|
+
.filter(Boolean);
|
|
56
59
|
const uniquePermissions = (0, uniq_1.default)(permissions);
|
|
57
60
|
return {
|
|
58
61
|
$and: [
|
package/dist/server/bootstrap.js
CHANGED
|
@@ -30,23 +30,25 @@ exports.default = async ({ strapi }) => {
|
|
|
30
30
|
async beforeUpdate(event) {
|
|
31
31
|
var _a;
|
|
32
32
|
if (event.params.data.id) {
|
|
33
|
-
const
|
|
33
|
+
const originalUserObject = await ((_a = strapi.entityService) === null || _a === void 0 ? void 0 : _a.findOne(constants_1.USER_PERMISSION_USER_PLUGIN, event.params.data.id, {
|
|
34
34
|
populate: { platform: { populate: { platformEmails: { populate: '*' } } } }
|
|
35
35
|
}));
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
36
|
+
if (originalUserObject &&
|
|
37
|
+
event.params.data.activateUser &&
|
|
38
|
+
event.params.data.confirmed &&
|
|
39
|
+
!originalUserObject.confirmMailSend) {
|
|
40
|
+
await strapi.service(constants_1.PAGE_BUILDER_EMAIL_PLUGIN).sendMail({
|
|
41
|
+
// @ts-ignore strapi typings
|
|
42
|
+
from: originalUserObject.platform.platformEmails.accountAcceptedMail.fromEmail,
|
|
43
|
+
to: event.params.data.email,
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
subject: originalUserObject.platform.platformEmails.accountAcceptedMail.subject,
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
text: originalUserObject.platform.platformEmails.accountAcceptedMail.message,
|
|
48
|
+
firstName: event.params.data.firstName,
|
|
49
|
+
lastName: event.params.data.lastName
|
|
50
|
+
});
|
|
51
|
+
event.params.data.confirmMailSend = true;
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"kind": "collectionType",
|
|
3
|
+
"collectionName": "user-categories",
|
|
4
|
+
"info": {
|
|
5
|
+
"singularName": "user-category",
|
|
6
|
+
"pluralName": "user-categories",
|
|
7
|
+
"displayName": "User Categories"
|
|
8
|
+
},
|
|
9
|
+
"options": {
|
|
10
|
+
"draftAndPublish": false,
|
|
11
|
+
"comment": ""
|
|
12
|
+
},
|
|
13
|
+
"attributes": {
|
|
14
|
+
"title": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
const AWS = __importStar(require("@aws-sdk/client-ses"));
|
|
27
27
|
const txtMail_email_template_text_1 = require("./private-content/mail-template/txtMail.email.template.text");
|
|
28
28
|
const constants_1 = require("../../shared/utils/constants");
|
|
29
|
+
const utils_1 = require("@strapi/utils");
|
|
29
30
|
exports.default = {
|
|
30
31
|
async sendMail(options) {
|
|
31
32
|
const { from, to, subject, text, variables } = options;
|
|
@@ -47,6 +48,7 @@ exports.default = {
|
|
|
47
48
|
}
|
|
48
49
|
catch (error) {
|
|
49
50
|
console.error(error);
|
|
51
|
+
throw new utils_1.errors.ApplicationError('Failed to send email', error);
|
|
50
52
|
}
|
|
51
53
|
},
|
|
52
54
|
async sendAdminMail(user) {
|