Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-164638 and 164805 MMM refine values for save and add manifest count #3416

Merged
merged 6 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions libs/blocks/mmm/mmm.css
Original file line number Diff line number Diff line change
@@ -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;
}
Expand Down
8 changes: 7 additions & 1 deletion libs/blocks/mmm/mmm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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);
Expand Down
15 changes: 9 additions & 6 deletions libs/features/personalization/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion test/blocks/mmm/mmm.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
5 changes: 5 additions & 0 deletions test/blocks/mmm/mocks/get-pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,39 @@
"pageId": 4,
"page": "/",
"locale": "en-US",
"numOfActivities": 1,
"url": "https://www.adobe.com/"
},
{
"geo": "",
"pageId": 7,
"page": "/acrobat/pricing.html",
"locale": "en-US",
"numOfActivities": 1,
"url": "https://www.adobe.com/acrobat/pricing.html"
},
{
"geo": "",
"pageId": 3,
"page": "/creativecloud.html",
"locale": "en-US",
"numOfActivities": 1,
"url": "https://www.adobe.com/creativecloud.html"
},
{
"geo": "ca_fr",
"pageId": 16,
"page": "/",
"locale": "fr-CA",
"numOfActivities": 1,
"url": "https://www.adobe.com/ca_fr/"
},
{
"geo": "de",
"pageId": 61,
"page": "/",
"locale": "de-DE",
"numOfActivities": 1,
"url": "https://www.adobe.com/de/"
}
]
7 changes: 7 additions & 0 deletions test/features/personalization/preview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down
Loading