@webbio/strapi-plugin-page-builder 0.3.3 → 0.3.4-legacy
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 +21 -6
- package/admin/src/api/collection-type.ts +1 -7
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +12 -15
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +28 -10
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +32 -61
- package/admin/src/components/EditView/Details/index.tsx +1 -1
- package/admin/src/components/EditView/PageSettings/index.tsx +6 -74
- package/admin/src/components/PageTypeFilter/index.tsx +17 -0
- package/admin/src/components/PageTypeFilter/page-type-filter.tsx +130 -0
- package/admin/src/index.tsx +2 -2
- package/admin/src/utils/sanitizeModules.ts +92 -9
- package/dist/package.json +12 -10
- package/dist/server/bootstrap/permissions.js +10 -68
- package/dist/server/bootstrap.js +24 -40
- package/dist/server/content-types/user-categories/schema.json +18 -0
- package/dist/server/content-types/user-category/schema.json +23 -0
- package/dist/server/controllers/index.js +1 -3
- package/dist/server/controllers/platform.js +5 -5
- package/dist/server/controllers/private-content.js +18 -0
- package/dist/server/controllers/sitemap.js +29 -0
- package/dist/server/controllers/user-category.js +4 -0
- package/dist/server/graphql/page-by-path.js +113 -0
- package/dist/server/graphql/page-by-slug.js +37 -44
- package/dist/server/graphql/pages-by-uid.js +7 -9
- package/dist/server/policies/isAuthorizedPage.js +11 -0
- package/dist/server/routes/index.js +0 -21
- package/dist/server/routes/user-category.js +4 -0
- package/dist/server/schema/page-end.json +0 -5
- package/dist/server/schema/platform-start.json +0 -10
- package/dist/server/schema/template-end.json +40 -0
- package/dist/server/services/builder.js +5 -15
- package/dist/server/services/email.js +160 -0
- package/dist/server/services/index.js +1 -3
- package/dist/server/services/platform.js +6 -11
- package/dist/server/services/private-content/components/admin-email.json +22 -0
- package/dist/server/services/private-content/components/email.json +22 -0
- package/dist/server/services/private-content/components/platform-email.json +33 -0
- package/dist/server/services/private-content/constants/index.js +16 -0
- package/dist/server/services/private-content/graphql/index.js +77 -0
- package/dist/server/services/private-content/graphql/resolvers/findOnePage.js +40 -0
- package/dist/server/services/private-content/graphql/resolvers/findPage.js +44 -0
- package/dist/server/services/private-content/graphql/resolvers/forgot-password.js +29 -0
- package/dist/server/services/private-content/graphql/resolvers/login.js +49 -0
- package/dist/server/services/private-content/graphql/resolvers/register.js +68 -0
- package/dist/server/services/private-content/graphql/resolvers/reset-password.js +41 -0
- package/dist/server/services/private-content/graphql/types/index.js +89 -0
- package/dist/server/services/private-content/index.js +94 -0
- package/dist/server/services/private-content/mail-template/txtMail.email.template.text.js +12 -0
- package/dist/server/services/private-content/page.js +22 -0
- package/dist/server/services/private-content/platform.js +22 -0
- package/dist/server/services/private-content/schemas/index.js +30 -0
- package/dist/server/services/private-content/user.js +170 -0
- package/dist/server/services/sitemap.js +78 -0
- package/dist/server/services/template.js +1 -2
- package/dist/server/services/user-category.js +4 -0
- package/dist/server/utils/strapi.js +1 -4
- package/dist/shared/utils/constants.js +1 -3
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +12 -10
- package/server/bootstrap/collection-type-lifecycles.ts +1 -1
- package/server/bootstrap/permissions.ts +10 -75
- package/server/bootstrap.ts +24 -43
- package/server/controllers/index.ts +1 -3
- package/server/graphql/page-by-slug.ts +43 -50
- package/server/graphql/pages-by-uid.ts +7 -9
- package/server/routes/index.ts +0 -21
- package/server/schema/page-end.json +0 -5
- package/server/services/builder.ts +6 -18
- package/server/services/index.ts +1 -3
- package/server/services/template.ts +1 -2
- package/server/utils/strapi.ts +1 -5
- package/shared/utils/constants.ts +0 -2
- package/admin/src/api/platform.ts +0 -34
- package/admin/src/components/EditView/Platform/platform-select.tsx +0 -30
- package/admin/src/components/PageFilters/PageTypeFilter/index.tsx +0 -39
- package/admin/src/components/PageFilters/PlatformFilter/index.tsx +0 -28
- package/admin/src/components/PageFilters/filters.tsx +0 -180
- package/admin/src/components/PageFilters/index.tsx +0 -30
- package/server/controllers/platform.ts +0 -21
- package/server/schema/platform-start.json +0 -31
- package/server/services/platform.ts +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webbio/strapi-plugin-page-builder",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4-legacy",
|
|
4
4
|
"description": "This is the description of the plugin.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"develop": "tsc -p tsconfig.server.json -w",
|
|
@@ -20,14 +20,16 @@
|
|
|
20
20
|
"url": "https://github.com/webbio/strapi-plugin-page-builder.git"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@strapi/design-system": "^1.
|
|
24
|
-
"@strapi/helper-plugin": "^4.
|
|
25
|
-
"@strapi/icons": "^1.
|
|
26
|
-
"@strapi/typescript-utils": "
|
|
27
|
-
"@strapi/utils": "
|
|
28
|
-
"react-select": "^5.7.4"
|
|
23
|
+
"@strapi/design-system": "^1.19.0",
|
|
24
|
+
"@strapi/helper-plugin": "^4.25.22",
|
|
25
|
+
"@strapi/icons": "^1.19.0",
|
|
26
|
+
"@strapi/typescript-utils": "4.25.22",
|
|
27
|
+
"@strapi/utils": "4.25.22",
|
|
28
|
+
"react-select": "^5.7.4",
|
|
29
|
+
"slugify": "^1.6.6"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
32
|
+
"@strapi/typescript-utils": "4.25.22",
|
|
31
33
|
"@types/react": "^18.2.21",
|
|
32
34
|
"@types/react-dom": "^18.2.7",
|
|
33
35
|
"@types/react-router-dom": "^5.3.3",
|
|
@@ -39,8 +41,8 @@
|
|
|
39
41
|
"typescript": "5.1.6"
|
|
40
42
|
},
|
|
41
43
|
"peerDependencies": {
|
|
42
|
-
"@strapi/strapi": "
|
|
43
|
-
"@webbio/strapi-plugin-slug": "^
|
|
44
|
+
"@strapi/strapi": "4.25.22",
|
|
45
|
+
"@webbio/strapi-plugin-slug": "^4.0.10",
|
|
44
46
|
"react": "^17.0.0 || ^18.0.0",
|
|
45
47
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
46
48
|
"react-router-dom": "^5.3.4",
|
|
@@ -59,7 +61,7 @@
|
|
|
59
61
|
}
|
|
60
62
|
],
|
|
61
63
|
"engines": {
|
|
62
|
-
"node": ">=14.19.1 <=
|
|
64
|
+
"node": ">=14.19.1 <=20.x.x",
|
|
63
65
|
"npm": ">=6.0.0"
|
|
64
66
|
},
|
|
65
67
|
"license": "MIT",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Strapi } from '@strapi/strapi';
|
|
2
|
-
import { PAGE_TYPE_UID
|
|
2
|
+
import { PAGE_TYPE_UID } from '../../shared/utils/constants';
|
|
3
3
|
|
|
4
4
|
export default async ({ strapi }: { strapi: Strapi }) => {
|
|
5
5
|
try {
|
|
@@ -7,84 +7,26 @@ export default async ({ strapi }: { strapi: Strapi }) => {
|
|
|
7
7
|
limit: -1
|
|
8
8
|
})) as Record<string, any>[];
|
|
9
9
|
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const platformPagePermissions = platforms.map((platform) => {
|
|
15
|
-
return pageTypes.map((pageType) => {
|
|
16
|
-
const name = `platform-is-${platform.title}-${pageType.uid}`;
|
|
17
|
-
const displayName = `${platform.title}-${pageType.title}`;
|
|
18
|
-
|
|
19
|
-
return {
|
|
20
|
-
plugin: 'page-builder',
|
|
21
|
-
name,
|
|
22
|
-
displayName,
|
|
23
|
-
category: `${platform.title} Page roles`,
|
|
24
|
-
handler: async () => {
|
|
25
|
-
return {
|
|
26
|
-
$and: [
|
|
27
|
-
{
|
|
28
|
-
'platform.id': {
|
|
29
|
-
$eq: platform.id
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
'pageType.uid': {
|
|
34
|
-
$eq: pageType.uid
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
uid: {
|
|
39
|
-
$eq: pageType.uid
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
]
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const pageTypePermissions = pageTypes.map((pageType) => {
|
|
50
|
-
const name = `pageType-permission-${pageType.uid}`;
|
|
51
|
-
const displayName = `pageType ${pageType.title}`;
|
|
10
|
+
const pagePermissions = pageTypes.map((pageType) => {
|
|
11
|
+
const name = `page-type-is-${pageType.uid}`;
|
|
12
|
+
const displayName = pageType.title;
|
|
52
13
|
|
|
53
14
|
return {
|
|
54
15
|
plugin: 'page-builder',
|
|
55
16
|
name,
|
|
56
17
|
displayName,
|
|
57
|
-
category:
|
|
58
|
-
handler: async () => {
|
|
59
|
-
return {
|
|
60
|
-
uid: {
|
|
61
|
-
$eq: pageType.uid
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const platformCollectiontypePermissions = platforms.map((platform) => {
|
|
69
|
-
const name = `platform-is-${platform.title}`;
|
|
70
|
-
const displayName = platform.title;
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
plugin: 'page-builder',
|
|
74
|
-
name,
|
|
75
|
-
displayName,
|
|
76
|
-
category: 'Platform CollectionType roles',
|
|
18
|
+
category: 'Page type',
|
|
77
19
|
handler: async () => {
|
|
78
20
|
return {
|
|
79
21
|
$or: [
|
|
80
22
|
{
|
|
81
|
-
'
|
|
82
|
-
$eq:
|
|
23
|
+
'pageType.uid': {
|
|
24
|
+
$eq: pageType.uid
|
|
83
25
|
}
|
|
84
26
|
},
|
|
85
27
|
{
|
|
86
|
-
|
|
87
|
-
$eq:
|
|
28
|
+
uid: {
|
|
29
|
+
$eq: pageType.uid
|
|
88
30
|
}
|
|
89
31
|
}
|
|
90
32
|
]
|
|
@@ -92,15 +34,8 @@ export default async ({ strapi }: { strapi: Strapi }) => {
|
|
|
92
34
|
}
|
|
93
35
|
};
|
|
94
36
|
});
|
|
95
|
-
|
|
96
|
-
const allPermissions = [
|
|
97
|
-
...platformPagePermissions.flat(),
|
|
98
|
-
...pageTypePermissions.flat(),
|
|
99
|
-
...platformCollectiontypePermissions
|
|
100
|
-
];
|
|
101
|
-
|
|
102
37
|
// @ts-ignore shitty types
|
|
103
|
-
await strapi.admin.services.permission.conditionProvider.registerMany(
|
|
38
|
+
await strapi.admin.services.permission.conditionProvider.registerMany(pagePermissions);
|
|
104
39
|
} catch {
|
|
105
40
|
console.log('Cannot set page permissions');
|
|
106
41
|
}
|
package/server/bootstrap.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Common, Strapi } from '@strapi/strapi';
|
|
2
2
|
import { errors } from '@strapi/utils';
|
|
3
|
-
import { PAGE_TYPE_UID, PAGE_UID
|
|
3
|
+
import { PAGE_TYPE_UID, PAGE_UID } from '../shared/utils/constants';
|
|
4
4
|
import permissions from './bootstrap/permissions';
|
|
5
5
|
import collectionTypeLifecycles from './bootstrap/collection-type-lifecycles';
|
|
6
6
|
|
|
@@ -27,7 +27,6 @@ export default async ({ strapi }: { strapi: Strapi }) => {
|
|
|
27
27
|
let { data } = event.params;
|
|
28
28
|
const collectionTypeId = data?.collectionTypeId;
|
|
29
29
|
const pageTypeId = data?.pageType.connect?.[0]?.id || data.initialPageType;
|
|
30
|
-
const platformId = data?.platform.connect?.[0]?.id;
|
|
31
30
|
|
|
32
31
|
if (collectionTypeId && pageTypeId) {
|
|
33
32
|
const pageType: Record<string, any> | undefined | null = await strapi.entityService?.findOne(
|
|
@@ -40,26 +39,10 @@ export default async ({ strapi }: { strapi: Strapi }) => {
|
|
|
40
39
|
|
|
41
40
|
const page: Record<string, any>[] = collectionToConnect?.page as any;
|
|
42
41
|
|
|
43
|
-
const foundPlatforms: Record<string, any> | undefined | null = await strapi.entityService?.findMany(
|
|
44
|
-
PLATFORM_UID,
|
|
45
|
-
{
|
|
46
|
-
populate: '*',
|
|
47
|
-
filters: {
|
|
48
|
-
pagetype: {
|
|
49
|
-
uid: pageType?.uid
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
|
|
55
42
|
if (page && page.length > 0) {
|
|
56
43
|
throw new errors.ValidationError('You can only link one CollectionType to one page');
|
|
57
44
|
}
|
|
58
45
|
|
|
59
|
-
if (platformId && !foundPlatforms?.some((platform) => platform.id === platformId)) {
|
|
60
|
-
throw new errors.ValidationError('Platform not found');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
46
|
data = updateCollectionTypeData(data, collectionTypeId, pageType?.uid);
|
|
64
47
|
}
|
|
65
48
|
},
|
|
@@ -115,6 +98,8 @@ export default async ({ strapi }: { strapi: Strapi }) => {
|
|
|
115
98
|
data = updateCollectionTypeData(data, collectionTypeId, pageType?.uid);
|
|
116
99
|
}
|
|
117
100
|
|
|
101
|
+
// needs to check if the collectionTypeData is already connected to another page
|
|
102
|
+
// if so, remove the hasPage for filtering
|
|
118
103
|
if (
|
|
119
104
|
data.collectionTypeData &&
|
|
120
105
|
originalEntity?.collectionTypeData?.[0]?.__type &&
|
|
@@ -137,32 +122,28 @@ export default async ({ strapi }: { strapi: Strapi }) => {
|
|
|
137
122
|
}
|
|
138
123
|
},
|
|
139
124
|
async afterUpdate(event) {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
data
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
await strapi.entityService?.update(data.collectionTypeData.__type, data.collectionTypeData.id, {
|
|
158
|
-
data: {
|
|
159
|
-
id: data.collectionTypeData.id,
|
|
160
|
-
hasPage: true,
|
|
161
|
-
lifecycleState: {
|
|
162
|
-
exit: true
|
|
125
|
+
try {
|
|
126
|
+
// Result not correctly typed within Strapi
|
|
127
|
+
const data = event?.['result'];
|
|
128
|
+
const hasCollectionTypeRelation =
|
|
129
|
+
data && data?.collectionTypeData?.[0] && data?.collectionTypeData[0].__type && data?.collectionTypeData[0].id;
|
|
130
|
+
|
|
131
|
+
if (hasCollectionTypeRelation) {
|
|
132
|
+
const isPublished = data.publishedAt !== undefined;
|
|
133
|
+
const pageData = isPublished ? { hasPage: !!data.publishedAt } : {};
|
|
134
|
+
|
|
135
|
+
await strapi.entityService?.update(data.collectionTypeData[0].__type, data.collectionTypeData[0].id, {
|
|
136
|
+
data: {
|
|
137
|
+
...pageData,
|
|
138
|
+
id: data.collectionTypeData[0].id,
|
|
139
|
+
lifecycleState: {
|
|
140
|
+
exit: true
|
|
141
|
+
}
|
|
163
142
|
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
} catch (error) {
|
|
146
|
+
console.error('Failed to save hasPage data', error);
|
|
166
147
|
}
|
|
167
148
|
},
|
|
168
149
|
async beforeDelete(event) {
|
|
@@ -2,12 +2,10 @@ import page from './page';
|
|
|
2
2
|
import pageType from './page-type';
|
|
3
3
|
import collectionTypes from './collection-types';
|
|
4
4
|
import template from './template';
|
|
5
|
-
import platform from './platform';
|
|
6
5
|
|
|
7
6
|
export default {
|
|
8
7
|
page,
|
|
9
8
|
'page-type': pageType,
|
|
10
9
|
'collection-types': collectionTypes,
|
|
11
|
-
template
|
|
12
|
-
platform
|
|
10
|
+
template
|
|
13
11
|
};
|
|
@@ -11,7 +11,7 @@ const getPageBySlug = (strapi: Strapi) => {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
type Query {
|
|
14
|
-
getPageBySlug(path: String,
|
|
14
|
+
getPageBySlug(path: String, _locale: String, _publicationState: PublicationState): PageEntity
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
`;
|
|
@@ -24,63 +24,56 @@ const getPageBySlug = (strapi: Strapi) => {
|
|
|
24
24
|
Query: {
|
|
25
25
|
getPageBySlug: {
|
|
26
26
|
resolve: async (_parent: any, args: Record<string, any>, ctx: any) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
throw new Error(ctx.koaContext.response.message);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const collectionTypeDataFilter = entityResponse?.value?.collectionTypeData?.filter(Boolean);
|
|
27
|
+
const filteredArgs = {
|
|
28
|
+
...filterUnderscoreArguments(args)
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const { toEntityResponse } = strapi.plugin('graphql').service('format').returnTypes;
|
|
32
|
+
|
|
33
|
+
const getPage = async () => {
|
|
34
|
+
const transformedArgs = transformArgs(filteredArgs, {
|
|
35
|
+
contentType: strapi.contentTypes[PAGE_UID],
|
|
36
|
+
usePagination: false
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const results = await strapi.entityService?.findMany(PAGE_UID, {
|
|
40
|
+
filters: transformedArgs,
|
|
41
|
+
locale: args._locale,
|
|
42
|
+
publicationState: args._publicationState,
|
|
43
|
+
populate: '*'
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const entityResponse = toEntityResponse(results?.[0] || {}, {
|
|
47
|
+
args: transformedArgs,
|
|
48
|
+
resourceUID: PAGE_UID
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (!entityResponse?.value || Object.keys(entityResponse.value).length === 0) {
|
|
52
|
+
throw new Error(ctx.koaContext.response.message);
|
|
53
|
+
}
|
|
58
54
|
|
|
59
|
-
|
|
60
|
-
collectionTypeDataFilter.length === 1 ? collectionTypeDataFilter?.[0] : null;
|
|
55
|
+
const collectionTypeDataFilter = entityResponse?.value?.collectionTypeData?.filter(Boolean);
|
|
61
56
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
};
|
|
57
|
+
const collectionType: Record<string, any> | null =
|
|
58
|
+
collectionTypeDataFilter.length === 1 ? collectionTypeDataFilter?.[0] : null;
|
|
65
59
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
60
|
+
const addedAttributes = {
|
|
61
|
+
collectionType: collectionType
|
|
62
|
+
};
|
|
70
63
|
|
|
71
|
-
|
|
64
|
+
const result = {
|
|
65
|
+
...entityResponse.value,
|
|
66
|
+
...addedAttributes
|
|
72
67
|
};
|
|
73
68
|
|
|
74
|
-
|
|
69
|
+
return result;
|
|
70
|
+
};
|
|
75
71
|
|
|
76
|
-
|
|
77
|
-
return results;
|
|
78
|
-
} else {
|
|
79
|
-
throw new Error(ctx.koaContext.response.message);
|
|
80
|
-
}
|
|
81
|
-
} catch (error) {
|
|
82
|
-
console.log('Error in getPageBySlug:', error);
|
|
72
|
+
const results: Record<string, any> = await getPage();
|
|
83
73
|
|
|
74
|
+
if (Object.values(results)?.filter(Boolean).length > 0) {
|
|
75
|
+
return results;
|
|
76
|
+
} else {
|
|
84
77
|
throw new Error(ctx.koaContext.response.message);
|
|
85
78
|
}
|
|
86
79
|
}
|
|
@@ -16,16 +16,13 @@ const getPageInfoFromUID = (strapi: Strapi) => {
|
|
|
16
16
|
pageSize: Int
|
|
17
17
|
}`;
|
|
18
18
|
const entityInfo = collectionTypes.map((collectionType) => {
|
|
19
|
-
return `
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
type Query {
|
|
25
|
-
get${collectionType.type}Pages(filters: ${collectionType.type}FiltersInput,pagination: PaginationArg, pageFilters: PageFiltersInput): ${collectionType.type}EntityResponseCollection
|
|
26
|
-
}
|
|
19
|
+
return `extend type ${collectionType.type}EntityResponseCollection {
|
|
20
|
+
metaInfo: MetaInfo
|
|
21
|
+
}
|
|
27
22
|
|
|
28
|
-
|
|
23
|
+
type Query {
|
|
24
|
+
get${collectionType.type}Pages(filters: ${collectionType.type}FiltersInput, pagination: PaginationArg, sort:[String], pageFilters: PageFiltersInput): ${collectionType.type}EntityResponseCollection
|
|
25
|
+
}`;
|
|
29
26
|
});
|
|
30
27
|
|
|
31
28
|
return `${metaInfo} ${entityInfo}`;
|
|
@@ -67,6 +64,7 @@ const getPageInfoFromUID = (strapi: Strapi) => {
|
|
|
67
64
|
hasPage: { $eq: true },
|
|
68
65
|
page: { ...transformedpageArgs.filters }
|
|
69
66
|
},
|
|
67
|
+
sort: transformedArgs.sort,
|
|
70
68
|
start: start,
|
|
71
69
|
limit: limit
|
|
72
70
|
});
|
package/server/routes/index.ts
CHANGED
|
@@ -52,27 +52,6 @@ const routes = {
|
|
|
52
52
|
handler: 'template.findOneById'
|
|
53
53
|
}
|
|
54
54
|
]
|
|
55
|
-
},
|
|
56
|
-
platform: {
|
|
57
|
-
type: 'admin',
|
|
58
|
-
prefix: undefined,
|
|
59
|
-
routes: [
|
|
60
|
-
{
|
|
61
|
-
method: 'GET',
|
|
62
|
-
path: '/platform',
|
|
63
|
-
handler: 'platform.findAll'
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
method: 'GET',
|
|
67
|
-
path: '/platform/:uid',
|
|
68
|
-
handler: 'platform.findOneByUid'
|
|
69
|
-
},
|
|
70
|
-
{
|
|
71
|
-
method: 'GET',
|
|
72
|
-
path: '/platform/:platform/page-types',
|
|
73
|
-
handler: 'platform.findPageTypesByPlatform'
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
55
|
}
|
|
77
56
|
};
|
|
78
57
|
|
|
@@ -4,14 +4,13 @@ import { Common } from '@strapi/strapi';
|
|
|
4
4
|
import pageStart from '../schema/page-start.json';
|
|
5
5
|
import pageEnd from '../schema/page-end.json';
|
|
6
6
|
import pluginId from '../../admin/src/pluginId';
|
|
7
|
-
import { PAGE_UID, TEMPLATE_UID, PAGE_TYPE_UID
|
|
7
|
+
import { PAGE_UID, TEMPLATE_UID, PAGE_TYPE_UID } from '../../shared/utils/constants';
|
|
8
8
|
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 platformStart from '../schema/platform-start.json';
|
|
13
12
|
|
|
14
|
-
const UIDS: Common.UID.ContentType[] = [TEMPLATE_UID, PAGE_TYPE_UID,
|
|
13
|
+
const UIDS: Common.UID.ContentType[] = [TEMPLATE_UID, PAGE_TYPE_UID, PAGE_UID];
|
|
15
14
|
|
|
16
15
|
export default {
|
|
17
16
|
async buildContentTypes() {
|
|
@@ -88,10 +87,6 @@ export default {
|
|
|
88
87
|
[TEMPLATE_UID]: {
|
|
89
88
|
create: this.getTemplateContentType(),
|
|
90
89
|
update: this.getTemplateContentType()
|
|
91
|
-
},
|
|
92
|
-
[PLATFORM_UID]: {
|
|
93
|
-
create: this.getPlatformContentType(),
|
|
94
|
-
update: this.getPlatformContentType()
|
|
95
90
|
}
|
|
96
91
|
};
|
|
97
92
|
|
|
@@ -99,30 +94,23 @@ export default {
|
|
|
99
94
|
},
|
|
100
95
|
getPageContentType(create?: boolean) {
|
|
101
96
|
const page = create ? pageStart : pageEnd;
|
|
102
|
-
const contentType = this.
|
|
97
|
+
const contentType = this.mergeCollectionTypeWithModules(page, PAGE_UID);
|
|
103
98
|
|
|
104
99
|
return { uid: PAGE_UID, contentType };
|
|
105
100
|
},
|
|
106
101
|
getPageTypeContentType(create?: boolean) {
|
|
107
102
|
const pageType = create ? pageTypeStart : pageTypeEnd;
|
|
108
|
-
const contentType = this.
|
|
103
|
+
const contentType = this.mergeCollectionTypeWithModules(pageType, PAGE_TYPE_UID);
|
|
109
104
|
|
|
110
105
|
return { uid: PAGE_TYPE_UID, contentType };
|
|
111
106
|
},
|
|
112
107
|
getTemplateContentType() {
|
|
113
108
|
const template = templateStart;
|
|
114
|
-
const contentType = this.
|
|
109
|
+
const contentType = this.mergeCollectionTypeWithModules(template, TEMPLATE_UID);
|
|
115
110
|
|
|
116
111
|
return { uid: TEMPLATE_UID, contentType };
|
|
117
112
|
},
|
|
118
|
-
|
|
119
|
-
const platform = platformStart;
|
|
120
|
-
|
|
121
|
-
const contentType = this.mergeCollectionTypeWithOld(platform, PLATFORM_UID);
|
|
122
|
-
|
|
123
|
-
return { uid: PLATFORM_UID, contentType };
|
|
124
|
-
},
|
|
125
|
-
mergeCollectionTypeWithOld(collectionType: Record<string, any>, uid: Common.UID.ContentType) {
|
|
113
|
+
mergeCollectionTypeWithModules(collectionType: Record<string, any>, uid: Common.UID.ContentType) {
|
|
126
114
|
const { pluginOptions: oldPluginOptions, __schema__: oldSchema } = (strapi.contentType(uid) as any) || {};
|
|
127
115
|
const modulesFromConfig = oldSchema?.attributes?.modules ? this.getConfigModuleComponents() : undefined;
|
|
128
116
|
|
package/server/services/index.ts
CHANGED
|
@@ -3,13 +3,11 @@ import builder from './builder';
|
|
|
3
3
|
import pageType from './page-type';
|
|
4
4
|
import collectionTypes from './collection-types';
|
|
5
5
|
import template from './template';
|
|
6
|
-
import platform from './platform';
|
|
7
6
|
|
|
8
7
|
export default {
|
|
9
8
|
page,
|
|
10
9
|
builder,
|
|
11
10
|
'page-type': pageType,
|
|
12
11
|
'collection-types': collectionTypes,
|
|
13
|
-
template
|
|
14
|
-
platform
|
|
12
|
+
template
|
|
15
13
|
};
|
package/server/utils/strapi.ts
CHANGED
|
@@ -14,17 +14,13 @@ export const getDeepPopulate = (uid: Common.UID.Component, populate?: any, depth
|
|
|
14
14
|
return Object.keys(attributes).reduce((populateAcc, attributeName) => {
|
|
15
15
|
const attribute = attributes[attributeName];
|
|
16
16
|
|
|
17
|
-
if (attribute.type === 'relation') {
|
|
18
|
-
return populateAcc;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
17
|
if (attribute.type === 'component') {
|
|
22
18
|
populateAcc[attributeName] = {
|
|
23
19
|
populate: getDeepPopulate(attribute.component, null, depth + 1)
|
|
24
20
|
};
|
|
25
21
|
}
|
|
26
22
|
|
|
27
|
-
if (attribute.type === 'media') {
|
|
23
|
+
if (attribute.type === 'relation' || attribute.type === 'media') {
|
|
28
24
|
populateAcc[attributeName] = true;
|
|
29
25
|
}
|
|
30
26
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export const PAGE_UID = 'api::page.page';
|
|
2
2
|
export const TEMPLATE_UID = 'api::template.template';
|
|
3
3
|
export const PAGE_TYPE_UID = 'api::page-type.page-type';
|
|
4
|
-
export const PLATFORM_UID = 'api::platform.platform';
|
|
5
4
|
export const PAGE_TYPE_PAGE = 'page';
|
|
6
|
-
export const PLATFORM = 'platform';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { useQuery } from 'react-query';
|
|
2
|
-
|
|
3
|
-
import { useFetchClient } from '@strapi/helper-plugin';
|
|
4
|
-
|
|
5
|
-
import getRequestUrl from '../utils/getRequestUrl';
|
|
6
|
-
import { PageType } from './page-type';
|
|
7
|
-
|
|
8
|
-
export type Platform = {
|
|
9
|
-
id: number;
|
|
10
|
-
title?: string;
|
|
11
|
-
pageTypes?: PageType[];
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const QUERY_KEY = 'platforms';
|
|
15
|
-
|
|
16
|
-
const fetchPlatforms = async ({ fetchClient }: any): Promise<Platform[]> => {
|
|
17
|
-
const { get } = fetchClient;
|
|
18
|
-
const result = await get('/content-manager/collection-types/api::platform.platform');
|
|
19
|
-
|
|
20
|
-
return result?.data?.results.map((entity: any) => ({
|
|
21
|
-
id: entity.id,
|
|
22
|
-
title: entity.title,
|
|
23
|
-
pageTypes: entity.pageTypes
|
|
24
|
-
}));
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const useGetPlatforms = (params: any) => {
|
|
28
|
-
const fetchClient = useFetchClient();
|
|
29
|
-
params = {
|
|
30
|
-
...params,
|
|
31
|
-
fetchClient
|
|
32
|
-
};
|
|
33
|
-
return useQuery<Platform[], Error>(QUERY_KEY, () => fetchPlatforms(params));
|
|
34
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { SingleSelect, SingleSelectOption } from '@strapi/design-system';
|
|
4
|
-
|
|
5
|
-
import { Platform } from '../../../api/platform';
|
|
6
|
-
import { PLATFORM } from '../../../../../shared/utils/constants';
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
onChange: (platformId: string) => void;
|
|
10
|
-
selectedPlatform?: Platform | null;
|
|
11
|
-
platforms?: Platform[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const PlatformSelect = ({ onChange, platforms, selectedPlatform }: Props) => {
|
|
15
|
-
return (
|
|
16
|
-
<SingleSelect
|
|
17
|
-
label="Platform"
|
|
18
|
-
placeholder="Choose a platform"
|
|
19
|
-
value={selectedPlatform?.id || PLATFORM}
|
|
20
|
-
onChange={onChange}
|
|
21
|
-
>
|
|
22
|
-
<SingleSelectOption value={PLATFORM}>Platform</SingleSelectOption>
|
|
23
|
-
{platforms?.map((pageType: Platform) => (
|
|
24
|
-
<SingleSelectOption key={pageType?.id} value={pageType?.id}>
|
|
25
|
-
{pageType?.title}
|
|
26
|
-
</SingleSelectOption>
|
|
27
|
-
))}
|
|
28
|
-
</SingleSelect>
|
|
29
|
-
);
|
|
30
|
-
};
|