Skip to content

Commit

Permalink
[Release] Stage to Main (adobecom#2742)
Browse files Browse the repository at this point in the history
  • Loading branch information
milo-pr-merge[bot] authored Aug 19, 2024
2 parents baef0d5 + f92f07c commit 53f37de
Show file tree
Hide file tree
Showing 12 changed files with 54 additions and 25 deletions.
1 change: 1 addition & 0 deletions .github/workflows/label-zero-impact.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const zeroImpactDirs = [
'LICENSE',
'codecov.yaml',
'.gitignore',
'package.json',
'package-lock.json',
];
const zeroImpactLabel = 'zero-impact';
Expand Down
4 changes: 2 additions & 2 deletions libs/blocks/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export function getHashParams(hashStr) {
params.hash = part;
} else {
const [key, val] = part.split('=');
if (key === 'delay' && parseInt(val, 10) > 0) {
if (key === 'delay') {
params.delay = parseInt(val, 10) * 1000;
}
}
Expand All @@ -232,7 +232,7 @@ export function getHashParams(hashStr) {

export function delayedModal(el) {
const { hash, delay } = getHashParams(el?.dataset.modalHash);
if (!delay || !hash) return false;
if (delay === undefined || !hash) return false;
isDelayedModal = true;
const modalOpenEvent = new Event(`${hash}:modalOpen`);
const pagesModalWasShownOn = window.sessionStorage.getItem(`shown:${hash}`);
Expand Down
4 changes: 2 additions & 2 deletions libs/deps/imslib.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion libs/features/personalization/entitlements.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getConfig } from '../../utils/utils.js';

const ENTITLEMENT_MAP = {
'51b1f617-2e43-4e91-a98a-3b7716ecba8f': 'photoshop-any',
'31943c06-06de-4f5f-8689-18973c13207a': 'photoshop-any',
'8ba78b22-90fb-4b97-a1c4-f8c03a45cbc2': 'indesign-any',
'8d3c8ac2-2937-486b-b6ff-37f02271b09b': 'illustrator-any',
'fd30e9c7-9ae9-44db-8e70-5c652a5bb1d2': 'cc-all-apps-any',
Expand Down
19 changes: 12 additions & 7 deletions libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -442,11 +442,11 @@ export function handleCommands(commands, rootEl = document, forceInline = false)
});
}

const getVariantInfo = (line, variantNames, variants, manifestPath, manifestOverrideName) => {
const getVariantInfo = (line, variantNames, variants, manifestPath, fTargetId) => {
const config = getConfig();
let manifestId = getFileName(manifestPath);
let targetId = manifestId.replace('.json', '');
if (manifestOverrideName) targetId = manifestOverrideName;
if (fTargetId) targetId = fTargetId;
if (!config.mep?.preview) manifestId = false;
const action = line.action?.toLowerCase().replace('content', '').replace('fragment', '');
const { selector } = line;
Expand Down Expand Up @@ -508,7 +508,7 @@ const getVariantInfo = (line, variantNames, variants, manifestPath, manifestOver
});
};

export function parseManifestVariants(data, manifestPath, manifestOverrideName) {
export function parseManifestVariants(data, manifestPath, targetId) {
if (!data?.length) return null;

const manifestConfig = {};
Expand All @@ -524,7 +524,7 @@ export function parseManifestVariants(data, manifestPath, manifestOverrideName)
});

experiences.forEach((line) => {
getVariantInfo(line, variantNames, variants, manifestPath, manifestOverrideName);
getVariantInfo(line, variantNames, variants, manifestPath, targetId);
});

manifestConfig.variants = variants;
Expand All @@ -545,6 +545,7 @@ function parsePlaceholders(placeholders, config, selectedVariantName = '') {
if (!placeholders?.length || selectedVariantName === 'default') return config;
const valueNames = [
selectedVariantName.toLowerCase(),
config.mep?.geoPrefix,
config.locale.region.toLowerCase(),
config.locale.ietf.toLowerCase(),
...config.locale.ietf.toLowerCase().split('-'),
Expand Down Expand Up @@ -684,8 +685,9 @@ export async function getManifestConfig(info, variantOverride = false) {
acc[item.key] = item.value;
return acc;
}, {});
const manifestOverrideName = name || infoObj?.['manifest-override-name']?.toLowerCase();
const manifestConfig = parseManifestVariants(persData, manifestPath, manifestOverrideName);
const manifestOverrideName = infoObj?.['manifest-override-name']?.toLowerCase();
const targetId = name || manifestOverrideName;
const manifestConfig = parseManifestVariants(persData, manifestPath, targetId);

if (!manifestConfig) {
/* c8 ignore next 3 */
Expand All @@ -697,8 +699,10 @@ export async function getManifestConfig(info, variantOverride = false) {
'manifest-execution-order': ['First', 'Normal', 'Last'],
};
if (infoTab) {
manifestConfig.manifestOverrideName = manifestOverrideName;
manifestConfig.manifestType = infoObj?.['manifest-type']?.toLowerCase();
if (manifestOverrideName && manifestConfig.manifestType === TRACKED_MANIFEST_TYPE) {
manifestConfig.manifestOverrideName = manifestOverrideName;
}
const executionOrder = {
'manifest-type': 1,
'manifest-execution-order': 1,
Expand Down Expand Up @@ -955,6 +959,7 @@ export async function init(enablements = {}) {
highlight: (mepHighlight !== undefined && mepHighlight !== 'false'),
targetEnabled: target,
experiments: [],
geoPrefix: config.locale?.prefix.split('/')[1]?.toLowerCase() || 'en-us',
};
manifests = manifests.concat(await combineMepSources(pzn, promo, mepParam));
manifests?.forEach((manifest) => {
Expand Down
10 changes: 5 additions & 5 deletions libs/features/personalization/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ function createPreviewPill(manifests) {
manifestUrl,
manifestOverrideName,
} = manifest;
const editUrl = manifestUrl || manifestPath;
let radio = '';
variantNames.forEach((variant) => {
const checked = {
Expand Down Expand Up @@ -180,18 +181,18 @@ function createPreviewPill(manifests) {
<p>On: ${manifest.event.start?.toLocaleString()} - <a target= "_blank" href="?instant=${manifest.event.start?.toISOString()}">instant</a></p>
<p>Off: ${manifest.event.end?.toLocaleString()}</p>` : '';
let analyticsTitle = '';
if (manifestType === TRACKED_MANIFEST_TYPE) {
if (manifestType !== TRACKED_MANIFEST_TYPE) {
analyticsTitle = 'N/A for this manifest type';
} else if (manifestOverrideName) {
analyticsTitle = manifestOverrideName;
} else {
analyticsTitle = manifestFileName.replace('.json', '').slice(0, 20);
}
manifestList += `<div class="mep-manifest-info" title="Full url: ${manifestUrl}&#013;Analytics manifest name: ${analyticsTitle}">
manifestList += `<div class="mep-manifest-info" title="Manifest location: ${editUrl}&#013;Analytics manifest name: ${analyticsTitle}">
<div class="mep-manifest-title">
${targetTitle}
<i></i>
<a class="mep-edit-manifest" data-manifest-url="${manifestUrl}" data-manifest-path="${manifestPath}" target="_blank" title="Open manifest">
<a class="mep-edit-manifest" data-manifest-url="${editUrl}" data-manifest-path="${editUrl}" target="_blank" title="Open manifest">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0,0,256,256" width="16px" height="16px" fill-rule="nonzero"><g transform=""><g fill="#ffffff" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><g transform="scale(8.53333,8.53333)"><path d="M22.82813,3c-0.51175,0 -1.02356,0.19544 -1.41406,0.58594l-2.41406,2.41406l5,5l2.41406,-2.41406c0.781,-0.781 0.781,-2.04713 0,-2.82812l-2.17187,-2.17187c-0.3905,-0.3905 -0.90231,-0.58594 -1.41406,-0.58594zM17,8l-11.74023,11.74023c0,0 0.91777,-0.08223 1.25977,0.25977c0.342,0.342 0.06047,2.58 0.48047,3c0.42,0.42 2.64389,0.12436 2.96289,0.44336c0.319,0.319 0.29688,1.29688 0.29688,1.29688l11.74023,-11.74023zM4,23l-0.94336,2.67188c-0.03709,0.10544 -0.05623,0.21635 -0.05664,0.32813c0,0.55228 0.44772,1 1,1c0.11177,-0.00041 0.22268,-0.01956 0.32813,-0.05664c0.00326,-0.00128 0.00652,-0.00259 0.00977,-0.00391l0.02539,-0.00781c0.00196,-0.0013 0.00391,-0.0026 0.00586,-0.00391l2.63086,-0.92773l-1.5,-1.5z"></path></g></g></g></svg>
</a>
${scheduled}
Expand Down Expand Up @@ -228,8 +229,7 @@ function createPreviewPill(manifests) {
<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 Region is ${config.locale.region}</div>
<div>Page's Locale is ${config.locale.ietf}</div>
<div>Page's Prefix/Region/Locale are ${config.mep.geoPrefix} / ${config.locale.region} / ${config.locale.ietf}</div>
</div>
</div>
<div class="mep-manifest-list">
Expand Down
2 changes: 1 addition & 1 deletion libs/features/personalization/stage-entitlements.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const STAGE_ENTITLEMENTS = {
'5a5fd14e-f4ca-49d2-9f87-835df5477e3c': 'photoshop-any',
'22ec76d1-b715-4ec5-8f36-b0db7c8b725a': 'photoshop-any',
'09bc4ba3-ebed-4d05-812d-a1fb1a7e82ae': 'indesign-any',
'25ede755-7181-4be2-801e-19f157c005ae': 'illustrator-any',
'bf632803-4412-463d-83c5-757dda3224ee': 'cc-all-apps-any',
Expand Down
26 changes: 23 additions & 3 deletions libs/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,10 +730,30 @@ async function decorateIcons(area, config) {
async function decoratePlaceholders(area, config) {
const el = area.querySelector('main') || area;
const regex = /{{(.*?)}}|%7B%7B(.*?)%7D%7D/g;
const found = regex.test(el.innerHTML);
if (!found) return;
const walker = document.createTreeWalker(
el,
NodeFilter.SHOW_TEXT,
{
acceptNode(node) {
const a = regex.test(node.nodeValue) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT;
regex.lastIndex = 0;
return a;
},
},
);
const nodes = [];
let node = walker.nextNode();
while (node !== null) {
nodes.push(node);
node = walker.nextNode();
}
if (!nodes.length) return;
const { replaceText } = await import('../features/placeholders.js');
el.innerHTML = await replaceText(el.innerHTML, config, regex);
const replaceNodes = nodes.map(async (textNode) => {
textNode.nodeValue = await replaceText(textNode.nodeValue, config, regex);
textNode.nodeValue = textNode.nodeValue.replace(/&nbsp;/g, '\u00A0');
});
await Promise.all(replaceNodes);
}

async function loadFooter() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"lint": "npm run lint:js && npm run lint:css",
"lint:js": "eslint .",
"lint:js:nibble": "eslint-nibble .",
"lint:css": "stylelint 'blocks/**/*.css' 'styles/*.css'",
"lint:css": "stylelint 'libs/blocks/**/*.css' 'libs/styles/*.css'",
"build:htm-preact": "microbundle ./build/htm-preact.js -o ./libs/deps/htm-preact.js -f modern --no-sourcemap --target web; mv ./libs/deps/htm-preact.modern.mjs ./libs/deps/htm-preact.js",
"build:preact-debug": "microbundle ./build/htm-preact-debug.js -o ./libs/deps/htm-preact-debug.js -f modern --no-sourcemap --target web; mv ./libs/deps/htm-preact-debug.modern.mjs ./libs/deps/htm-preact-debug.js",
"build:gnav-profile": "microbundle ./libs/blocks/global-navigation/blocks/profile/profile-wrapper.js -o ./build/profile-wrapper-build.js -f umd --external none --no-sourcemap --target web; mv ./build/profile-wrapper-build.umd.js ./build/profile.js"
Expand Down
5 changes: 4 additions & 1 deletion test/blocks/modals/modals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ describe('Modals', () => {

it('validates and returns proper hash parameters', () => {
expect(getHashParams()).to.deep.equal({});
expect(getHashParams('#delayed-modal:delay=0')).to.deep.equal({ hash: '#delayed-modal' });
expect(getHashParams('#delayed-modal:delay=0')).to.deep.equal({
delay: 0,
hash: '#delayed-modal',
});
expect(getHashParams('#delayed-modal:delay=1')).to.deep.equal({
delay: 1000,
hash: '#delayed-modal',
Expand Down
2 changes: 1 addition & 1 deletion test/utils/mocks/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@
<!-- Default content -->
<div>
<p>I'm not a blockhead.</p>
<p>{{nothing-to-see-here}}</p>
<p>{{&nbsp;inkl. MwSt.}}</p>
</div>
</main>
2 changes: 1 addition & 1 deletion test/utils/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe('Utils', () => {
it('Decorates placeholder', () => {
const paragraphs = [...document.querySelectorAll('p')];
const lastPara = paragraphs.pop();
expect(lastPara.textContent).to.equal('nothing to see here');
expect(lastPara.textContent).to.equal(' inkl. MwSt.');
});

it('Decorates meta helix url', () => {
Expand Down

0 comments on commit 53f37de

Please sign in to comment.