@webbio/strapi-plugin-page-builder 0.12.2-platform → 0.12.3-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.js +1 -1
- package/dist/server/graphql/page-by-path.js +20 -17
- 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/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
- package/dist/server/graphql/page-by-slug.js +0 -89
- package/dist/server/utils/graphql.js +0 -100
- package/dist/server/utils/paginationValidation.js +0 -31
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
import remove from 'lodash/remove';
|
|
3
|
-
|
|
4
|
-
import { useLocalStorage, useSessionStorage } from '@mantine/hooks';
|
|
5
|
-
|
|
6
|
-
import { Platform, useGetPlatforms } from '../../api/platform';
|
|
7
|
-
|
|
8
|
-
const useDefaultPlatformFromLocalStorage = () => {
|
|
9
|
-
const { data: platforms, isLoading } = useGetPlatforms({});
|
|
10
|
-
// Set multiple platforms in local storage. When a new tab is opened, the first platform from the array will be selected.
|
|
11
|
-
const [platformsFromState, setPlatformsFromState] = useLocalStorage<Platform[] | undefined>({
|
|
12
|
-
key: 'selectedPlatforms',
|
|
13
|
-
defaultValue: undefined,
|
|
14
|
-
getInitialValueInEffect: false
|
|
15
|
-
});
|
|
16
|
-
const selectedPlatformFromState = platformsFromState?.[0];
|
|
17
|
-
|
|
18
|
-
// Session storage is used to keep the state of the current tab.
|
|
19
|
-
const [selectedPlatform, setSelectedPlatform] = useSessionStorage<Platform | undefined>({
|
|
20
|
-
key: 'selectedPlatform',
|
|
21
|
-
defaultValue: undefined,
|
|
22
|
-
getInitialValueInEffect: false
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// When a new platform is selected, it is added as first element to the array of platforms in local storage.
|
|
26
|
-
// This makes sure that when a new tab is opened, the most recent platform will be selected.
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
const platformArray: Platform[] = platformsFromState || [];
|
|
29
|
-
remove(platformArray, (p) => p.id === selectedPlatform?.id);
|
|
30
|
-
|
|
31
|
-
if (selectedPlatform) {
|
|
32
|
-
platformArray.unshift(selectedPlatform);
|
|
33
|
-
}
|
|
34
|
-
setPlatformsFromState(platformArray);
|
|
35
|
-
}, [selectedPlatform]);
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
// If there are no platforms in local storage, select the first platform from the list.
|
|
39
|
-
if (
|
|
40
|
-
!isLoading &&
|
|
41
|
-
platforms?.[0]?.title &&
|
|
42
|
-
(!selectedPlatform?.id || !platforms.find((platform) => platform.id === selectedPlatformFromState?.id))
|
|
43
|
-
) {
|
|
44
|
-
setSelectedPlatform(platforms[0]);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// If there are no platforms in local storage and no platforms are returned from the API, set the selected platform to undefined.
|
|
48
|
-
if (!isLoading && (platforms || []).length === 0) {
|
|
49
|
-
setSelectedPlatform(undefined);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
// If there is no selected platform in the session storage, set it to the selected platform from local storage.
|
|
53
|
-
if (!isLoading && selectedPlatformFromState?.id && !selectedPlatform) {
|
|
54
|
-
setSelectedPlatform(selectedPlatformFromState);
|
|
55
|
-
}
|
|
56
|
-
}, [isLoading, selectedPlatformFromState, platforms]);
|
|
57
|
-
|
|
58
|
-
return { selectedPlatform, setSelectedPlatform, platforms };
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export { useDefaultPlatformFromLocalStorage };
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import remove from 'lodash/remove';
|
|
3
|
+
|
|
4
|
+
import { useLocalStorage, useSessionStorage } from '@mantine/hooks';
|
|
5
|
+
|
|
6
|
+
import { Platform, useGetPlatforms } from '../../api/platform';
|
|
7
|
+
|
|
8
|
+
const useDefaultPlatformFromLocalStorage = () => {
|
|
9
|
+
const { data: platforms, isLoading } = useGetPlatforms({});
|
|
10
|
+
// Set multiple platforms in local storage. When a new tab is opened, the first platform from the array will be selected.
|
|
11
|
+
const [platformsFromState, setPlatformsFromState] = useLocalStorage<Platform[] | undefined>({
|
|
12
|
+
key: 'selectedPlatforms',
|
|
13
|
+
defaultValue: undefined,
|
|
14
|
+
getInitialValueInEffect: false
|
|
15
|
+
});
|
|
16
|
+
const selectedPlatformFromState = platformsFromState?.[0];
|
|
17
|
+
|
|
18
|
+
// Session storage is used to keep the state of the current tab.
|
|
19
|
+
const [selectedPlatform, setSelectedPlatform] = useSessionStorage<Platform | undefined>({
|
|
20
|
+
key: 'selectedPlatform',
|
|
21
|
+
defaultValue: undefined,
|
|
22
|
+
getInitialValueInEffect: false
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// When a new platform is selected, it is added as first element to the array of platforms in local storage.
|
|
26
|
+
// This makes sure that when a new tab is opened, the most recent platform will be selected.
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
const platformArray: Platform[] = platformsFromState || [];
|
|
29
|
+
remove(platformArray, (p) => p.id === selectedPlatform?.id);
|
|
30
|
+
|
|
31
|
+
if (selectedPlatform) {
|
|
32
|
+
platformArray.unshift(selectedPlatform);
|
|
33
|
+
}
|
|
34
|
+
setPlatformsFromState(platformArray);
|
|
35
|
+
}, [selectedPlatform]);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
// If there are no platforms in local storage, select the first platform from the list.
|
|
39
|
+
if (
|
|
40
|
+
!isLoading &&
|
|
41
|
+
platforms?.[0]?.title &&
|
|
42
|
+
(!selectedPlatform?.id || !platforms.find((platform) => platform.id === selectedPlatformFromState?.id))
|
|
43
|
+
) {
|
|
44
|
+
setSelectedPlatform(platforms[0]);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// If there are no platforms in local storage and no platforms are returned from the API, set the selected platform to undefined.
|
|
48
|
+
if (!isLoading && (platforms || []).length === 0) {
|
|
49
|
+
setSelectedPlatform(undefined);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// If there is no selected platform in the session storage, set it to the selected platform from local storage.
|
|
53
|
+
if (!isLoading && selectedPlatformFromState?.id && !selectedPlatform) {
|
|
54
|
+
setSelectedPlatform(selectedPlatformFromState);
|
|
55
|
+
}
|
|
56
|
+
}, [isLoading, selectedPlatformFromState, platforms]);
|
|
57
|
+
|
|
58
|
+
return { selectedPlatform, setSelectedPlatform, platforms };
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export { useDefaultPlatformFromLocalStorage };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useQueryParams } from '@strapi/helper-plugin';
|
|
2
|
-
|
|
3
|
-
const useGetLocaleFromUrl = () => {
|
|
4
|
-
const [{ query }] = useQueryParams() as any;
|
|
5
|
-
|
|
6
|
-
return query?.plugins?.i18n?.locale;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export { useGetLocaleFromUrl };
|
|
1
|
+
import { useQueryParams } from '@strapi/helper-plugin';
|
|
2
|
+
|
|
3
|
+
const useGetLocaleFromUrl = () => {
|
|
4
|
+
const [{ query }] = useQueryParams() as any;
|
|
5
|
+
|
|
6
|
+
return query?.plugins?.i18n?.locale;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { useGetLocaleFromUrl };
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { useLayoutEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useQueryParams } from '@strapi/helper-plugin';
|
|
4
|
-
|
|
5
|
-
import { findElementParent } from '../../utils/findElementParent';
|
|
6
|
-
import { findDomElement } from '../../utils/findDomElement';
|
|
7
|
-
import { useGetPlatforms } from '../../api/platform';
|
|
8
|
-
|
|
9
|
-
const filtersToRemove = ['platform', 'pageType'];
|
|
10
|
-
|
|
11
|
-
export const useHideOverviewFilterTags = () => {
|
|
12
|
-
const [{ query }] = useQueryParams() as any;
|
|
13
|
-
const { data: platforms } = useGetPlatforms({});
|
|
14
|
-
|
|
15
|
-
useLayoutEffect(() => {
|
|
16
|
-
filtersToRemove.forEach((filter) => removeFilterElement(filter, query));
|
|
17
|
-
}, [query, platforms]);
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const removeFilterElement = (filterToRemove?: string, query?: Record<string, any>): void => {
|
|
21
|
-
if (!filterToRemove || !query || !(JSON.stringify(query.filters || {}) || '').includes(filterToRemove)) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const filterTag = findDomElement(`//button//span[contains(., '${filterToRemove} is')]`);
|
|
26
|
-
|
|
27
|
-
if (filterTag) {
|
|
28
|
-
const parent = findElementParent(filterTag, 'DIV', 2);
|
|
29
|
-
|
|
30
|
-
if (parent?.remove) {
|
|
31
|
-
parent.style.display = 'none';
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
};
|
|
1
|
+
import { useLayoutEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useQueryParams } from '@strapi/helper-plugin';
|
|
4
|
+
|
|
5
|
+
import { findElementParent } from '../../utils/findElementParent';
|
|
6
|
+
import { findDomElement } from '../../utils/findDomElement';
|
|
7
|
+
import { useGetPlatforms } from '../../api/platform';
|
|
8
|
+
|
|
9
|
+
const filtersToRemove = ['platform', 'pageType'];
|
|
10
|
+
|
|
11
|
+
export const useHideOverviewFilterTags = () => {
|
|
12
|
+
const [{ query }] = useQueryParams() as any;
|
|
13
|
+
const { data: platforms } = useGetPlatforms({});
|
|
14
|
+
|
|
15
|
+
useLayoutEffect(() => {
|
|
16
|
+
filtersToRemove.forEach((filter) => removeFilterElement(filter, query));
|
|
17
|
+
}, [query, platforms]);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const removeFilterElement = (filterToRemove?: string, query?: Record<string, any>): void => {
|
|
21
|
+
if (!filterToRemove || !query || !(JSON.stringify(query.filters || {}) || '').includes(filterToRemove)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const filterTag = findDomElement(`//button//span[contains(., '${filterToRemove} is')]`);
|
|
26
|
+
|
|
27
|
+
if (filterTag) {
|
|
28
|
+
const parent = findElementParent(filterTag, 'DIV', 2);
|
|
29
|
+
|
|
30
|
+
if (parent?.remove) {
|
|
31
|
+
parent.style.display = 'none';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import { useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
import { Platform } from '../../api/platform';
|
|
4
|
-
import { useDefaultPlatformFromLocalStorage } from './useDefaultPlatformFromLocalStorage';
|
|
5
|
-
import { useGetPlatformRelation } from '../../api/platform-relation';
|
|
6
|
-
import { PLATFORM_UID } from '../../../../shared/utils/constants';
|
|
7
|
-
|
|
8
|
-
const usePlatformFormData = (form?: Record<string, any>, onPlatformChange?: (platform: Platform) => void) => {
|
|
9
|
-
const { onChange, initialData, modifiedData, layout } = form || {};
|
|
10
|
-
const { isLoading: isLoadingPlatform, data: platformRelation } = useGetPlatformRelation({
|
|
11
|
-
id: initialData?.id,
|
|
12
|
-
uid: layout.uid
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const { selectedPlatform: defaultPlatform, setSelectedPlatform: setDefaultPlatform } =
|
|
16
|
-
useDefaultPlatformFromLocalStorage();
|
|
17
|
-
const isPlatformPage = layout.uid === PLATFORM_UID;
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (!isLoadingPlatform && !platformRelation?.id && defaultPlatform && !isPlatformPage) {
|
|
21
|
-
handleSelectPlatform(defaultPlatform);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// If a user lands on a page which has a different platform linked than the one that is globally selected,
|
|
25
|
-
// we want to update the global selection to match the page's platform (if the user has access to it).
|
|
26
|
-
if (platformRelation?.id && defaultPlatform?.id && platformRelation.id !== defaultPlatform.id) {
|
|
27
|
-
setDefaultPlatform(platformRelation);
|
|
28
|
-
}
|
|
29
|
-
}, [isLoadingPlatform, defaultPlatform]);
|
|
30
|
-
|
|
31
|
-
const setFormValue = (name: string, value?: string | Record<string, any>[]) => {
|
|
32
|
-
onChange({
|
|
33
|
-
target: {
|
|
34
|
-
name,
|
|
35
|
-
value
|
|
36
|
-
},
|
|
37
|
-
shouldSetInitialValue: true
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const handleSelectPlatform = async (platform: Platform) => {
|
|
42
|
-
onPlatformChange?.(platform);
|
|
43
|
-
if (platform?.title) {
|
|
44
|
-
const formPlatform = {
|
|
45
|
-
...platform,
|
|
46
|
-
label: platform.title,
|
|
47
|
-
value: platform.id
|
|
48
|
-
};
|
|
49
|
-
setFormValue('platform', [formPlatform]);
|
|
50
|
-
} else {
|
|
51
|
-
setFormValue('platform', []);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
defaultPlatform,
|
|
57
|
-
selectedPlatform:
|
|
58
|
-
(isPlatformPage && initialData) ||
|
|
59
|
-
(modifiedData?.platform?.[0]?.id ? modifiedData?.platform?.[0] : platformRelation),
|
|
60
|
-
isLoadingPlatform
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export { usePlatformFormData };
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Platform } from '../../api/platform';
|
|
4
|
+
import { useDefaultPlatformFromLocalStorage } from './useDefaultPlatformFromLocalStorage';
|
|
5
|
+
import { useGetPlatformRelation } from '../../api/platform-relation';
|
|
6
|
+
import { PLATFORM_UID } from '../../../../shared/utils/constants';
|
|
7
|
+
|
|
8
|
+
const usePlatformFormData = (form?: Record<string, any>, onPlatformChange?: (platform: Platform) => void) => {
|
|
9
|
+
const { onChange, initialData, modifiedData, layout } = form || {};
|
|
10
|
+
const { isLoading: isLoadingPlatform, data: platformRelation } = useGetPlatformRelation({
|
|
11
|
+
id: initialData?.id,
|
|
12
|
+
uid: layout.uid
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const { selectedPlatform: defaultPlatform, setSelectedPlatform: setDefaultPlatform } =
|
|
16
|
+
useDefaultPlatformFromLocalStorage();
|
|
17
|
+
const isPlatformPage = layout.uid === PLATFORM_UID;
|
|
18
|
+
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (!isLoadingPlatform && !platformRelation?.id && defaultPlatform && !isPlatformPage) {
|
|
21
|
+
handleSelectPlatform(defaultPlatform);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// If a user lands on a page which has a different platform linked than the one that is globally selected,
|
|
25
|
+
// we want to update the global selection to match the page's platform (if the user has access to it).
|
|
26
|
+
if (platformRelation?.id && defaultPlatform?.id && platformRelation.id !== defaultPlatform.id) {
|
|
27
|
+
setDefaultPlatform(platformRelation);
|
|
28
|
+
}
|
|
29
|
+
}, [isLoadingPlatform, defaultPlatform]);
|
|
30
|
+
|
|
31
|
+
const setFormValue = (name: string, value?: string | Record<string, any>[]) => {
|
|
32
|
+
onChange({
|
|
33
|
+
target: {
|
|
34
|
+
name,
|
|
35
|
+
value
|
|
36
|
+
},
|
|
37
|
+
shouldSetInitialValue: true
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const handleSelectPlatform = async (platform: Platform) => {
|
|
42
|
+
onPlatformChange?.(platform);
|
|
43
|
+
if (platform?.title) {
|
|
44
|
+
const formPlatform = {
|
|
45
|
+
...platform,
|
|
46
|
+
label: platform.title,
|
|
47
|
+
value: platform.id
|
|
48
|
+
};
|
|
49
|
+
setFormValue('platform', [formPlatform]);
|
|
50
|
+
} else {
|
|
51
|
+
setFormValue('platform', []);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
defaultPlatform,
|
|
57
|
+
selectedPlatform:
|
|
58
|
+
(isPlatformPage && initialData) ||
|
|
59
|
+
(modifiedData?.platform?.[0]?.id ? modifiedData?.platform?.[0] : platformRelation),
|
|
60
|
+
isLoadingPlatform
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { usePlatformFormData };
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { useRef, useEffect } from 'react';
|
|
2
|
-
|
|
3
|
-
// Hook
|
|
4
|
-
export const usePrevious = <T>(value: T): T | null => {
|
|
5
|
-
const ref: React.MutableRefObject<T | null> = useRef(null);
|
|
6
|
-
|
|
7
|
-
useEffect(() => {
|
|
8
|
-
ref.current = value;
|
|
9
|
-
}, [value]);
|
|
10
|
-
|
|
11
|
-
return ref.current;
|
|
12
|
-
};
|
|
1
|
+
import { useRef, useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
// Hook
|
|
4
|
+
export const usePrevious = <T>(value: T): T | null => {
|
|
5
|
+
const ref: React.MutableRefObject<T | null> = useRef(null);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
ref.current = value;
|
|
9
|
+
}, [value]);
|
|
10
|
+
|
|
11
|
+
return ref.current;
|
|
12
|
+
};
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
export const sanitizeModules = (modules: Record<string, any>[], convertToJSON = true) =>
|
|
2
|
-
modules?.map((module, idx) => {
|
|
3
|
-
try {
|
|
4
|
-
const sanitizedModule = sanitizeObject(module, idx, convertToJSON);
|
|
5
|
-
|
|
6
|
-
// go through top level properties in the module
|
|
7
|
-
for (let prop in sanitizedModule) {
|
|
8
|
-
// Strapi didn't give us the properties in an array when we used the Strapi API to get modules
|
|
9
|
-
// But it crashes when we try and have single relations not in an array, so we put them into an array.
|
|
10
|
-
if (
|
|
11
|
-
sanitizedModule[prop] &&
|
|
12
|
-
sanitizedModule[prop].hasOwnProperty('__is_array__') &&
|
|
13
|
-
!Array.isArray(sanitizedModule[prop])
|
|
14
|
-
) {
|
|
15
|
-
sanitizedModule[prop] = [{ ...sanitizedModule[prop] }];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// If a property is null, Strapi decides it should crash completely so we remove those.
|
|
19
|
-
if (sanitizedModule[prop] === null) {
|
|
20
|
-
delete sanitizedModule[prop];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const result = {
|
|
25
|
-
...sanitizedModule
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return result;
|
|
29
|
-
} catch (error) {
|
|
30
|
-
console.error('ERROR IN SANITIZE MODULES', error);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
function sanitizeObject(obj: any, idx: number, convertToJSON = true): any {
|
|
35
|
-
try {
|
|
36
|
-
for (let key in obj) {
|
|
37
|
-
try {
|
|
38
|
-
if (typeof obj[key] === 'object' && obj[key] !== null && obj[key] !== undefined) {
|
|
39
|
-
sanitizeObject(obj[key], idx);
|
|
40
|
-
}
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error('ERROR in loop', error);
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// We have to remove the id for components, but not for relations to other collection items
|
|
48
|
-
// We use createdAt to check, only collection items have this property (hopefully)
|
|
49
|
-
if (obj.hasOwnProperty('id') && !obj.hasOwnProperty('createdAt')) {
|
|
50
|
-
obj['__temp_key__'] = idx;
|
|
51
|
-
delete obj['id'];
|
|
52
|
-
} else if (obj.hasOwnProperty('id') && obj.hasOwnProperty('createdAt')) {
|
|
53
|
-
// if it's a relation to a collection item, it has to be in an array because it crashes otherwise.
|
|
54
|
-
// We use this property at the top of this file, only for top level properties.
|
|
55
|
-
obj['__is_array__'] = true;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
try {
|
|
59
|
-
if (obj.hasOwnProperty('defaultModuleOptions')) {
|
|
60
|
-
delete obj['defaultModuleOptions'].id;
|
|
61
|
-
|
|
62
|
-
let spacing = obj['defaultModuleOptions']?.spacing;
|
|
63
|
-
|
|
64
|
-
if (convertToJSON && spacing) {
|
|
65
|
-
spacing = JSON.stringify(spacing);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
obj['defaultModuleOptions'] = {
|
|
69
|
-
...obj['defaultModuleOptions'],
|
|
70
|
-
spacing,
|
|
71
|
-
__temp_key__: idx
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
} catch (error) {
|
|
75
|
-
console.error('error in defaultmodule options', error);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Strapi doesnt give us the mainfield and label properties when we get the data using the Strapi API
|
|
79
|
-
// So we add them here using other properties. This might be expanded with more if statements if required,
|
|
80
|
-
if (obj.hasOwnProperty('name') && !obj.hasOwnProperty('mainField') && !obj.hasOwnProperty('label')) {
|
|
81
|
-
obj['label'] = obj['name'];
|
|
82
|
-
obj['mainField'] = obj['name'];
|
|
83
|
-
}
|
|
84
|
-
if (obj.hasOwnProperty('title') && !obj.hasOwnProperty('mainField') && !obj.hasOwnProperty('label')) {
|
|
85
|
-
obj['label'] = obj['title'];
|
|
86
|
-
obj['mainField'] = obj['title'];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
return obj;
|
|
90
|
-
} catch (error) {
|
|
91
|
-
console.error('error in root sanitize object', error);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
1
|
+
export const sanitizeModules = (modules: Record<string, any>[], convertToJSON = true) =>
|
|
2
|
+
modules?.map((module, idx) => {
|
|
3
|
+
try {
|
|
4
|
+
const sanitizedModule = sanitizeObject(module, idx, convertToJSON);
|
|
5
|
+
|
|
6
|
+
// go through top level properties in the module
|
|
7
|
+
for (let prop in sanitizedModule) {
|
|
8
|
+
// Strapi didn't give us the properties in an array when we used the Strapi API to get modules
|
|
9
|
+
// But it crashes when we try and have single relations not in an array, so we put them into an array.
|
|
10
|
+
if (
|
|
11
|
+
sanitizedModule[prop] &&
|
|
12
|
+
sanitizedModule[prop].hasOwnProperty('__is_array__') &&
|
|
13
|
+
!Array.isArray(sanitizedModule[prop])
|
|
14
|
+
) {
|
|
15
|
+
sanitizedModule[prop] = [{ ...sanitizedModule[prop] }];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// If a property is null, Strapi decides it should crash completely so we remove those.
|
|
19
|
+
if (sanitizedModule[prop] === null) {
|
|
20
|
+
delete sanitizedModule[prop];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const result = {
|
|
25
|
+
...sanitizedModule
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return result;
|
|
29
|
+
} catch (error) {
|
|
30
|
+
console.error('ERROR IN SANITIZE MODULES', error);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
function sanitizeObject(obj: any, idx: number, convertToJSON = true): any {
|
|
35
|
+
try {
|
|
36
|
+
for (let key in obj) {
|
|
37
|
+
try {
|
|
38
|
+
if (typeof obj[key] === 'object' && obj[key] !== null && obj[key] !== undefined) {
|
|
39
|
+
sanitizeObject(obj[key], idx);
|
|
40
|
+
}
|
|
41
|
+
} catch (error) {
|
|
42
|
+
console.error('ERROR in loop', error);
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// We have to remove the id for components, but not for relations to other collection items
|
|
48
|
+
// We use createdAt to check, only collection items have this property (hopefully)
|
|
49
|
+
if (obj.hasOwnProperty('id') && !obj.hasOwnProperty('createdAt')) {
|
|
50
|
+
obj['__temp_key__'] = idx;
|
|
51
|
+
delete obj['id'];
|
|
52
|
+
} else if (obj.hasOwnProperty('id') && obj.hasOwnProperty('createdAt')) {
|
|
53
|
+
// if it's a relation to a collection item, it has to be in an array because it crashes otherwise.
|
|
54
|
+
// We use this property at the top of this file, only for top level properties.
|
|
55
|
+
obj['__is_array__'] = true;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
if (obj.hasOwnProperty('defaultModuleOptions')) {
|
|
60
|
+
delete obj['defaultModuleOptions'].id;
|
|
61
|
+
|
|
62
|
+
let spacing = obj['defaultModuleOptions']?.spacing;
|
|
63
|
+
|
|
64
|
+
if (convertToJSON && spacing) {
|
|
65
|
+
spacing = JSON.stringify(spacing);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
obj['defaultModuleOptions'] = {
|
|
69
|
+
...obj['defaultModuleOptions'],
|
|
70
|
+
spacing,
|
|
71
|
+
__temp_key__: idx
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('error in defaultmodule options', error);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Strapi doesnt give us the mainfield and label properties when we get the data using the Strapi API
|
|
79
|
+
// So we add them here using other properties. This might be expanded with more if statements if required,
|
|
80
|
+
if (obj.hasOwnProperty('name') && !obj.hasOwnProperty('mainField') && !obj.hasOwnProperty('label')) {
|
|
81
|
+
obj['label'] = obj['name'];
|
|
82
|
+
obj['mainField'] = obj['name'];
|
|
83
|
+
}
|
|
84
|
+
if (obj.hasOwnProperty('title') && !obj.hasOwnProperty('mainField') && !obj.hasOwnProperty('label')) {
|
|
85
|
+
obj['label'] = obj['title'];
|
|
86
|
+
obj['mainField'] = obj['title'];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return obj;
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error('error in root sanitize object', error);
|
|
92
|
+
}
|
|
93
|
+
}
|
package/custom.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
declare module '@strapi/design-system/*';
|
|
2
|
-
declare module '@strapi/design-system';
|
|
3
|
-
declare module '@strapi/icons';
|
|
4
|
-
declare module '@strapi/icons/*';
|
|
5
|
-
declare module '@strapi/helper-plugin';
|
|
6
|
-
declare module '@strapi/admin/*';
|
|
1
|
+
declare module '@strapi/design-system/*';
|
|
2
|
+
declare module '@strapi/design-system';
|
|
3
|
+
declare module '@strapi/icons';
|
|
4
|
+
declare module '@strapi/icons/*';
|
|
5
|
+
declare module '@strapi/helper-plugin';
|
|
6
|
+
declare module '@strapi/admin/*';
|
package/dist/package.json
CHANGED
package/dist/server/bootstrap.js
CHANGED
|
@@ -198,7 +198,7 @@ const afterUpdate = async (result) => {
|
|
|
198
198
|
data: {
|
|
199
199
|
...pageData,
|
|
200
200
|
id: result.collectionTypeData[0].id,
|
|
201
|
-
...result.customPublishedAt ? { publishedAt: result.customPublishedAt } : undefined,
|
|
201
|
+
...(result.customPublishedAt ? { publishedAt: result.customPublishedAt } : undefined),
|
|
202
202
|
lifecycleState: {
|
|
203
203
|
exit: true
|
|
204
204
|
}
|
|
@@ -5,15 +5,15 @@ const apollo_server_koa_1 = require("apollo-server-koa");
|
|
|
5
5
|
const strapi_1 = require("../utils/strapi");
|
|
6
6
|
const getPageByPath = (strapi) => {
|
|
7
7
|
const typeDefs = () => {
|
|
8
|
-
return `
|
|
9
|
-
extend type Page {
|
|
10
|
-
collectionType: GenericMorph
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type Query {
|
|
14
|
-
getPageByPath(path: String, domain: String, publicationState: PublicationState): PageEntity
|
|
15
|
-
}
|
|
16
|
-
|
|
8
|
+
return `
|
|
9
|
+
extend type Page {
|
|
10
|
+
collectionType: GenericMorph
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Query {
|
|
14
|
+
getPageByPath(path: String, domain: String, publicationState: PublicationState): PageEntity
|
|
15
|
+
}
|
|
16
|
+
|
|
17
17
|
`;
|
|
18
18
|
};
|
|
19
19
|
const resolvers = (strapi) => {
|
|
@@ -61,21 +61,24 @@ const getPageByPath = (strapi) => {
|
|
|
61
61
|
};
|
|
62
62
|
return result;
|
|
63
63
|
};
|
|
64
|
-
const
|
|
65
|
-
if (((_a = Object.values(
|
|
66
|
-
if (
|
|
67
|
-
return
|
|
64
|
+
const result = await getPage();
|
|
65
|
+
if (((_a = Object.values(result)) === null || _a === void 0 ? void 0 : _a.filter(Boolean).length) > 0) {
|
|
66
|
+
if ((result === null || result === void 0 ? void 0 : result.path) === '404' || result.path === '500') {
|
|
67
|
+
return result;
|
|
68
|
+
}
|
|
69
|
+
if (!((_b = result === null || result === void 0 ? void 0 : result.platform) === null || _b === void 0 ? void 0 : _b.isPrivate) && !(result === null || result === void 0 ? void 0 : result.isPrivate)) {
|
|
70
|
+
return result;
|
|
68
71
|
}
|
|
69
|
-
if ((((_c =
|
|
70
|
-
((
|
|
72
|
+
if ((((_c = result === null || result === void 0 ? void 0 : result.platform) === null || _c === void 0 ? void 0 : _c.isPrivate) === true && ctx.koaContext.req.headers.authorization) ||
|
|
73
|
+
((result === null || result === void 0 ? void 0 : result.isPrivate) === true && ctx.koaContext.req.headers.authorization)) {
|
|
71
74
|
const auth = ctx.koaContext.req.headers.authorization;
|
|
72
75
|
const token = auth.split(' ');
|
|
73
76
|
const jwtService = strapi.plugin('users-permissions').service('jwt');
|
|
74
77
|
const decodedToken = await jwtService.verify(token[1]);
|
|
75
78
|
if (decodedToken) {
|
|
76
79
|
const user = ctx.state.user;
|
|
77
|
-
if (((_d = user === null || user === void 0 ? void 0 : user.platform) === null || _d === void 0 ? void 0 : _d.id) === ((_e =
|
|
78
|
-
return
|
|
80
|
+
if (((_d = user === null || user === void 0 ? void 0 : user.platform) === null || _d === void 0 ? void 0 : _d.id) === ((_e = result === null || result === void 0 ? void 0 : result.platform) === null || _e === void 0 ? void 0 : _e.id)) {
|
|
81
|
+
return result;
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
}
|