diff --git a/libs/blocks/mmm/mmm.css b/libs/blocks/mmm/mmm.css index 9ee9086170..044a9ff464 100644 --- a/libs/blocks/mmm/mmm.css +++ b/libs/blocks/mmm/mmm.css @@ -1,5 +1,12 @@ @import '../../styles/inline.css'; +.mmm-page_item-subtext { + position: absolute; + font-size: 12px; + bottom: 3px; + left: 16px; + color: #505050; +} .mmm-container { padding: var(--spacing-m) 0; } diff --git a/libs/blocks/mmm/mmm.js b/libs/blocks/mmm/mmm.js index f1f0e3fbf9..fc0b05fb38 100644 --- a/libs/blocks/mmm/mmm.js +++ b/libs/blocks/mmm/mmm.js @@ -26,11 +26,16 @@ async function toggleDrawer(target, dd) { } } function createButtonDetailsPair(mmmEl, page) { - const { url, pageId } = page; + const { url, pageId, numOfActivities } = page; const triggerId = `mmm-trigger-${pageId}`; const panelId = `mmm-content-${pageId}`; const icon = createTag('span', { class: 'mmm-icon' }); const hTag = createTag('h5', false, url); + const activitiesNum = createTag( + 'span', + { class: 'mmm-page_item-subtext' }, + `${numOfActivities} Manifest(s) found`, + ); const button = createTag('button', { type: 'button', id: triggerId, @@ -39,6 +44,7 @@ function createButtonDetailsPair(mmmEl, page) { 'aria-controls': panelId, }, hTag); button.append(icon); + button.append(activitiesNum); const dtHtml = hTag ? createTag(hTag.tagName, { class: 'mmm-heading' }, button) : button; const dt = createTag('dt', false, dtHtml); diff --git a/libs/features/personalization/preview.js b/libs/features/personalization/preview.js index f55deedbb8..3ee4f925cb 100644 --- a/libs/features/personalization/preview.js +++ b/libs/features/personalization/preview.js @@ -74,16 +74,18 @@ function addPillEventListeners(div) { export function parsePageAndUrl(config, windowLocation, prefix) { const { stageDomainsMap, env } = config; const { pathname, origin } = windowLocation; - if (env?.name === 'prod' || !stageDomainsMap) { - return { page: pathname.replace(`/${prefix}/`, '/'), url: `${origin}${pathname}` }; - } - let path = pathname; - let domain = origin; const allowedHosts = [ 'business.stage.adobe.com', 'www.stage.adobe.com', 'milo.stage.adobe.com', ]; + if (env?.name === 'prod' || !stageDomainsMap + || allowedHosts.includes(origin.replace('https://', ''))) { + const domain = origin.replace('stage.adobe.com', 'adobe.com'); + return { page: pathname.replace(`/${prefix}/`, '/'), url: `${domain}${pathname}` }; + } + let path = pathname; + let domain = origin; const domainCheck = Object.keys(stageDomainsMap) .find((key) => { try { @@ -353,7 +355,8 @@ function addHighlightData(manifests) { } export async function saveToMmm() { const data = parseMepConfig(); - if (data.page.url.includes('/drafts/')) return false; + const excludedStrings = ['/drafts/', '.stage.', '.page/', '.live/', '/fragments/', '/nala/']; + if (excludedStrings.some((str) => data.page.url.includes(str))) return false; data.activities = data.activities.filter((activity) => { const { url, source } = activity; activity.source = source.filter((item) => item !== 'mep param'); diff --git a/test/blocks/mmm/mmm.test.js b/test/blocks/mmm/mmm.test.js index 56b51c4531..1912e8b5f7 100644 --- a/test/blocks/mmm/mmm.test.js +++ b/test/blocks/mmm/mmm.test.js @@ -33,7 +33,7 @@ describe('MMM', () => { expect(mmmDl).to.exist; const mmmDt = mmmDl.querySelectorAll('dt'); expect(mmmDt.length).to.equal(5); - expect(mmmDt[0].textContent).to.equal('https://www.adobe.com/'); + expect(mmmDt[0].textContent).to.equal('https://www.adobe.com/1 Manifest(s) found'); const mmmDd = mmmDl.querySelectorAll('dd'); expect(mmmDd.length).to.equal(5); const loading = mmmDd[0].querySelector('.loading'); diff --git a/test/blocks/mmm/mocks/get-pages.json b/test/blocks/mmm/mocks/get-pages.json index 9c07e761c8..f67ae0a11d 100644 --- a/test/blocks/mmm/mocks/get-pages.json +++ b/test/blocks/mmm/mocks/get-pages.json @@ -4,6 +4,7 @@ "pageId": 4, "page": "/", "locale": "en-US", + "numOfActivities": 1, "url": "https://www.adobe.com/" }, { @@ -11,6 +12,7 @@ "pageId": 7, "page": "/acrobat/pricing.html", "locale": "en-US", + "numOfActivities": 1, "url": "https://www.adobe.com/acrobat/pricing.html" }, { @@ -18,6 +20,7 @@ "pageId": 3, "page": "/creativecloud.html", "locale": "en-US", + "numOfActivities": 1, "url": "https://www.adobe.com/creativecloud.html" }, { @@ -25,6 +28,7 @@ "pageId": 16, "page": "/", "locale": "fr-CA", + "numOfActivities": 1, "url": "https://www.adobe.com/ca_fr/" }, { @@ -32,6 +36,7 @@ "pageId": 61, "page": "/", "locale": "de-DE", + "numOfActivities": 1, "url": "https://www.adobe.com/de/" } ] diff --git a/test/features/personalization/preview.test.js b/test/features/personalization/preview.test.js index 23649cb6f3..f7f41caee2 100644 --- a/test/features/personalization/preview.test.js +++ b/test/features/personalization/preview.test.js @@ -148,6 +148,13 @@ describe('preview feature', () => { expect(url).to.equal('https://www.adobe.com/fr/products/photoshop.html'); expect(page).to.equal('/products/photoshop.html'); }); + it('parse url and page for no stage map', () => { + config.env.name = 'stage'; + delete config.stageDomainsMap; + const { url, page } = parsePageAndUrl(config, new URL('https://www.stage.adobe.com/events/2024-10-31.html'), ''); + expect(url).to.equal('https://www.adobe.com/events/2024-10-31.html'); + expect(page).to.equal('/events/2024-10-31.html'); + }); it('opens manifest', () => { document.querySelector('a.mep-edit-manifest').click(); });