@webbio/strapi-plugin-page-builder 0.15.5-platform → 0.17.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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webbio/strapi-plugin-page-builder",
3
- "version": "0.15.5-platform",
3
+ "version": "0.17.0-platform",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -23,12 +23,12 @@
23
23
  "@aws-sdk/client-ses": "^3.485.0",
24
24
  "@mantine/hooks": "^7.2.2",
25
25
  "@sindresorhus/slugify": "^2.2.1",
26
- "@strapi/design-system": "^1.11.0",
27
- "@strapi/helper-plugin": "^4.15.0",
28
- "@strapi/icons": "^1.11.0",
26
+ "@strapi/design-system": "^1.19.0",
27
+ "@strapi/helper-plugin": "^4.25.4",
28
+ "@strapi/icons": "^1.19.0",
29
29
  "@strapi/provider-email-amazon-ses": "^4.16.2",
30
- "@strapi/typescript-utils": "^4.15.0",
31
- "@strapi/utils": "^4.15.0",
30
+ "@strapi/typescript-utils": "^4.25.4",
31
+ "@strapi/utils": "^4.25.4",
32
32
  "add": "^2.0.6",
33
33
  "aws-sdk": "^2.1528.0",
34
34
  "fuse.js": "^7.0.0",
@@ -48,8 +48,8 @@
48
48
  "typescript": "5.1.6"
49
49
  },
50
50
  "peerDependencies": {
51
- "@strapi/strapi": "^4.15.0",
52
- "@webbio/strapi-plugin-slug": "^3.3.1",
51
+ "@strapi/strapi": "^4.25.4",
52
+ "@webbio/strapi-plugin-slug": "^3.3.2",
53
53
  "react": "^17.0.0 || ^18.0.0",
54
54
  "react-dom": "^17.0.0 || ^18.0.0",
55
55
  "react-router-dom": "^5.3.4",
@@ -98,11 +98,18 @@ exports.default = async ({ strapi }) => {
98
98
  }
99
99
  }
