From d0f2a3785f90f9233b6193d46879e699d58a5767 Mon Sep 17 00:00:00 2001 From: Vivian A Goodrich <101133187+vgoodric@users.noreply.github.com> Date: Wed, 14 Aug 2024 02:19:53 -0600 Subject: [PATCH] MWPW-156624 [MILO][MEP] Add locale prefix as an option for placeholder feature (#2736) * mepgeofolder * Update libs/features/personalization/preview.js Co-authored-by: Mark Perry <124626043+markpadbe@users.noreply.github.com> * MWPW-156545 [MILO][MEP] Info in MEP button panel is incorrect (#2729) * stash * add override existance to if check --------- Co-authored-by: Mark Perry <124626043+markpadbe@users.noreply.github.com> --- .../personalization/personalization.js | 19 ++++++++++++------- libs/features/personalization/preview.js | 10 +++++----- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/libs/features/personalization/personalization.js b/libs/features/personalization/personalization.js index 4a092127b4..4586cc158b 100644 --- a/libs/features/personalization/personalization.js +++ b/libs/features/personalization/personalization.js @@ -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; @@ -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 = {}; @@ -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; @@ -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('-'), @@ -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 */ @@ -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, @@ -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) => { diff --git a/libs/features/personalization/preview.js b/libs/features/personalization/preview.js index d98050622b..f88c0d4889 100644 --- a/libs/features/personalization/preview.js +++ b/libs/features/personalization/preview.js @@ -143,6 +143,7 @@ function createPreviewPill(manifests) { manifestUrl, manifestOverrideName, } = manifest; + const editUrl = manifestUrl || manifestPath; let radio = ''; variantNames.forEach((variant) => { const checked = { @@ -180,18 +181,18 @@ function createPreviewPill(manifests) {
On: ${manifest.event.start?.toLocaleString()} - instant
Off: ${manifest.event.end?.toLocaleString()}
` : ''; 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 += `