@webbio/strapi-plugin-page-builder 0.2.2 → 0.3.0
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 +6 -18
- package/admin/src/api/collection-type.ts +7 -1
- package/admin/src/api/platform.ts +34 -0
- package/admin/src/components/Combobox/react-select-custom-styles.tsx +12 -3
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +17 -14
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +5 -1
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +5 -15
- package/admin/src/components/EditView/PageSettings/index.tsx +57 -6
- package/admin/src/components/EditView/Platform/platform-select.tsx +30 -0
- package/admin/src/components/EditView/Template/TemplateSelect/index.tsx +2 -2
- package/admin/src/components/EditView/index.tsx +1 -1
- package/admin/src/components/EditView/page-type-select.tsx +1 -1
- package/admin/src/components/PageFilters/PageTypeFilter/index.tsx +39 -0
- package/admin/src/components/PageFilters/PlatformFilter/index.tsx +28 -0
- package/admin/src/components/PageFilters/filters.tsx +180 -0
- package/admin/src/components/PageFilters/index.tsx +30 -0
- package/admin/src/index.tsx +2 -2
- package/admin/src/utils/hooks/useGetLocaleFromUrl.ts +1 -1
- package/dist/package.json +5 -6
- package/dist/server/bootstrap.js +15 -5
- package/dist/server/controllers/index.js +3 -1
- package/dist/server/graphql/pages-by-uid.js +1 -2
- package/dist/server/routes/index.js +21 -0
- package/dist/server/schema/page-end.json +5 -0
- package/dist/server/services/builder.js +20 -7
- package/dist/server/services/index.js +3 -1
- package/dist/shared/utils/constants.js +3 -1
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +5 -6
- package/server/bootstrap/collection-type-lifecycles.ts +1 -1
- package/server/bootstrap.ts +18 -3
- package/server/controllers/index.ts +3 -1
- package/server/controllers/platform.ts +21 -0
- package/server/graphql/pages-by-uid.ts +1 -2
- package/server/routes/index.ts +21 -0
- package/server/schema/page-end.json +5 -0
- package/server/schema/platform-start.json +31 -0
- package/server/services/builder.ts +23 -8
- package/server/services/index.ts +3 -1
- package/server/services/platform.ts +36 -0
- package/shared/utils/constants.ts +2 -0
- package/admin/src/components/PageTypeFilter/index.tsx +0 -17
- package/admin/src/components/PageTypeFilter/page-type-filter.tsx +0 -130
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import set from 'lodash/set';
|
|
3
|
+
|
|
4
|
+
import { Stack } from '@strapi/design-system';
|
|
5
|
+
import { useQueryParams } from '@strapi/helper-plugin';
|
|
6
|
+
|
|
7
|
+
import PageTypeFilter from './PageTypeFilter';
|
|
8
|
+
import { PAGE_TYPE_PAGE, PLATFORM } from '../../../../shared/utils/constants';
|
|
9
|
+
import PlatformFilter from './PlatformFilter';
|
|
10
|
+
import { Platform, useGetPlatforms } from '../../api/platform';
|
|
11
|
+
import { PAGE_TYPE, PAGE_TYPE_NO_FILTER, PLATFORM_NO_FILTER } from '../../constants';
|
|
12
|
+
import { PageType } from '../../api/page-type';
|
|
13
|
+
|
|
14
|
+
interface PageFiltersProps {
|
|
15
|
+
hidePageType?: boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const PageFilters = ({ hidePageType }: PageFiltersProps) => {
|
|
19
|
+
const [{ query }, setQuery] = useQueryParams() as any;
|
|
20
|
+
|
|
21
|
+
const { data: platforms } = useGetPlatforms({});
|
|
22
|
+
|
|
23
|
+
const selectedPlatformTitle = useMemo(() => getPlatformFromQuery(query, platforms), [query, platforms]);
|
|
24
|
+
const selectedPageTypeUid = useMemo(
|
|
25
|
+
() => getPageTypeFromQuery(query, getPageTypesFromPlatformTitle(selectedPlatformTitle, platforms)),
|
|
26
|
+
[query, platforms, selectedPlatformTitle]
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const handleFilterChange = (
|
|
30
|
+
filters: Record<string, any>,
|
|
31
|
+
filterCategory: string,
|
|
32
|
+
filterCategoryToRemove?: string
|
|
33
|
+
) => {
|
|
34
|
+
const currentFilters = query.filters?.$and ? query.filters : { ...query.filters, $and: [] };
|
|
35
|
+
const filterIndex = currentFilters.$and.findIndex(
|
|
36
|
+
(x?: Record<string, any>) => Object.keys(x || {})?.[0] === filterCategory
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
if (filterIndex > -1) {
|
|
40
|
+
set(currentFilters, `$and[${filterIndex}]`, filters); // If the filter in this category already exists, replace it
|
|
41
|
+
} else {
|
|
42
|
+
currentFilters.$and.push(filters);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const removedFilters = removeFiltersFromQuery({ filters: currentFilters }, filterCategoryToRemove);
|
|
46
|
+
|
|
47
|
+
setQuery({
|
|
48
|
+
page: 1,
|
|
49
|
+
filters: removedFilters
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const removeFilters = (filterCategory: string) => {
|
|
54
|
+
const filters = removeFiltersFromQuery(query, filterCategory);
|
|
55
|
+
|
|
56
|
+
setQuery({
|
|
57
|
+
page: 1,
|
|
58
|
+
filters
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const handlePlatformSelect = (platformId: string) => {
|
|
63
|
+
if (platformId === PLATFORM_NO_FILTER) {
|
|
64
|
+
removeFilters(PLATFORM);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
handleFilterChange(getPlatformQueryFilter(platformId), PLATFORM, PAGE_TYPE);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const handlePageTypeSelect = (pageType: string) => {
|
|
72
|
+
if (pageType === PAGE_TYPE_NO_FILTER) {
|
|
73
|
+
removeFilters(PAGE_TYPE);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (pageType === PAGE_TYPE_PAGE) {
|
|
78
|
+
handleFilterChange(nullPageTypeQueryFilter, PAGE_TYPE);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
handleFilterChange(getPageTypeQueryFilter(pageType), PAGE_TYPE);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Stack horizontal spacing={2}>
|
|
87
|
+
<PlatformFilter onChange={handlePlatformSelect} platforms={platforms} selectedPlatform={selectedPlatformTitle} />
|
|
88
|
+
{!hidePageType && (
|
|
89
|
+
<PageTypeFilter
|
|
90
|
+
onChange={handlePageTypeSelect}
|
|
91
|
+
pageTypes={getPageTypesFromPlatformTitle(selectedPlatformTitle, platforms)}
|
|
92
|
+
selectedPageTypeUid={selectedPageTypeUid}
|
|
93
|
+
/>
|
|
94
|
+
)}
|
|
95
|
+
</Stack>
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export default PageFilters;
|
|
100
|
+
|
|
101
|
+
const getPageTypesFromPlatformTitle = (selectedPlatformTitle?: string, platforms?: Platform[]) =>
|
|
102
|
+
platforms?.find((p) => p.title === selectedPlatformTitle)?.pageTypes;
|
|
103
|
+
|
|
104
|
+
const getPageTypeFromQuery = (query: Record<string, any>, pageTypes?: PageType[]) => {
|
|
105
|
+
const pageTypeFromQuery = query?.filters?.$and?.find(
|
|
106
|
+
(x?: Record<string, any>) => Object.keys(x || {})?.[0] === PAGE_TYPE
|
|
107
|
+
)?.pageType;
|
|
108
|
+
|
|
109
|
+
if (pageTypeFromQuery?.uid?.$null === 'true') {
|
|
110
|
+
return PAGE_TYPE_PAGE;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (pageTypeFromQuery?.uid?.$eq) {
|
|
114
|
+
const matchingPageType = pageTypes?.find((pageType: any) => pageType?.uid === pageTypeFromQuery.uid.$eq);
|
|
115
|
+
|
|
116
|
+
if (matchingPageType) {
|
|
117
|
+
return matchingPageType.uid;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return PAGE_TYPE_NO_FILTER;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
const getPlatformFromQuery = (query: Record<string, any>, platforms?: Platform[]): string | undefined => {
|
|
125
|
+
const platformFromQuery = query?.filters?.$and?.find(
|
|
126
|
+
(x?: Record<string, any>) => Object.keys(x || {})?.[0] === PLATFORM
|
|
127
|
+
)?.platform;
|
|
128
|
+
|
|
129
|
+
if (platformFromQuery?.title?.$null === 'true') {
|
|
130
|
+
return PLATFORM_NO_FILTER;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (platformFromQuery?.title?.$eq) {
|
|
134
|
+
const matchingPageType = platforms?.find((platforms: Platform) => platforms?.title === platformFromQuery.title.$eq);
|
|
135
|
+
|
|
136
|
+
if (matchingPageType) {
|
|
137
|
+
return matchingPageType.title;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return PLATFORM_NO_FILTER;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
const getPlatformQueryFilter = (platform: string) => ({
|
|
145
|
+
platform: {
|
|
146
|
+
title: {
|
|
147
|
+
$eq: platform
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const getPageTypeQueryFilter = (pageType: string) => ({
|
|
153
|
+
pageType: {
|
|
154
|
+
uid: {
|
|
155
|
+
$eq: pageType
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const nullPageTypeQueryFilter = {
|
|
161
|
+
pageType: {
|
|
162
|
+
uid: {
|
|
163
|
+
$null: true
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const removeFiltersFromQuery = (query: Record<string, any>, filterCategory?: string) => {
|
|
169
|
+
const newAndFilters = query.filters?.$and?.filter(
|
|
170
|
+
(x?: Record<string, any>) => Object.keys(x || {})?.[0] !== filterCategory
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const filters = { ...query.filters, $and: newAndFilters };
|
|
174
|
+
|
|
175
|
+
if (newAndFilters && newAndFilters.length === 0) {
|
|
176
|
+
delete filters.$and;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return filters;
|
|
180
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useLocation } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import { PAGE_UID } from '../../../../shared/utils/constants';
|
|
6
|
+
|
|
7
|
+
import PageFilters from './filters';
|
|
8
|
+
import { useHasPageRelation } from '../../api/has-page-relation';
|
|
9
|
+
|
|
10
|
+
const PageFiltersContainer = () => {
|
|
11
|
+
const { pathname } = useLocation();
|
|
12
|
+
const uid = pathname.split('/').find((x) => x.startsWith('api::')) || '';
|
|
13
|
+
const isPageCollectionType = uid === PAGE_UID;
|
|
14
|
+
|
|
15
|
+
const { data: hasPageRelation, isLoading } = useHasPageRelation({
|
|
16
|
+
uid
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
if (isPageCollectionType) {
|
|
20
|
+
return <PageFilters />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!isPageCollectionType && hasPageRelation && !isLoading) {
|
|
24
|
+
return <PageFilters hidePageType />;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default PageFiltersContainer;
|
package/admin/src/index.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { prefixPluginTranslations } from '@strapi/helper-plugin';
|
|
|
3
3
|
import pluginPkg from '../../package.json';
|
|
4
4
|
import pluginId from './pluginId';
|
|
5
5
|
import Initializer from './components/Initializer';
|
|
6
|
-
import
|
|
6
|
+
import PageFiltersContainer from './components/PageFilters';
|
|
7
7
|
import { EditView } from './components/EditView';
|
|
8
8
|
import middlewares from './middlewares';
|
|
9
9
|
|
|
@@ -29,7 +29,7 @@ export default {
|
|
|
29
29
|
});
|
|
30
30
|
app.injectContentManagerComponent('listView', 'actions', {
|
|
31
31
|
name: 'page-filters',
|
|
32
|
-
Component:
|
|
32
|
+
Component: PageFiltersContainer
|
|
33
33
|
});
|
|
34
34
|
},
|
|
35
35
|
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webbio/strapi-plugin-page-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "This is the description of the plugin.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"develop": "tsc -p tsconfig.server.json -w",
|
|
@@ -21,14 +21,13 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@strapi/design-system": "^1.11.0",
|
|
24
|
-
"@strapi/helper-plugin": "^4.
|
|
24
|
+
"@strapi/helper-plugin": "^4.15.0",
|
|
25
25
|
"@strapi/icons": "^1.11.0",
|
|
26
|
-
"@strapi/typescript-utils": "^4.
|
|
27
|
-
"@strapi/utils": "^4.
|
|
26
|
+
"@strapi/typescript-utils": "^4.15.0",
|
|
27
|
+
"@strapi/utils": "^4.15.0",
|
|
28
28
|
"react-select": "^5.7.4"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@strapi/typescript-utils": "^4.13.6",
|
|
32
31
|
"@types/react": "^18.2.21",
|
|
33
32
|
"@types/react-dom": "^18.2.7",
|
|
34
33
|
"@types/react-router-dom": "^5.3.3",
|
|
@@ -40,7 +39,7 @@
|
|
|
40
39
|
"typescript": "5.1.6"
|
|
41
40
|
},
|
|
42
41
|
"peerDependencies": {
|
|
43
|
-
"@strapi/strapi": "^4.
|
|
42
|
+
"@strapi/strapi": "^4.15.0",
|
|
44
43
|
"@webbio/strapi-plugin-slug": "^2.0.2",
|
|
45
44
|
"react": "^17.0.0 || ^18.0.0",
|
|
46
45
|
"react-dom": "^17.0.0 || ^18.0.0",
|
package/dist/server/bootstrap.js
CHANGED
|
@@ -25,19 +25,31 @@ exports.default = async ({ strapi }) => {
|
|
|
25
25
|
// @ts-ignore
|
|
26
26
|
models: [constants_1.PAGE_UID],
|
|
27
27
|
async beforeCreate(event) {
|
|
28
|
-
var _a, _b, _c, _d;
|
|
28
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
29
29
|
let { data } = event.params;
|
|
30
30
|
const collectionTypeId = data === null || data === void 0 ? void 0 : data.collectionTypeId;
|
|
31
31
|
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;
|
|
32
|
+
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;
|
|
32
33
|
if (collectionTypeId && pageTypeId) {
|
|
33
|
-
const pageType = await ((
|
|
34
|
-
const collectionToConnect = await ((
|
|
34
|
+
const pageType = await ((_e = strapi.entityService) === null || _e === void 0 ? void 0 : _e.findOne(constants_1.PAGE_TYPE_UID, pageTypeId));
|
|
35
|
+
const collectionToConnect = await ((_f = strapi.entityService) === null || _f === void 0 ? void 0 : _f.findOne(pageType === null || pageType === void 0 ? void 0 : pageType.uid, collectionTypeId, {
|
|
35
36
|
populate: { page: true }
|
|
36
37
|
}));
|
|
37
38
|
const page = collectionToConnect === null || collectionToConnect === void 0 ? void 0 : collectionToConnect.page;
|
|
39
|
+
const foundPlatforms = await ((_g = strapi.entityService) === null || _g === void 0 ? void 0 : _g.findMany(constants_1.PLATFORM_UID, {
|
|
40
|
+
populate: '*',
|
|
41
|
+
filters: {
|
|
42
|
+
pagetype: {
|
|
43
|
+
uid: pageType === null || pageType === void 0 ? void 0 : pageType.uid
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}));
|
|
38
47
|
if (page && page.length > 0) {
|
|
39
48
|
throw new utils_1.errors.ValidationError('You can only link one CollectionType to one page');
|
|
40
49
|
}
|
|
50
|
+
if (platformId && !(foundPlatforms === null || foundPlatforms === void 0 ? void 0 : foundPlatforms.some((platform) => platform.id === platformId))) {
|
|
51
|
+
throw new utils_1.errors.ValidationError('Platform not found');
|
|
52
|
+
}
|
|
41
53
|
data = updateCollectionTypeData(data, collectionTypeId, pageType === null || pageType === void 0 ? void 0 : pageType.uid);
|
|
42
54
|
}
|
|
43
55
|
},
|
|
@@ -74,8 +86,6 @@ exports.default = async ({ strapi }) => {
|
|
|
74
86
|
}
|
|
75
87
|
data = updateCollectionTypeData(data, collectionTypeId, pageType === null || pageType === void 0 ? void 0 : pageType.uid);
|
|
76
88
|
}
|
|
77
|
-
// needs to check if the collectionTypeData is already connected to another page
|
|
78
|
-
// if so, remove the hasPage for filtering
|
|
79
89
|
if (data.collectionTypeData &&
|
|
80
90
|
((_r = (_q = originalEntity === null || originalEntity === void 0 ? void 0 : originalEntity.collectionTypeData) === null || _q === void 0 ? void 0 : _q[0]) === null || _r === void 0 ? void 0 : _r.__type) &&
|
|
81
91
|
((_t = (_s = originalEntity === null || originalEntity === void 0 ? void 0 : originalEntity.collectionTypeData) === null || _s === void 0 ? void 0 : _s[0]) === null || _t === void 0 ? void 0 : _t.id) &&
|
|
@@ -7,9 +7,11 @@ const page_1 = __importDefault(require("./page"));
|
|
|
7
7
|
const page_type_1 = __importDefault(require("./page-type"));
|
|
8
8
|
const collection_types_1 = __importDefault(require("./collection-types"));
|
|
9
9
|
const template_1 = __importDefault(require("./template"));
|
|
10
|
+
const platform_1 = __importDefault(require("./platform"));
|
|
10
11
|
exports.default = {
|
|
11
12
|
page: page_1.default,
|
|
12
13
|
'page-type': page_type_1.default,
|
|
13
14
|
'collection-types': collection_types_1.default,
|
|
14
|
-
template: template_1.default
|
|
15
|
+
template: template_1.default,
|
|
16
|
+
platform: platform_1.default
|
|
15
17
|
};
|
|
@@ -20,7 +20,7 @@ const getPageInfoFromUID = (strapi) => {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
type Query {
|
|
23
|
-
get${collectionType.type}Pages(filters: ${collectionType.type}FiltersInput,pagination: PaginationArg,
|
|
23
|
+
get${collectionType.type}Pages(filters: ${collectionType.type}FiltersInput,pagination: PaginationArg, pageFilters: PageFiltersInput): ${collectionType.type}EntityResponseCollection
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
`;
|
|
@@ -60,7 +60,6 @@ const getPageInfoFromUID = (strapi) => {
|
|
|
60
60
|
hasPage: { $eq: true },
|
|
61
61
|
page: { ...transformedpageArgs.filters }
|
|
62
62
|
},
|
|
63
|
-
sort: transformedArgs.sort,
|
|
64
63
|
start: start,
|
|
65
64
|
limit: limit
|
|
66
65
|
}));
|
|
@@ -54,6 +54,27 @@ const routes = {
|
|
|
54
54
|
handler: 'template.findOneById'
|
|
55
55
|
}
|
|
56
56
|
]
|
|
57
|
+
},
|
|
58
|
+
platform: {
|
|
59
|
+
type: 'admin',
|
|
60
|
+
prefix: undefined,
|
|
61
|
+
routes: [
|
|
62
|
+
{
|
|
63
|
+
method: 'GET',
|
|
64
|
+
path: '/platform',
|
|
65
|
+
handler: 'platform.findAll'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
method: 'GET',
|
|
69
|
+
path: '/platform/:uid',
|
|
70
|
+
handler: 'platform.findOneByUid'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
method: 'GET',
|
|
74
|
+
path: '/platform/:platform/page-types',
|
|
75
|
+
handler: 'platform.findPageTypesByPlatform'
|
|
76
|
+
}
|
|
77
|
+
]
|
|
57
78
|
}
|
|
58
79
|
};
|
|
59
80
|
exports.default = routes;
|
|
@@ -12,7 +12,8 @@ const reload_strapi_on_load_1 = require("../utils/reload-strapi-on-load");
|
|
|
12
12
|
const page_type_start_json_1 = __importDefault(require("../schema/page-type-start.json"));
|
|
13
13
|
const page_type_end_json_1 = __importDefault(require("../schema/page-type-end.json"));
|
|
14
14
|
const template_start_json_1 = __importDefault(require("../schema/template-start.json"));
|
|
15
|
-
const
|
|
15
|
+
const platform_start_json_1 = __importDefault(require("../schema/platform-start.json"));
|
|
16
|
+
const UIDS = [constants_1.TEMPLATE_UID, constants_1.PAGE_TYPE_UID, constants_1.PLATFORM_UID, constants_1.PAGE_UID];
|
|
16
17
|
exports.default = {
|
|
17
18
|
async buildContentTypes() {
|
|
18
19
|
this.listenToCreatedContentTypes();
|
|
@@ -72,29 +73,38 @@ exports.default = {
|
|
|
72
73
|
[constants_1.TEMPLATE_UID]: {
|
|
73
74
|
create: this.getTemplateContentType(),
|
|
74
75
|
update: this.getTemplateContentType()
|
|
76
|
+
},
|
|
77
|
+
[constants_1.PLATFORM_UID]: {
|
|
78
|
+
create: this.getPlatformContentType(),
|
|
79
|
+
update: this.getPlatformContentType()
|
|
75
80
|
}
|
|
76
81
|
};
|
|
77
82
|
return contentTypes === null || contentTypes === void 0 ? void 0 : contentTypes[uid];
|
|
78
83
|
},
|
|
79
84
|
getPageContentType(create) {
|
|
80
85
|
const page = create ? page_start_json_1.default : page_end_json_1.default;
|
|
81
|
-
const contentType = this.
|
|
86
|
+
const contentType = this.mergeCollectionTypeWithOld(page, constants_1.PAGE_UID);
|
|
82
87
|
return { uid: constants_1.PAGE_UID, contentType };
|
|
83
88
|
},
|
|
84
89
|
getPageTypeContentType(create) {
|
|
85
90
|
const pageType = create ? page_type_start_json_1.default : page_type_end_json_1.default;
|
|
86
|
-
const contentType = this.
|
|
91
|
+
const contentType = this.mergeCollectionTypeWithOld(pageType, constants_1.PAGE_TYPE_UID);
|
|
87
92
|
return { uid: constants_1.PAGE_TYPE_UID, contentType };
|
|
88
93
|
},
|
|
89
94
|
getTemplateContentType() {
|
|
90
95
|
const template = template_start_json_1.default;
|
|
91
|
-
const contentType = this.
|
|
96
|
+
const contentType = this.mergeCollectionTypeWithOld(template, constants_1.TEMPLATE_UID);
|
|
92
97
|
return { uid: constants_1.TEMPLATE_UID, contentType };
|
|
93
98
|
},
|
|
94
|
-
|
|
99
|
+
getPlatformContentType() {
|
|
100
|
+
const platform = platform_start_json_1.default;
|
|
101
|
+
const contentType = this.mergeCollectionTypeWithOld(platform, constants_1.PLATFORM_UID);
|
|
102
|
+
return { uid: constants_1.PLATFORM_UID, contentType };
|
|
103
|
+
},
|
|
104
|
+
mergeCollectionTypeWithOld(collectionType, uid) {
|
|
95
105
|
var _a;
|
|
96
106
|
const { pluginOptions: oldPluginOptions, __schema__: oldSchema } = strapi.contentType(uid) || {};
|
|
97
|
-
const
|
|
107
|
+
const modulesFromConfig = oldSchema.attributes.modules ? this.getConfigModuleComponents() : undefined;
|
|
98
108
|
return {
|
|
99
109
|
...collectionType,
|
|
100
110
|
displayName: ((_a = oldSchema === null || oldSchema === void 0 ? void 0 : oldSchema.info) === null || _a === void 0 ? void 0 : _a.displayName) || (collectionType === null || collectionType === void 0 ? void 0 : collectionType.displayName),
|
|
@@ -105,7 +115,10 @@ exports.default = {
|
|
|
105
115
|
attributes: {
|
|
106
116
|
...oldSchema === null || oldSchema === void 0 ? void 0 : oldSchema.attributes,
|
|
107
117
|
...collectionType.attributes,
|
|
108
|
-
modules
|
|
118
|
+
...(((collectionType.attributes.modules && collectionType.attributes.modules.length > 0) ||
|
|
119
|
+
modulesFromConfig) && {
|
|
120
|
+
modules: { ...collectionType.attributes.modules, components: modulesFromConfig }
|
|
121
|
+
})
|
|
109
122
|
}
|
|
110
123
|
};
|
|
111
124
|
},
|
|
@@ -8,10 +8,12 @@ const builder_1 = __importDefault(require("./builder"));
|
|
|
8
8
|
const page_type_1 = __importDefault(require("./page-type"));
|
|
9
9
|
const collection_types_1 = __importDefault(require("./collection-types"));
|
|
10
10
|
const template_1 = __importDefault(require("./template"));
|
|
11
|
+
const platform_1 = __importDefault(require("./platform"));
|
|
11
12
|
exports.default = {
|
|
12
13
|
page: page_1.default,
|
|
13
14
|
builder: builder_1.default,
|
|
14
15
|
'page-type': page_type_1.default,
|
|
15
16
|
'collection-types': collection_types_1.default,
|
|
16
|
-
template: template_1.default
|
|
17
|
+
template: template_1.default,
|
|
18
|
+
platform: platform_1.default
|
|
17
19
|
};
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PAGE_TYPE_PAGE = exports.PAGE_TYPE_UID = exports.TEMPLATE_UID = exports.PAGE_UID = void 0;
|
|
3
|
+
exports.PLATFORM = exports.PAGE_TYPE_PAGE = exports.PLATFORM_UID = exports.PAGE_TYPE_UID = exports.TEMPLATE_UID = exports.PAGE_UID = void 0;
|
|
4
4
|
exports.PAGE_UID = 'api::page.page';
|
|
5
5
|
exports.TEMPLATE_UID = 'api::template.template';
|
|
6
6
|
exports.PAGE_TYPE_UID = 'api::page-type.page-type';
|
|
7
|
+
exports.PLATFORM_UID = 'api::platform.platform';
|
|
7
8
|
exports.PAGE_TYPE_PAGE = 'page';
|
|
9
|
+
exports.PLATFORM = 'platform';
|