Skip to content
This repository was archived by the owner on Mar 28, 2024. It is now read-only.

Commit 4c457e4

Browse files
committed
NEXT-25102 - Multiple CMS elements registered via Shopware 6 Admin SDK share same element config data
1 parent 27370e3 commit 4c457e4

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/ui/cms/index.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { createSender } from '../../channel';
22

3-
export const registerCmsElement = createSender('cmsRegisterElement');
4-
53
export type cmsRegisterElement = {
64
responseType: void,
75

@@ -28,3 +26,26 @@ export type cmsRegisterElement = {
2826
[key: string]: unknown,
2927
},
3028
};
29+
30+
export const registerCmsElement = createSender('cmsRegisterElement');
31+
32+
export const isCmsLocation = (name: string, type: 'preview' | 'component' | 'config'): { isLocation: false } | {isLocation: true, dataSetId: string} => {
33+
const params = new URLSearchParams(window.location.search);
34+
35+
const locationId = params.get('location-id');
36+
if (!locationId) {
37+
return { isLocation: false };
38+
}
39+
40+
const locationParts = locationId.split('-');
41+
42+
const [elementName, elementType, id] = locationParts;
43+
if (elementName !== name || elementType !== type || !id) {
44+
return { isLocation: false };
45+
}
46+
47+
return {
48+
isLocation: true,
49+
dataSetId: `${elementName}__${type}-${id}`,
50+
};
51+
};

0 commit comments

Comments
 (0)