@webbio/strapi-plugin-page-builder 0.12.2-platform → 0.12.4-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 +166 -166
- package/admin/src/api/collection-type.ts +111 -111
- package/admin/src/api/entity-relation.ts +42 -42
- package/admin/src/api/has-page-relation.ts +37 -37
- package/admin/src/api/has-platform-relation.ts +40 -40
- package/admin/src/api/page-type-relation.ts +41 -41
- package/admin/src/api/platform-page-types.ts +45 -45
- package/admin/src/api/platform-relation.ts +42 -42
- package/admin/src/api/platform.ts +35 -35
- package/admin/src/api/search-filtered-entity.ts +114 -114
- package/admin/src/api/template.ts +39 -39
- package/admin/src/components/Combobox/index.tsx +83 -83
- package/admin/src/components/Combobox/react-select-custom-styles.tsx +121 -121
- package/admin/src/components/Combobox/styles.ts +46 -46
- package/admin/src/components/ConfirmModal/index.tsx +90 -90
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +127 -127
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +149 -149
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/styles.ts +19 -19
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +82 -82
- package/admin/src/components/EditView/Details/index.tsx +48 -48
- package/admin/src/components/EditView/Details/styles.ts +51 -51
- package/admin/src/components/EditView/PageSettings/index.tsx +124 -124
- package/admin/src/components/EditView/Platform/platform-select.tsx +30 -30
- package/admin/src/components/EditView/Template/TemplateConfirmModal/index.tsx +36 -36
- package/admin/src/components/EditView/Template/TemplateSelect/index.tsx +70 -70
- package/admin/src/components/EditView/Template/TemplateSelect/use-template-modules.ts +41 -41
- package/admin/src/components/EditView/index.tsx +35 -35
- package/admin/src/components/EditView/page-type-select.tsx +32 -32
- package/admin/src/components/EditView/wrapper.tsx +41 -41
- package/admin/src/components/GlobalPlatformSelect/index.tsx +40 -40
- package/admin/src/components/GlobalPlatformSelect/styles.ts +27 -27
- package/admin/src/components/Initializer/index.tsx +24 -24
- package/admin/src/components/PageFilters/PageTypeFilter/index.tsx +39 -39
- package/admin/src/components/PageFilters/PlatformFilter/index.tsx +32 -32
- package/admin/src/components/PageFilters/filters.tsx +189 -189
- package/admin/src/components/PageFilters/index.tsx +35 -35
- package/admin/src/components/PageTypeEditView/TemplatePlatformSelect/index.tsx +76 -76
- package/admin/src/components/PageTypeEditView/index.tsx +53 -53
- package/admin/src/components/PlatformFilteredSelectField/InputIcon/index.tsx +23 -23
- package/admin/src/components/PlatformFilteredSelectField/Multi/index.tsx +210 -210
- package/admin/src/components/PlatformFilteredSelectField/Single/index.tsx +197 -197
- package/admin/src/components/PlatformFilteredSelectField/hooks/useRelationLoad.tsx +128 -128
- package/admin/src/components/PlatformFilteredSelectField/index.tsx +85 -85
- package/admin/src/components/PlatformFilteredSelectField/styles.tsx +77 -77
- package/admin/src/components/PlatformFilteredSelectField/utils/get-translations.ts +3 -3
- package/admin/src/components/PlatformFilteredSelectField/utils/relation-helper.ts +147 -147
- package/admin/src/components/PluginIcon/index.tsx +94 -94
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/RelationInput.tsx +689 -689
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/RelationInputDataManager.tsx +6 -6
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/useRelation.ts +170 -170
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/utils/getRelationLink.ts +5 -5
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/components/Relations/utils/normalizeRelations.ts +52 -52
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/constants/attributes.ts +3 -3
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/hooks/useDragAndDrop.ts +253 -253
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/hooks/useKeyboardDragAndDrop.ts +96 -96
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/hooks/usePrev.ts +11 -11
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/utils/dragAndDrop.ts +8 -8
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/utils/paths.ts +29 -29
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/utils/refs.ts +19 -19
- package/admin/src/components/StrapiCore/admin/admin/src/content-manager/utils/translations.ts +3 -3
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/collection-types.ts +300 -300
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/components.ts +72 -72
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/content-types.ts +116 -116
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/index.ts +8 -8
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/init.ts +22 -22
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/relations.ts +80 -80
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/review-workflows.ts +88 -88
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/single-types.ts +112 -112
- package/admin/src/components/StrapiCore/content-manager/shared/contracts/uid.ts +48 -48
- package/admin/src/components/StrapiCore/content-manager/shared/index.ts +1 -1
- package/admin/src/constants.ts +3 -3
- package/admin/src/index.tsx +101 -101
- package/admin/src/middlewares/index.tsx +37 -37
- package/admin/src/pages/app/index.tsx +14 -14
- package/admin/src/pluginId.ts +5 -5
- package/admin/src/translations/en.json +9 -9
- package/admin/src/translations/nl.json +9 -9
- package/admin/src/utils/findDomElement.ts +6 -6
- package/admin/src/utils/findElementParent.ts +20 -20
- package/admin/src/utils/getObjectFromFormName.ts +42 -42
- package/admin/src/utils/getRequestUrl.ts +11 -11
- package/admin/src/utils/getTrad.ts +5 -5
- package/admin/src/utils/hooks/useDebounce.ts +17 -17
- package/admin/src/utils/hooks/useDefaultPlatformFromLocalStorage.ts +61 -61
- package/admin/src/utils/hooks/useGetLocaleFromUrl.ts +9 -9
- package/admin/src/utils/hooks/useHideOverviewFilterTags.ts +34 -34
- package/admin/src/utils/hooks/usePlatformFormData.ts +64 -64
- package/admin/src/utils/hooks/usePrevious.ts +12 -12
- package/admin/src/utils/sanitizeModules.ts +93 -93
- package/custom.d.ts +6 -6
- package/dist/package.json +1 -1
- package/dist/server/bootstrap/collection-type-lifecycles.js +1 -1
- package/dist/server/bootstrap.js +1 -1
- package/dist/server/graphql/page-by-path.js +20 -17
- package/dist/server/graphql/page-by-slug.js +9 -9
- package/dist/server/graphql/pages-by-uid.js +5 -5
- package/dist/server/services/private-content/graphql/index.js +27 -27
- package/dist/server/services/private-content/graphql/types/index.js +74 -74
- package/dist/server/utils/graphql.js +18 -18
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +78 -78
- package/server/bootstrap/collection-type-lifecycles.ts +47 -47
- package/server/bootstrap/permissions.ts +161 -161
- package/server/bootstrap.ts +261 -261
- package/server/config/index.ts +4 -4
- package/server/content-types/index.ts +7 -7
- package/server/content-types/user-category/schema.json +23 -23
- package/server/controllers/collection-types.ts +32 -32
- package/server/controllers/index.ts +19 -19
- package/server/controllers/page-type.ts +18 -18
- package/server/controllers/page.ts +9 -9
- package/server/controllers/platform.ts +21 -21
- package/server/controllers/private-content.ts +17 -17
- package/server/controllers/sitemap.ts +32 -32
- package/server/controllers/template.ts +16 -16
- package/server/controllers/user-category.ts +3 -3
- package/server/destroy.ts +5 -5
- package/server/graphql/index.ts +9 -9
- package/server/graphql/page-by-path.ts +135 -132
- package/server/graphql/page-type.ts +67 -67
- package/server/graphql/pages-by-uid.ts +89 -89
- package/server/index.ts +23 -23
- package/server/middlewares/index.ts +1 -1
- package/server/policies/index.ts +5 -5
- package/server/policies/isAuthorizedPage.ts +11 -11
- package/server/register.ts +22 -22
- package/server/routes/index.ts +115 -115
- package/server/routes/user-category.ts +3 -3
- package/server/schema/page-end.json +96 -96
- package/server/schema/page-start.json +87 -87
- package/server/schema/page-type-end.json +53 -53
- package/server/schema/page-type-start.json +38 -38
- package/server/schema/platform-start.json +21 -21
- package/server/schema/template-end.json +40 -40
- package/server/schema/template-start.json +35 -35
- package/server/services/builder.ts +232 -232
- package/server/services/collection-types.ts +95 -95
- package/server/services/email.ts +127 -127
- package/server/services/index.ts +23 -23
- package/server/services/page-type.ts +30 -30
- package/server/services/page.ts +24 -24
- package/server/services/platform.ts +30 -30
- package/server/services/private-content/components/admin-email.json +22 -22
- package/server/services/private-content/components/email.json +22 -22
- package/server/services/private-content/components/platform-email.json +30 -30
- package/server/services/private-content/constants/index.ts +13 -13
- package/server/services/private-content/graphql/index.ts +88 -88
- package/server/services/private-content/graphql/resolvers/findOnePage.ts +40 -40
- package/server/services/private-content/graphql/resolvers/findPage.ts +45 -45
- package/server/services/private-content/graphql/resolvers/forgot-password.ts +34 -34
- package/server/services/private-content/graphql/resolvers/login.ts +56 -56
- package/server/services/private-content/graphql/resolvers/register.ts +78 -78
- package/server/services/private-content/graphql/resolvers/reset-password.ts +44 -44
- package/server/services/private-content/graphql/types/index.ts +96 -96
- package/server/services/private-content/index.ts +95 -95
- package/server/services/private-content/mail-template/txtMail.email.template.text.ts +6 -6
- package/server/services/private-content/page.ts +20 -20
- package/server/services/private-content/platform.ts +19 -19
- package/server/services/private-content/schemas/index.ts +28 -28
- package/server/services/private-content/user.ts +197 -197
- package/server/services/sitemap.ts +83 -83
- package/server/services/template.ts +13 -13
- package/server/services/user-category.ts +3 -3
- package/server/utils/filter-underscore-arguments.ts +12 -12
- package/server/utils/reload-strapi-on-load.ts +13 -13
- package/server/utils/strapi.ts +50 -50
- package/shared/utils/constants.ts +8 -8
- package/shared/utils/sleep.ts +1 -1
- package/strapi-admin.js +3 -3
- package/strapi-server.js +3 -3
- package/tsconfig.json +20 -20
- package/tsconfig.server.json +25 -25
|
@@ -1,30 +1,30 @@
|
|
|
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
|
-
noLabel?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const PlatformSelect = ({ onChange, platforms, selectedPlatform, noLabel }: Props) => {
|
|
16
|
-
return (
|
|
17
|
-
<SingleSelect
|
|
18
|
-
label={!noLabel && 'Platform'}
|
|
19
|
-
placeholder="Kies een platform"
|
|
20
|
-
value={selectedPlatform?.id || PLATFORM}
|
|
21
|
-
onChange={onChange}
|
|
22
|
-
>
|
|
23
|
-
{platforms?.map((pageType: Platform) => (
|
|
24
|
-
<SingleSelectOption key={pageType?.id} value={pageType?.id}>
|
|
25
|
-
{pageType?.title}
|
|
26
|
-
</SingleSelectOption>
|
|
27
|
-
))}
|
|
28
|
-
</SingleSelect>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
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
|
+
noLabel?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const PlatformSelect = ({ onChange, platforms, selectedPlatform, noLabel }: Props) => {
|
|
16
|
+
return (
|
|
17
|
+
<SingleSelect
|
|
18
|
+
label={!noLabel && 'Platform'}
|
|
19
|
+
placeholder="Kies een platform"
|
|
20
|
+
value={selectedPlatform?.id || PLATFORM}
|
|
21
|
+
onChange={onChange}
|
|
22
|
+
>
|
|
23
|
+
{platforms?.map((pageType: Platform) => (
|
|
24
|
+
<SingleSelectOption key={pageType?.id} value={pageType?.id}>
|
|
25
|
+
{pageType?.title}
|
|
26
|
+
</SingleSelectOption>
|
|
27
|
+
))}
|
|
28
|
+
</SingleSelect>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useIntl } from 'react-intl';
|
|
3
|
-
|
|
4
|
-
import { Icon, Flex } from '@strapi/design-system';
|
|
5
|
-
import { Rotate } from '@strapi/icons';
|
|
6
|
-
|
|
7
|
-
import getTrad from '../../../../utils/getTrad';
|
|
8
|
-
import ConfirmModal, { IConfirmModalProps } from '../../../ConfirmModal';
|
|
9
|
-
|
|
10
|
-
interface ITemplateConfirmModalProps extends IConfirmModalProps {}
|
|
11
|
-
|
|
12
|
-
const TemplateConfirmModal = (props: ITemplateConfirmModalProps): JSX.Element => {
|
|
13
|
-
const { formatMessage } = useIntl();
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<ConfirmModal
|
|
17
|
-
{...props}
|
|
18
|
-
title={
|
|
19
|
-
<Flex gap={4}>
|
|
20
|
-
<Icon as={Rotate} color="neutral900" width={4} height={4} />
|
|
21
|
-
{formatMessage({
|
|
22
|
-
id: getTrad('template.confirmModal.title')
|
|
23
|
-
})}
|
|
24
|
-
</Flex>
|
|
25
|
-
}
|
|
26
|
-
body={formatMessage({
|
|
27
|
-
id: getTrad('template.confirmModal.body')
|
|
28
|
-
})}
|
|
29
|
-
submitText={formatMessage({
|
|
30
|
-
id: getTrad('template.confirmModal.buttons.submit')
|
|
31
|
-
})}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default TemplateConfirmModal;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
|
|
4
|
+
import { Icon, Flex } from '@strapi/design-system';
|
|
5
|
+
import { Rotate } from '@strapi/icons';
|
|
6
|
+
|
|
7
|
+
import getTrad from '../../../../utils/getTrad';
|
|
8
|
+
import ConfirmModal, { IConfirmModalProps } from '../../../ConfirmModal';
|
|
9
|
+
|
|
10
|
+
interface ITemplateConfirmModalProps extends IConfirmModalProps {}
|
|
11
|
+
|
|
12
|
+
const TemplateConfirmModal = (props: ITemplateConfirmModalProps): JSX.Element => {
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<ConfirmModal
|
|
17
|
+
{...props}
|
|
18
|
+
title={
|
|
19
|
+
<Flex gap={4}>
|
|
20
|
+
<Icon as={Rotate} color="neutral900" width={4} height={4} />
|
|
21
|
+
{formatMessage({
|
|
22
|
+
id: getTrad('template.confirmModal.title')
|
|
23
|
+
})}
|
|
24
|
+
</Flex>
|
|
25
|
+
}
|
|
26
|
+
body={formatMessage({
|
|
27
|
+
id: getTrad('template.confirmModal.body')
|
|
28
|
+
})}
|
|
29
|
+
submitText={formatMessage({
|
|
30
|
+
id: getTrad('template.confirmModal.buttons.submit')
|
|
31
|
+
})}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default TemplateConfirmModal;
|
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { SingleSelect, SingleSelectOption } from '@strapi/design-system';
|
|
3
|
-
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
|
-
import { Template } from '../../../../api/template';
|
|
5
|
-
import TemplateConfirmModal from '../TemplateConfirmModal';
|
|
6
|
-
import { useTemplateModules } from './use-template-modules';
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const TemplateSelect = ({ disabled }: Props) => {
|
|
13
|
-
const { onChange, modifiedData } = useCMEditViewDataManager() as any;
|
|
14
|
-
const [selectedTemplate, setSelectedTemplate] = useState<Template | null>(null);
|
|
15
|
-
const { templates, replaceContentTypeModules } = useTemplateModules(onChange);
|
|
16
|
-
const [templateIdToSelect, setTemplateIdToSelect] = useState<string | undefined>();
|
|
17
|
-
|
|
18
|
-
const handleSelectChange = (templateId?: string) => {
|
|
19
|
-
setTemplateIdToSelect(templateId);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const handleSelectTemplate = (templateId?: string) => {
|
|
23
|
-
const template = templates?.find((template) => template.id === Number(templateId));
|
|
24
|
-
|
|
25
|
-
setSelectedTemplate(template || null);
|
|
26
|
-
|
|
27
|
-
setTemplateIdToSelect(undefined);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
useEffect(() => {
|
|
31
|
-
const noModules = getHasModules(modifiedData?.modules);
|
|
32
|
-
|
|
33
|
-
const template = templates?.find((template) => template.id === Number(modifiedData?.pageType?.[0]?.templateId));
|
|
34
|
-
if (template && noModules) {
|
|
35
|
-
setSelectedTemplate(template);
|
|
36
|
-
}
|
|
37
|
-
}, [modifiedData?.pageType]);
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (selectedTemplate !== null) {
|
|
41
|
-
replaceContentTypeModules(selectedTemplate.id);
|
|
42
|
-
}
|
|
43
|
-
}, [selectedTemplate]);
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<>
|
|
47
|
-
<SingleSelect
|
|
48
|
-
label="Template"
|
|
49
|
-
placeholder="Kies een template"
|
|
50
|
-
value={selectedTemplate?.id || 0}
|
|
51
|
-
onChange={handleSelectChange}
|
|
52
|
-
disabled={Boolean(disabled)}
|
|
53
|
-
>
|
|
54
|
-
<SingleSelectOption value={0}>Kies een template om in te laden</SingleSelectOption>
|
|
55
|
-
{templates?.map((template) => (
|
|
56
|
-
<SingleSelectOption key={template.id} value={template.id}>
|
|
57
|
-
{template.title}
|
|
58
|
-
</SingleSelectOption>
|
|
59
|
-
))}
|
|
60
|
-
</SingleSelect>
|
|
61
|
-
<TemplateConfirmModal
|
|
62
|
-
isOpen={Boolean(templateIdToSelect)}
|
|
63
|
-
onSubmit={() => handleSelectTemplate(templateIdToSelect)}
|
|
64
|
-
closeModal={() => setTemplateIdToSelect(undefined)}
|
|
65
|
-
/>
|
|
66
|
-
</>
|
|
67
|
-
);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const getHasModules = (modules: any[]): boolean => (modules?.length || 0) === 0;
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { SingleSelect, SingleSelectOption } from '@strapi/design-system';
|
|
3
|
+
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
|
+
import { Template } from '../../../../api/template';
|
|
5
|
+
import TemplateConfirmModal from '../TemplateConfirmModal';
|
|
6
|
+
import { useTemplateModules } from './use-template-modules';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const TemplateSelect = ({ disabled }: Props) => {
|
|
13
|
+
const { onChange, modifiedData } = useCMEditViewDataManager() as any;
|
|
14
|
+
const [selectedTemplate, setSelectedTemplate] = useState<Template | null>(null);
|
|
15
|
+
const { templates, replaceContentTypeModules } = useTemplateModules(onChange);
|
|
16
|
+
const [templateIdToSelect, setTemplateIdToSelect] = useState<string | undefined>();
|
|
17
|
+
|
|
18
|
+
const handleSelectChange = (templateId?: string) => {
|
|
19
|
+
setTemplateIdToSelect(templateId);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const handleSelectTemplate = (templateId?: string) => {
|
|
23
|
+
const template = templates?.find((template) => template.id === Number(templateId));
|
|
24
|
+
|
|
25
|
+
setSelectedTemplate(template || null);
|
|
26
|
+
|
|
27
|
+
setTemplateIdToSelect(undefined);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const noModules = getHasModules(modifiedData?.modules);
|
|
32
|
+
|
|
33
|
+
const template = templates?.find((template) => template.id === Number(modifiedData?.pageType?.[0]?.templateId));
|
|
34
|
+
if (template && noModules) {
|
|
35
|
+
setSelectedTemplate(template);
|
|
36
|
+
}
|
|
37
|
+
}, [modifiedData?.pageType]);
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (selectedTemplate !== null) {
|
|
41
|
+
replaceContentTypeModules(selectedTemplate.id);
|
|
42
|
+
}
|
|
43
|
+
}, [selectedTemplate]);
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<>
|
|
47
|
+
<SingleSelect
|
|
48
|
+
label="Template"
|
|
49
|
+
placeholder="Kies een template"
|
|
50
|
+
value={selectedTemplate?.id || 0}
|
|
51
|
+
onChange={handleSelectChange}
|
|
52
|
+
disabled={Boolean(disabled)}
|
|
53
|
+
>
|
|
54
|
+
<SingleSelectOption value={0}>Kies een template om in te laden</SingleSelectOption>
|
|
55
|
+
{templates?.map((template) => (
|
|
56
|
+
<SingleSelectOption key={template.id} value={template.id}>
|
|
57
|
+
{template.title}
|
|
58
|
+
</SingleSelectOption>
|
|
59
|
+
))}
|
|
60
|
+
</SingleSelect>
|
|
61
|
+
<TemplateConfirmModal
|
|
62
|
+
isOpen={Boolean(templateIdToSelect)}
|
|
63
|
+
onSubmit={() => handleSelectTemplate(templateIdToSelect)}
|
|
64
|
+
closeModal={() => setTemplateIdToSelect(undefined)}
|
|
65
|
+
/>
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const getHasModules = (modules: any[]): boolean => (modules?.length || 0) === 0;
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { useFetchClient } from '@strapi/helper-plugin';
|
|
2
|
-
|
|
3
|
-
import { Template, useGetTemplates } from '../../../../api/template';
|
|
4
|
-
import { sanitizeModules } from '../../../../utils/sanitizeModules';
|
|
5
|
-
import getRequestUrl from '../../../../utils/getRequestUrl';
|
|
6
|
-
import { useDefaultPlatformFromLocalStorage } from '../../../../utils/hooks/useDefaultPlatformFromLocalStorage';
|
|
7
|
-
|
|
8
|
-
type OnChangeFormType = (props: { target: Record<string, any>; shouldSetInitialValue: boolean }) => void;
|
|
9
|
-
|
|
10
|
-
export const useTemplateModules = (onChange: OnChangeFormType) => {
|
|
11
|
-
const { selectedPlatform } = useDefaultPlatformFromLocalStorage();
|
|
12
|
-
const { data: templates } = useGetTemplates({ platformId: selectedPlatform?.id });
|
|
13
|
-
const fetchClient = useFetchClient();
|
|
14
|
-
|
|
15
|
-
return {
|
|
16
|
-
findTemplate,
|
|
17
|
-
templates,
|
|
18
|
-
replaceContentTypeModules: (id: number) => replaceContentTypeModules(id, fetchClient, onChange)
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const findTemplate = (templates?: Template[], selectedTemplateId?: string | number) =>
|
|
23
|
-
templates?.find((template) => template.id === Number(selectedTemplateId));
|
|
24
|
-
|
|
25
|
-
const sanatizeContentTypeModules = (onChange: OnChangeFormType, modules: Record<string, any>[]) => {
|
|
26
|
-
const sanitizedModules = sanitizeModules(modules);
|
|
27
|
-
|
|
28
|
-
return onChange({
|
|
29
|
-
target: {
|
|
30
|
-
name: 'modules',
|
|
31
|
-
value: sanitizedModules
|
|
32
|
-
},
|
|
33
|
-
shouldSetInitialValue: true
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const replaceContentTypeModules = async (id: number, fetchClient: any, onChange: OnChangeFormType) => {
|
|
38
|
-
const { get } = fetchClient;
|
|
39
|
-
const result = await get(getRequestUrl(`/template/${id}`));
|
|
40
|
-
return sanatizeContentTypeModules(onChange, result.data.modules);
|
|
41
|
-
};
|
|
1
|
+
import { useFetchClient } from '@strapi/helper-plugin';
|
|
2
|
+
|
|
3
|
+
import { Template, useGetTemplates } from '../../../../api/template';
|
|
4
|
+
import { sanitizeModules } from '../../../../utils/sanitizeModules';
|
|
5
|
+
import getRequestUrl from '../../../../utils/getRequestUrl';
|
|
6
|
+
import { useDefaultPlatformFromLocalStorage } from '../../../../utils/hooks/useDefaultPlatformFromLocalStorage';
|
|
7
|
+
|
|
8
|
+
type OnChangeFormType = (props: { target: Record<string, any>; shouldSetInitialValue: boolean }) => void;
|
|
9
|
+
|
|
10
|
+
export const useTemplateModules = (onChange: OnChangeFormType) => {
|
|
11
|
+
const { selectedPlatform } = useDefaultPlatformFromLocalStorage();
|
|
12
|
+
const { data: templates } = useGetTemplates({ platformId: selectedPlatform?.id });
|
|
13
|
+
const fetchClient = useFetchClient();
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
findTemplate,
|
|
17
|
+
templates,
|
|
18
|
+
replaceContentTypeModules: (id: number) => replaceContentTypeModules(id, fetchClient, onChange)
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const findTemplate = (templates?: Template[], selectedTemplateId?: string | number) =>
|
|
23
|
+
templates?.find((template) => template.id === Number(selectedTemplateId));
|
|
24
|
+
|
|
25
|
+
const sanatizeContentTypeModules = (onChange: OnChangeFormType, modules: Record<string, any>[]) => {
|
|
26
|
+
const sanitizedModules = sanitizeModules(modules);
|
|
27
|
+
|
|
28
|
+
return onChange({
|
|
29
|
+
target: {
|
|
30
|
+
name: 'modules',
|
|
31
|
+
value: sanitizedModules
|
|
32
|
+
},
|
|
33
|
+
shouldSetInitialValue: true
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const replaceContentTypeModules = async (id: number, fetchClient: any, onChange: OnChangeFormType) => {
|
|
38
|
+
const { get } = fetchClient;
|
|
39
|
+
const result = await get(getRequestUrl(`/template/${id}`));
|
|
40
|
+
return sanatizeContentTypeModules(onChange, result.data.modules);
|
|
41
|
+
};
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
|
-
|
|
5
|
-
import { PAGE_UID } from '../../../../shared/utils/constants';
|
|
6
|
-
import { PageSettings } from './PageSettings';
|
|
7
|
-
import { CollectionTypeSettings } from './CollectionTypeSettings';
|
|
8
|
-
import { useHasPageRelation } from '../../api/has-page-relation';
|
|
9
|
-
import { useHasPlatformRelation } from '../../api/has-platform-relation';
|
|
10
|
-
|
|
11
|
-
export const EditView = () => {
|
|
12
|
-
const { layout } = useCMEditViewDataManager() as any;
|
|
13
|
-
|
|
14
|
-
const isPageCollectionType = layout.uid === PAGE_UID;
|
|
15
|
-
const isCollectionType = layout.kind === 'collectionType';
|
|
16
|
-
|
|
17
|
-
const { data: hasPageRelation, isLoading } = useHasPageRelation({
|
|
18
|
-
uid: layout.uid
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const { data: hasPlatformRelation, isLoading: isLoadingPlatformRelation } = useHasPlatformRelation({
|
|
22
|
-
uid: layout.uid
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
if (isPageCollectionType) {
|
|
26
|
-
return <PageSettings />;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Show collectiontype settings if it's not a page and it has a page relation OR a platform relation
|
|
30
|
-
if (isCollectionType && !isLoading && !isLoadingPlatformRelation && (hasPageRelation || hasPlatformRelation)) {
|
|
31
|
-
return <CollectionTypeSettings onlyPlatform={!hasPageRelation && hasPlatformRelation} />;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return null;
|
|
35
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
|
+
|
|
5
|
+
import { PAGE_UID } from '../../../../shared/utils/constants';
|
|
6
|
+
import { PageSettings } from './PageSettings';
|
|
7
|
+
import { CollectionTypeSettings } from './CollectionTypeSettings';
|
|
8
|
+
import { useHasPageRelation } from '../../api/has-page-relation';
|
|
9
|
+
import { useHasPlatformRelation } from '../../api/has-platform-relation';
|
|
10
|
+
|
|
11
|
+
export const EditView = () => {
|
|
12
|
+
const { layout } = useCMEditViewDataManager() as any;
|
|
13
|
+
|
|
14
|
+
const isPageCollectionType = layout.uid === PAGE_UID;
|
|
15
|
+
const isCollectionType = layout.kind === 'collectionType';
|
|
16
|
+
|
|
17
|
+
const { data: hasPageRelation, isLoading } = useHasPageRelation({
|
|
18
|
+
uid: layout.uid
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const { data: hasPlatformRelation, isLoading: isLoadingPlatformRelation } = useHasPlatformRelation({
|
|
22
|
+
uid: layout.uid
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (isPageCollectionType) {
|
|
26
|
+
return <PageSettings />;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Show collectiontype settings if it's not a page and it has a page relation OR a platform relation
|
|
30
|
+
if (isCollectionType && !isLoading && !isLoadingPlatformRelation && (hasPageRelation || hasPlatformRelation)) {
|
|
31
|
+
return <CollectionTypeSettings onlyPlatform={!hasPageRelation && hasPlatformRelation} />;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { SingleSelect, SingleSelectOption } from '@strapi/design-system';
|
|
4
|
-
|
|
5
|
-
import { PageType } from '../../api/platform-page-types';
|
|
6
|
-
import { PAGE_TYPE_PAGE } from '../../../../shared/utils/constants';
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
onChange: (pageTypeId: string) => void;
|
|
10
|
-
selectedPageType?: PageType | null;
|
|
11
|
-
pageTypes?: PageType[];
|
|
12
|
-
disabled?: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const PageTypeSelect = ({ onChange, pageTypes, selectedPageType, disabled }: Props) => {
|
|
16
|
-
return (
|
|
17
|
-
<SingleSelect
|
|
18
|
-
label="Page type"
|
|
19
|
-
placeholder="Choose a page type"
|
|
20
|
-
value={selectedPageType?.id || PAGE_TYPE_PAGE}
|
|
21
|
-
onChange={onChange}
|
|
22
|
-
disabled={Boolean(disabled)}
|
|
23
|
-
>
|
|
24
|
-
<SingleSelectOption value={PAGE_TYPE_PAGE}>Page</SingleSelectOption>
|
|
25
|
-
{pageTypes?.map((pageType: PageType) => (
|
|
26
|
-
<SingleSelectOption key={pageType?.uid} value={pageType?.id}>
|
|
27
|
-
{pageType?.title}
|
|
28
|
-
</SingleSelectOption>
|
|
29
|
-
))}
|
|
30
|
-
</SingleSelect>
|
|
31
|
-
);
|
|
32
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { SingleSelect, SingleSelectOption } from '@strapi/design-system';
|
|
4
|
+
|
|
5
|
+
import { PageType } from '../../api/platform-page-types';
|
|
6
|
+
import { PAGE_TYPE_PAGE } from '../../../../shared/utils/constants';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
onChange: (pageTypeId: string) => void;
|
|
10
|
+
selectedPageType?: PageType | null;
|
|
11
|
+
pageTypes?: PageType[];
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const PageTypeSelect = ({ onChange, pageTypes, selectedPageType, disabled }: Props) => {
|
|
16
|
+
return (
|
|
17
|
+
<SingleSelect
|
|
18
|
+
label="Page type"
|
|
19
|
+
placeholder="Choose a page type"
|
|
20
|
+
value={selectedPageType?.id || PAGE_TYPE_PAGE}
|
|
21
|
+
onChange={onChange}
|
|
22
|
+
disabled={Boolean(disabled)}
|
|
23
|
+
>
|
|
24
|
+
<SingleSelectOption value={PAGE_TYPE_PAGE}>Page</SingleSelectOption>
|
|
25
|
+
{pageTypes?.map((pageType: PageType) => (
|
|
26
|
+
<SingleSelectOption key={pageType?.uid} value={pageType?.id}>
|
|
27
|
+
{pageType?.title}
|
|
28
|
+
</SingleSelectOption>
|
|
29
|
+
))}
|
|
30
|
+
</SingleSelect>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Flex, Box, Divider, Typography } from '@strapi/design-system';
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
title?: string;
|
|
6
|
-
children: React.ReactNode;
|
|
7
|
-
flexProps?: Record<string, any>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const Wrapper = (props: Props) => {
|
|
11
|
-
return (
|
|
12
|
-
<Flex
|
|
13
|
-
as="aside"
|
|
14
|
-
direction="column"
|
|
15
|
-
background="neutral0"
|
|
16
|
-
borderColor="neutral150"
|
|
17
|
-
hasRadius={true}
|
|
18
|
-
paddingTop={6}
|
|
19
|
-
paddingBottom={4}
|
|
20
|
-
paddingRight={4}
|
|
21
|
-
paddingLeft={4}
|
|
22
|
-
shadow="tableShadow"
|
|
23
|
-
alignItems="left"
|
|
24
|
-
{...props.flexProps}
|
|
25
|
-
>
|
|
26
|
-
{props.title && (
|
|
27
|
-
<>
|
|
28
|
-
<Typography variant="sigma" textColor="neutral600" id="additional-information">
|
|
29
|
-
{props.title}
|
|
30
|
-
</Typography>
|
|
31
|
-
|
|
32
|
-
<Box paddingTop={2} paddingBottom={4}>
|
|
33
|
-
<Divider />
|
|
34
|
-
</Box>
|
|
35
|
-
</>
|
|
36
|
-
)}
|
|
37
|
-
|
|
38
|
-
{props.children}
|
|
39
|
-
</Flex>
|
|
40
|
-
);
|
|
41
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Flex, Box, Divider, Typography } from '@strapi/design-system';
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
title?: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
flexProps?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const Wrapper = (props: Props) => {
|
|
11
|
+
return (
|
|
12
|
+
<Flex
|
|
13
|
+
as="aside"
|
|
14
|
+
direction="column"
|
|
15
|
+
background="neutral0"
|
|
16
|
+
borderColor="neutral150"
|
|
17
|
+
hasRadius={true}
|
|
18
|
+
paddingTop={6}
|
|
19
|
+
paddingBottom={4}
|
|
20
|
+
paddingRight={4}
|
|
21
|
+
paddingLeft={4}
|
|
22
|
+
shadow="tableShadow"
|
|
23
|
+
alignItems="left"
|
|
24
|
+
{...props.flexProps}
|
|
25
|
+
>
|
|
26
|
+
{props.title && (
|
|
27
|
+
<>
|
|
28
|
+
<Typography variant="sigma" textColor="neutral600" id="additional-information">
|
|
29
|
+
{props.title}
|
|
30
|
+
</Typography>
|
|
31
|
+
|
|
32
|
+
<Box paddingTop={2} paddingBottom={4}>
|
|
33
|
+
<Divider />
|
|
34
|
+
</Box>
|
|
35
|
+
</>
|
|
36
|
+
)}
|
|
37
|
+
|
|
38
|
+
{props.children}
|
|
39
|
+
</Flex>
|
|
40
|
+
);
|
|
41
|
+
};
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useHistory, useLocation } from 'react-router-dom';
|
|
3
|
-
|
|
4
|
-
import PlatformFilter from '../PageFilters/PlatformFilter';
|
|
5
|
-
import { Platform, useGetPlatforms } from '../../api/platform';
|
|
6
|
-
import { useDefaultPlatformFromLocalStorage } from '../../utils/hooks/useDefaultPlatformFromLocalStorage';
|
|
7
|
-
|
|
8
|
-
import S from './styles';
|
|
9
|
-
|
|
10
|
-
export interface IGlobalPlatformSelectProps {
|
|
11
|
-
small?: boolean;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const GlobalPlatformSelect = ({ small }: IGlobalPlatformSelectProps) => {
|
|
15
|
-
const { pathname } = useLocation();
|
|
16
|
-
const { push } = useHistory();
|
|
17
|
-
|
|
18
|
-
const { data: platforms, isLoading } = useGetPlatforms({});
|
|
19
|
-
const { selectedPlatform, setSelectedPlatform } = useDefaultPlatformFromLocalStorage();
|
|
20
|
-
|
|
21
|
-
const handlePlatformChange = (platform: Platform) => {
|
|
22
|
-
setSelectedPlatform(platform);
|
|
23
|
-
|
|
24
|
-
if (typeof window !== 'undefined' && pathname.split('/').filter(Boolean).length > 3) {
|
|
25
|
-
push('/');
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
if (isLoading || (platforms || [])?.length < 2) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<S.Wrapper small={small}>
|
|
35
|
-
<PlatformFilter platforms={platforms} onChange={handlePlatformChange} selectedPlatform={selectedPlatform} />
|
|
36
|
-
</S.Wrapper>
|
|
37
|
-
);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { GlobalPlatformSelect };
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useHistory, useLocation } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import PlatformFilter from '../PageFilters/PlatformFilter';
|
|
5
|
+
import { Platform, useGetPlatforms } from '../../api/platform';
|
|
6
|
+
import { useDefaultPlatformFromLocalStorage } from '../../utils/hooks/useDefaultPlatformFromLocalStorage';
|
|
7
|
+
|
|
8
|
+
import S from './styles';
|
|
9
|
+
|
|
10
|
+
export interface IGlobalPlatformSelectProps {
|
|
11
|
+
small?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const GlobalPlatformSelect = ({ small }: IGlobalPlatformSelectProps) => {
|
|
15
|
+
const { pathname } = useLocation();
|
|
16
|
+
const { push } = useHistory();
|
|
17
|
+
|
|
18
|
+
const { data: platforms, isLoading } = useGetPlatforms({});
|
|
19
|
+
const { selectedPlatform, setSelectedPlatform } = useDefaultPlatformFromLocalStorage();
|
|
20
|
+
|
|
21
|
+
const handlePlatformChange = (platform: Platform) => {
|
|
22
|
+
setSelectedPlatform(platform);
|
|
23
|
+
|
|
24
|
+
if (typeof window !== 'undefined' && pathname.split('/').filter(Boolean).length > 3) {
|
|
25
|
+
push('/');
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
if (isLoading || (platforms || [])?.length < 2) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<S.Wrapper small={small}>
|
|
35
|
+
<PlatformFilter platforms={platforms} onChange={handlePlatformChange} selectedPlatform={selectedPlatform} />
|
|
36
|
+
</S.Wrapper>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { GlobalPlatformSelect };
|