@webbio/strapi-plugin-page-builder 0.5.1-platform → 0.7.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.
Files changed (41) hide show
  1. package/admin/src/api/has-page-relation.ts +1 -1
  2. package/admin/src/api/has-platform-relation.ts +1 -1
  3. package/admin/src/api/page.ts +94 -0
  4. package/admin/src/api/platform-page-types.ts +17 -19
  5. package/admin/src/api/platform.ts +2 -2
  6. package/admin/src/api/template.ts +10 -7
  7. package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +6 -2
  8. package/admin/src/components/EditView/Details/index.tsx +1 -1
  9. package/admin/src/components/EditView/PageSettings/index.tsx +1 -1
  10. package/admin/src/components/EditView/Template/TemplateSelect/index.tsx +3 -2
  11. package/admin/src/components/EditView/Template/TemplateSelect/use-template-modules.ts +5 -2
  12. package/admin/src/components/EditView/page-type-select.tsx +1 -1
  13. package/admin/src/components/EditView/wrapper.tsx +13 -7
  14. package/admin/src/components/GlobalPlatformSelect/index.tsx +0 -1
  15. package/admin/src/components/PageFilters/PageTypeFilter/index.tsx +1 -1
  16. package/admin/src/components/PageFilters/filters.tsx +1 -1
  17. package/admin/src/components/PageFilters/index.tsx +6 -1
  18. package/admin/src/components/PageTypeEditView/PageByPlatformSelect/index.tsx +112 -0
  19. package/admin/src/components/PageTypeEditView/TemplatePlatformSelect/index.tsx +55 -0
  20. package/admin/src/components/PageTypeEditView/index.tsx +28 -0
  21. package/admin/src/index.tsx +5 -0
  22. package/admin/src/utils/hooks/useDefaultPlatformFromLocalStorage.ts +36 -6
  23. package/admin/src/utils/hooks/usePlatformFormData.ts +1 -0
  24. package/dist/package.json +1 -1
  25. package/dist/server/controllers/page-type.js +6 -2
  26. package/dist/server/routes/index.js +1 -1
  27. package/dist/server/schema/page-type-end.json +15 -5
  28. package/dist/server/schema/platform-start.json +0 -10
  29. package/dist/server/schema/template-end.json +40 -0
  30. package/dist/server/services/builder.js +4 -3
  31. package/dist/server/services/page-type.js +7 -3
  32. package/dist/tsconfig.server.tsbuildinfo +1 -1
  33. package/package.json +1 -1
  34. package/server/controllers/page-type.ts +6 -1
  35. package/server/routes/index.ts +1 -1
  36. package/server/schema/page-type-end.json +15 -5
  37. package/server/schema/platform-start.json +0 -10
  38. package/server/schema/template-end.json +40 -0
  39. package/server/services/builder.ts +4 -3
  40. package/server/services/page-type.ts +7 -3
  41. package/admin/src/api/page-type.ts +0 -32
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webbio/strapi-plugin-page-builder",
3
- "version": "0.5.1-platform",
3
+ "version": "0.7.0-platform",
4
4
  "description": "This is the description of the plugin.",
5
5
  "scripts": {
6
6
  "develop": "tsc -p tsconfig.server.json -w",
@@ -3,11 +3,16 @@ import { Strapi } from '@strapi/strapi';
3
3
  export default {
4
4
  async findOneByUid(ctx: any) {
5
5
  const uid = ctx?.params?.uid;
6
+ const platformId = ctx?.params?.platformId;
6
7
 
7
8
  if (!uid) {
8
9
  return ctx.badRequest('uid is missing.');
9
10
  }
10
11
 
11
- return await (strapi as Strapi).service('plugin::page-builder.page-type').findOneByUid(uid);
12
+ if (!platformId) {
13
+ return ctx.badRequest('PlatformId is missing.');
14
+ }
15
+
16
+ return await (strapi as Strapi).service('plugin::page-builder.page-type').findOneByUid(uid, platformId);
12
17
  }
13
18
  };
@@ -5,7 +5,7 @@ const routes = {
5
5
  routes: [
6
6
  {
7
7
  method: 'GET',
8
- path: '/page-types/:uid',
8
+ path: '/page-types/:uid/:platformId',
9
9
  handler: 'page-type.findOneByUid'
10
10
  }
11
11
  ]
@@ -25,6 +25,21 @@
25
25
  }
26
26
  }
27
27
  },
28
+ "template": {
29
+ "type": "relation",
30
+ "relation": "oneToOne",
31
+ "target": "api::template.template"
32
+ },
33
+ "platform": {
34
+ "type": "relation",
35
+ "relation": "oneToOne",
36
+ "target": "api::platform.platform"
37
+ },
38
+ "defaultParent": {
39
+ "type": "relation",
40
+ "relation": "oneToOne",
41
+ "target": "api::page.page"
42
+ },
28
43
  "modules": {
29
44
  "type": "dynamiczone",
30
45
  "components": [],
@@ -33,11 +48,6 @@
33
48
  "localized": true
34
49
  }
35
50
  }
