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

[Release] Stage to Main #2423

Merged
merged 5 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
66 changes: 37 additions & 29 deletions libs/features/personalization/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,51 +213,59 @@ function createPreviewPill(manifests) {
document.body.dataset.mepHighlight = true;
}

const PREVIEW_BUTTON_ID = 'preview-button';

div.innerHTML = `
<div class="mep-manifest mep-badge">
<span class="mep-open"></span>
<div class="mep-manifest-count">${manifests?.length || 0} Manifest(s) served</div>
</div>
<div class="mep-popup">
<div class="mep-popup-header">
<div>
<h4>${manifests?.length || 0} Manifest(s) served</h4>
<span class="mep-close"></span>
<div class="mep-manifest-page-info-title">Page Info:</div>
<div>Target integration feature is ${targetOnText}</div>
<div>Personalization feature is ${personalizationOnText}</div>
<div>Page's Locale is ${config.locale.ietf}</div>
</div>
</div>
<div class="mep-manifest-list">
<div class="mep-manifest-info">
<div class="mep-manifest-variants">
<input type="checkbox" name="mepHighlight" id="mepHighlightCheckbox" ${mepHighlightChecked} value="true"> <label for="mepHighlightCheckbox">Highlight changes</label>
<div class="mep-popup-header">
<div>
<h4>${manifests?.length || 0} Manifest(s) served</h4>
<span class="mep-close"></span>
<div class="mep-manifest-page-info-title">Page Info:</div>
<div>Target integration feature is ${targetOnText}</div>
<div>Personalization feature is ${personalizationOnText}</div>
<div>Page's Locale is ${config.locale.ietf}</div>
</div>
</div>
${manifestList}
<div class="mep-advanced-container">
<div class="mep-toggle-advanced">Advanced options</div>
<div class="mep-manifest-info mep-advanced-options">
<div>
Optional: new manifest location or path
</div>
<div class="mep-manifest-list">
<div class="mep-manifest-info">
<div class="mep-manifest-variants">
<input type="checkbox" name="mepHighlight" id="mepHighlightCheckbox" ${mepHighlightChecked} value="true"> <label for="mepHighlightCheckbox">Highlight changes</label>
</div>
</div>
${manifestList}
<div class="mep-advanced-container">
<div class="mep-toggle-advanced">Advanced options</div>
<div class="mep-manifest-info mep-advanced-options">
<div>
<input type="text" name="new-manifest" id="new-manifest">
Optional: new manifest location or path
</div>
<div class="mep-manifest-variants">
<div>
<input type="text" name="new-manifest" id="new-manifest">
</div>
</div>
</div>
</div>
<div class="mep-manifest-info">
<div class="mep-manifest-variants mep-advanced-options">
<input type="checkbox" name="mepPreviewButtonCheckbox" id="mepPreviewButtonCheckbox" value="off"> <label for="mepPreviewButtonCheckbox">add mepButton=off to preview link</label>
<div class="mep-manifest-info">
<div class="mep-manifest-variants mep-advanced-options">
<input type="checkbox" name="mepPreviewButtonCheckbox" id="mepPreviewButtonCheckbox" value="off"> <label for="mepPreviewButtonCheckbox">add mepButton=off to preview link</label>
</div>
</div>
</div>
</div>
</div>
<div class="dark">
<a class="con-button outline button-l" href="${simulateHref.href}" title="Preview above choices">Preview</a>
<div class="dark">
<a class="con-button outline button-l" data-id="${PREVIEW_BUTTON_ID}" title="Preview above choices">Preview</a>
</div>
</div>`;

const previewButton = div.querySelector(`a[data-id="${PREVIEW_BUTTON_ID}"]`);

if (previewButton) previewButton.href = simulateHref.href;

overlay.append(div);
addPillEventListeners(div);
}
Expand Down
9 changes: 9 additions & 0 deletions libs/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ import {
// Production Domain
const prodDomains = ['milo.adobe.com'];

const stageDomainsMap = {
'www.adobe.com': 'www.stage.adobe.com',
'blog.adobe.com': 'blog.stage.adobe.com',
'business.adobe.com': 'business.stage.adobe.com',
'helpx.adobe.com': 'helpx.stage.adobe.com',
'news.adobe.com': 'news.stage.adobe.com',
};

const locales = {
'': { ietf: 'en-US', tk: 'hah7vzn.css' },
ae_ar: { ietf: 'ar-AE', tk: 'lpk1hwn.css', dir: 'rtl' },
Expand Down Expand Up @@ -127,6 +135,7 @@ const config = {
codeRoot: '/libs',
locales,
prodDomains,
stageDomainsMap,
jarvis: {
id: 'milo',
version: '1.0',
Expand Down
4 changes: 4 additions & 0 deletions libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -608,12 +608,16 @@ export function decorateAutoBlock(a) {
}

export function decorateLinks(el) {
const config = getConfig();
decorateImageLinks(el);
const anchors = el.getElementsByTagName('a');
return [...anchors].reduce((rdx, a) => {
appendHtmlToLink(a);
a.href = localizeLink(a.href);
decorateSVG(a);
if (config.env?.name === 'stage' && config.stageDomainsMap?.[a.hostname]) {
a.href = a.href.replace(a.hostname, config.stageDomainsMap[a.hostname]);
}
if (a.href.includes('#_blank')) {
a.setAttribute('target', '_blank');
a.href = a.href.replace('#_blank', '');
Expand Down
20 changes: 19 additions & 1 deletion test/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('Utils', () => {
await waitForElement('.login-action');
const login = document.querySelector('.login-action');
utils.decorateLinks(login);
expect(login.href).to.equal('https://www.adobe.com/');
expect(login.href).to.equal('https://www.stage.adobe.com/');
});
});

Expand Down Expand Up @@ -423,6 +423,24 @@ describe('Utils', () => {
expect(block).to.be.null;
expect(document.querySelector('.quote.hide-block')).to.be.null;
});

it('should convert prod links to stage links on stage env', async () => {
const stageDomainsMap = {
'www.adobe.com': 'www.stage.adobe.com',
'blog.adobe.com': 'blog.stage.adobe.com',
'business.adobe.com': 'business.stage.adobe.com',
'helpx.adobe.com': 'helpx.stage.adobe.com',
'news.adobe.com': 'news.stage.adobe.com',
};
utils.setConfig({
...config,
env: { name: 'stage' },
stageDomainsMap,
});
const links = Object.keys(stageDomainsMap).map((prodDom) => document.body.appendChild(createTag('a', { href: `https://${prodDom}`, 'data-prod-dom': prodDom })));
await utils.decorateLinks(document.body);
links.forEach((l) => expect(l.hostname === stageDomainsMap[l.dataset.prodDom]).to.be.true);
});
});

describe('title-append', async () => {
Expand Down
Loading