diff --git a/.github/workflows/helpers.js b/.github/workflows/helpers.js index c086fe88d1..7b36bc38b1 100644 --- a/.github/workflows/helpers.js +++ b/.github/workflows/helpers.js @@ -43,15 +43,21 @@ const RCPDates = [ }, ]; -const isWithinRCP = () => { +const isWithinRCP = (offset = 0) => { const now = new Date(); if (now.getFullYear() !== CURRENT_YEAR) { console.log(`ADD NEW RCPs for ${CURRENT_YEAR + 1}`); return true; } - if (RCPDates.some(({ start, end }) => start <= now && now <= end)) { - console.log('Current date is within a RCP. Stopping execution.'); + if (RCPDates.some(({ start, end }) => { + const adjustedStart = new Date(start); + adjustedStart.setDate(adjustedStart.getDate() - offset); + return start <= now && now <= end + })) { + console.log( + 'Current date is within a RCP (2 days earlier for stage, to keep stage clean & make CSO contributions during an RCP easier). Stopping execution.' + ); return true; } diff --git a/.github/workflows/merge-to-stage.js b/.github/workflows/merge-to-stage.js index 1ce20ca4c4..19ef68f570 100644 --- a/.github/workflows/merge-to-stage.js +++ b/.github/workflows/merge-to-stage.js @@ -179,7 +179,7 @@ const main = async (params) => { github = params.github; owner = params.context.repo.owner; repo = params.context.repo.repo; - if (isWithinRCP()) return console.log('Stopped, within RCP period.'); + if (isWithinRCP(2)) return console.log('Stopped, within RCP period.'); try { const stageToMainPR = await getStageToMainPR(); diff --git a/libs/features/personalization/preview.js b/libs/features/personalization/preview.js index 28caab1d2d..df2d7944fc 100644 --- a/libs/features/personalization/preview.js +++ b/libs/features/personalization/preview.js @@ -213,51 +213,59 @@ function createPreviewPill(manifests) { document.body.dataset.mepHighlight = true; } + const PREVIEW_BUTTON_ID = 'preview-button'; + div.innerHTML = `
${manifests?.length || 0} Manifest(s) served
-
-
-

${manifests?.length || 0} Manifest(s) served

- -
Page Info:
-
Target integration feature is ${targetOnText}
-
Personalization feature is ${personalizationOnText}
-
Page's Locale is ${config.locale.ietf}
-
-
-
-
-
- +
+
+

${manifests?.length || 0} Manifest(s) served

+ +
Page Info:
+
Target integration feature is ${targetOnText}
+
Personalization feature is ${personalizationOnText}
+
Page's Locale is ${config.locale.ietf}
- ${manifestList} -
-
Advanced options
-
-
- Optional: new manifest location or path -
+
+
+ +
+
+ ${manifestList} +
+
Advanced options
+
- + Optional: new manifest location or path +
+
+
+ +
-
-
-
- +
+
+ +
-
-
- Preview +
+ Preview +
`; + + const previewButton = div.querySelector(`a[data-id="${PREVIEW_BUTTON_ID}"]`); + + if (previewButton) previewButton.href = simulateHref.href; + overlay.append(div); addPillEventListeners(div); } diff --git a/libs/img/icons/icons.svg b/libs/img/icons/icons.svg index 4d91de3b63..5bacf4b763 100644 --- a/libs/img/icons/icons.svg +++ b/libs/img/icons/icons.svg @@ -1,5 +1,14 @@ + + + + + + + + + @@ -9,110 +18,118 @@ - - + + + + - - + + - - - - - - - + + - - - - - - - + + - - - - + + - - + + - - - + + + Device Phone + Facebook Facebook Logo - + + + + + + + + + Instagram + Instagram Logo + + + + + Copy + Copy to Clipboard + LinkedIn LinkedIn Logo - + - - X - X Logo - + + - - Instagram - Instagram Logo - + + + + + + + - - Tiktok - Tiktok Logo - + + + - - Copy - Copy to Clipboard - + + - - + + - - Device Phone - + + - - + + + + + + + + + + + + + + Tiktok + Tiktok Logo + + + + + X + X Logo + + diff --git a/libs/scripts/scripts.js b/libs/scripts/scripts.js index b7e0aca870..154e81967c 100644 --- a/libs/scripts/scripts.js +++ b/libs/scripts/scripts.js @@ -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' }, @@ -127,6 +135,7 @@ const config = { codeRoot: '/libs', locales, prodDomains, + stageDomainsMap, jarvis: { id: 'milo', version: '1.0', diff --git a/libs/utils/utils.js b/libs/utils/utils.js index 4aef67ed2e..fc39d9017c 100644 --- a/libs/utils/utils.js +++ b/libs/utils/utils.js @@ -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', ''); diff --git a/test/utils/utils.test.js b/test/utils/utils.test.js index 149ef1d736..0dcd7883ee 100644 --- a/test/utils/utils.test.js +++ b/test/utils/utils.test.js @@ -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/'); }); }); @@ -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 () => {