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

Commit

Permalink
NEXT-25102 - Multiple CMS elements registered via Shopware 6 Admin SD…
Browse files Browse the repository at this point in the history
…K share same element config data
  • Loading branch information
NiklasLimberg committed Aug 4, 2023
1 parent acf2e8f commit 9ee45f0
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/ui/cms/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { createSender } from '../../channel';

export const registerCmsElement = createSender('cmsRegisterElement');

export type cmsRegisterElement = {
responseType: void,

Expand All @@ -28,3 +26,26 @@ export type cmsRegisterElement = {
[key: string]: unknown,
},
};

export const registerCmsElement = createSender('cmsRegisterElement');

export const isCmsLocation = (name: string, type: 'preview' | 'component' | 'config'): { isLocation: false } | {isLocation: true, dataSetId: string} => {
const params = new URLSearchParams(window.location.search);

const locationId = params.get('location-id');
if (!locationId) {
return { isLocation: false };
}

const locationParts = locationId.split('-');

const [elementName, elementType, id] = locationParts;
if (elementName !== name || elementType !== type || !id) {
return { isLocation: false };
}

return {
isLocation: true,
dataSetId: `${elementName}__${type}-${id}`,
};
};

0 comments on commit 9ee45f0

Please sign in to comment.