100
100
  return {
101
- $and: [
101
+ $or: [
102
102
  {
103
103
  'platform.id': {
104
104
  $eq: platform.id
105
105
  }
106
+ },
107
+ {
108
+ // This is a fix for not showing data after saving. After an update, no platform is returned for the page, so the permission system thinks the user has no access.
109
+ // All pages have a platform, so this fix won't break anything 🙏
110
+ 'platform.id': {
111
+ $eq: null
112
+ }
106
113
  }
107
114
  ]
108
115
  };
@@ -62,18 +62,19 @@ exports.default = async ({ strapi }) => {
62
62
  // @ts-ignore
63
63
  models: [constants_1.PAGE_UID],
64
64
  async beforeCreate(event) {
65
- var _a, _b, _c, _d, _e, _f, _g;
65
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
66
66
  let { data } = event.params;
67
+ console.log('data', event);
67
68
  const collectionTypeId = data === null || data === void 0 ? void 0 : data.collectionTypeId;
68
- const pageTypeId = ((_b = (_a = data === null || data === void 0 ? void 0 : data.pageType.connect) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.id) || data.initialPageType;
69
- const platformId = (_d = (_c = data === null || data === void 0 ? void 0 : data.platform.connect) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.id;
69
+ const pageTypeId = ((_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.pageType) === null || _a === void 0 ? void 0 : _a.connect) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.id) || data.initialPageType;
70
+ const platformId = (_f = (_e = (_d = data === null || data === void 0 ? void 0 : data.platform) === null || _d === void 0 ? void 0 : _d.connect) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.id;
70
71
  if (collectionTypeId && pageTypeId) {
71
- const pageType = await ((_e = strapi.entityService) === null || _e === void 0 ? void 0 : _e.findOne(constants_1.PAGE_TYPE_UID, pageTypeId));
72
- const collectionToConnect = await ((_f = strapi.entityService) === null || _f === void 0 ? void 0 : _f.findOne(pageType === null || pageType === void 0 ? void 0 : pageType.uid, collectionTypeId, {
72
+ const pageType = await ((_g = strapi.entityService) === null || _g === void 0 ? void 0 : _g.findOne(constants_1.PAGE_TYPE_UID, pageTypeId));
73
+ const collectionToConnect = await ((_h = strapi.entityService) === null || _h === void 0 ? void 0 : _h.findOne(pageType === null || pageType === void 0 ? void 0 : pageType.uid, collectionTypeId, {
73
74
  populate: { page: true }
74
75
  }));
75
76
  const page = collectionToConnect === null || collectionToConnect === void 0 ? void 0 : collectionToConnect.page;
76
- const foundPlatforms = await ((_g = strapi.entityService) === null || _g === void 0 ? void 0 : _g.findMany(constants_1.PLATFORM_UID, {
77
+ const foundPlatforms = await ((_j = strapi.entityService) === null || _j === void 0 ? void 0 : _j.findMany(constants_1.PLATFORM_UID, {
77
78
  populate: '*',
78
79
  filters: {
79
80
  pagetype: {
@@ -82,12 +82,12 @@ exports.extendUser = extendUser;
82
82
  const extendControllers = () => {
83
83
  const contentController = strapi.controller(constants_1.USER_CONTENT_MANAGER);
84
84
  contentController.create = async (ctx) => {
85
- var _a;
85
+ var _a, _b, _c, _d, _e, _f;
86
86
  const { body } = ctx.request;
87
87
  const { user: admin, userAbility } = ctx.state;
88
88
  const { email } = body;
89
- const platformId = body.platform.connect[0].id;
90
- const pm = (_a = strapi === null || strapi === void 0 ? void 0 : strapi.admin) === null || _a === void 0 ? void 0 : _a.services.permission.createPermissionsManager({
89
+ const platformId = (_c = (_b = (_a = body === null || body === void 0 ? void 0 : body.platform) === null || _a === void 0 ? void 0 : _a.connect) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.id;
90
+ const pm = (_d = strapi === null || strapi === void 0 ? void 0 : strapi.admin) === null || _d === void 0 ? void 0 : _d.services.permission.createPermissionsManager({
91
91
  ability: userAbility,
92
92
  action: constants_1.ACTIONS.create,
93
93
  model: constants_1.USER_MODEL
@@ -110,7 +110,7 @@ const extendControllers = () => {
110
110
  };
111
111
  user.email = user.email.toLowerCase();
112
112
  const advanced = await (strapi === null || strapi === void 0 ? void 0 : strapi.store({ type: 'plugin', name: 'users-permissions', key: 'advanced' }).get({}));
113
- if (user.role.connect.length === 0) {
113
+ if ((((_f = (_e = user === null || user === void 0 ? void 0 : user.role) === null || _e === void 0 ? void 0 : _e.connect) === null || _f === void 0 ? void 0 : _f.length) || 0) === 0) {
114
114
  //@ts-ignore strapi types...
115
115
  const defaultRole = await strapi.query(constants_1.USER_ROLE).findOne({ where: { type: advanced.default_role } });
116
116
  user.role = defaultRole.id;
@@ -125,13 +125,14 @@ const extendControllers = () => {
125
125
  }
126
126
  };
127
127
  contentController.update = async (ctx) => {
128
+ var _a, _b;
128
129
  const { id } = ctx.params;
129
130
  const { body } = ctx.request;
130
131
  const { user: admin, userAbility } = ctx.state;
131
132
  const { email, password } = body;
132
133
  const { pm, entity } = await findEntityAndCheckPermissions(userAbility, constants_1.ACTIONS.edit, constants_1.USER_MODEL, id);
133
134
  const user = entity;
134
- const platformId = body.platform.connect.length > 0 ? body.platform.connect[0].id : entity.platform.id;
135
+ const platformId = (((_b = (_a = body === null || body === void 0 ? void 0 : body.platform) === null || _a === void 0 ? void 0 : _a.connect) === null || _b === void 0 ? void 0 : _b.length) || 0) > 0 ? body.platform.connect[0].id : entity.platform.id;
135
136
  if ((0, has_1.default)(body, 'password') && !password && user.provider === 'local') {
136
137
  throw new ValidationError('password.notNull');
137
138
  }