36
- },
37
- "template": {
38
- "type": "relation",
39
- "relation": "oneToOne",
40
- "target": "api::template.template"
41
51
  }
42
52
  }
43
53
  }
@@ -16,16 +16,6 @@
16
16
  },
17
17
  "domain": {
18
18
  "type": "string"
19
- },
20
- "template": {
21
- "type": "relation",
22
- "relation": "oneToMany",
23
- "target": "api::template.template"
24
- },
25
- "pageTypes": {
26
- "type": "relation",
27
- "relation": "oneToMany",
28
- "target": "api::page-type.page-type"
29
19
  }
30
20
  }
31
21
  }
@@ -0,0 +1,40 @@
1
+ {
2
+ "draftAndPublish": false,
3
+ "displayName": "Templates",
4
+ "singularName": "template",
5
+ "pluralName": "templates",
6
+ "description": "",
7
+ "plugin": "page-builder",
8
+ "pluginOptions": {
9
+ "i18n": {
10
+ "localized": true
11
+ }
12
+ },
13
+ "kind": "collectionType",
14
+ "collectionName": "templates",
15
+ "attributes": {
16
+ "title": {
17
+ "type": "string",
18
+ "required": true,
19
+ "pluginOptions": {
20
+ "i18n": {
21
+ "localized": true
22
+ }
23
+ }
24
+ },
25
+ "platform": {
26
+ "type": "relation",
27
+ "relation": "oneToOne",
28
+ "target": "api::platform.platform"
29
+ },
30
+ "modules": {
31
+ "type": "dynamiczone",
32
+ "components": [],
33
+ "pluginOptions": {
34
+ "i18n": {
35
+ "localized": true
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
@@ -9,6 +9,7 @@ import { reloadStrapiOnLoad } from '../utils/reload-strapi-on-load';
9
9
  import pageTypeStart from '../schema/page-type-start.json';
10
10
  import pageTypeEnd from '../schema/page-type-end.json';
11
11
  import templateStart from '../schema/template-start.json';
12
+ import templateEnd from '../schema/template-end.json';
12
13
  import platformStart from '../schema/platform-start.json';
13
14
 
14
15
  const UIDS: Common.UID.ContentType[] = [TEMPLATE_UID, PAGE_TYPE_UID, PLATFORM_UID, PAGE_UID];
@@ -86,7 +87,7 @@ export default {
86
87
  update: this.getPageTypeContentType()
87
88
  },
88
89
  [TEMPLATE_UID]: {
89
- create: this.getTemplateContentType(),
90
+ create: this.getTemplateContentType(true),
90
91
  update: this.getTemplateContentType()
91
92
  },
92
93
  [PLATFORM_UID]: {
@@ -109,8 +110,8 @@ export default {
109
110
 
110
111
  return { uid: PAGE_TYPE_UID, contentType };
111
112
  },
112
- getTemplateContentType() {
113
- const template = templateStart;
113
+ getTemplateContentType(create?: boolean) {
114
+ const template = create ? templateStart : templateEnd;
114
115
  const contentType = this.mergeCollectionTypeWithOld(template, TEMPLATE_UID);
115
116
 
116
117
  return { uid: TEMPLATE_UID, contentType };
@@ -1,17 +1,21 @@
1
1
  import { PAGE_TYPE_UID } from '../../shared/utils/constants';
2
2
 
3
3
  export default {
4
- async findOneByUid(uid: string) {
4
+ async findOneByUid(uid: string, platformId: number) {
5
5
  const results = await strapi.entityService?.findMany(PAGE_TYPE_UID, {
6
6
  populate: {
7
7
  template: {
8
8
  populate: {
9
9
  modules: true
10
10
  }
11
- }
11
+ },
12
+ defaultParent: true
12
13
  },
13
14
  filters: {
14
- uid
15
+ uid,
16
+ platform: {
17
+ id: platformId
18
+ }
15
19
  }
16
20
  });
17
21
 
@@ -1,32 +0,0 @@
1
- import { useQuery } from 'react-query';
2
- import { useFetchClient } from '@strapi/helper-plugin';
3
-
4
- export type PageType = {
5
- id: number;
6
- uid: string;
7
- title?: string;
8
- };
9
-
10
- const QUERY_KEY = 'page-types';
11
-
12
- const fetchPageTypes = async ({ fetchClient }: Record<string, any>): Promise<PageType[]> => {
13
- const { get } = fetchClient;
14
- const result = await get(`/content-manager/collection-types/api::page-type.page-type?page=1&pageSize=100`);
15
-
16
- return result?.data?.results?.map((entity: Record<string, any>) => ({
17
- id: entity.id,
18
- uid: entity.uid,
19
- title: entity.title,
20
- templateId: entity?.template?.id
21
- }));
22
- };
23
-
24
- export const useGetPageTypes = (params: Record<string, any>) => {
25
- const fetchClient = useFetchClient();
26
- params = {
27
- ...params,
28
- fetchClient
29
- };
30
-
31
- return useQuery<PageType[], Error>(QUERY_KEY, () => fetchPageTypes(params));
32
- };