Skip to content

Commit

Permalink
Helix 5 support for milo blocks and features (#3140)
Browse files Browse the repository at this point in the history
* Helix 5 support for milo blocks and features

* Fix the failing unit test

* Fix personalization nala tests

* Update libs/blocks/quiz-entry/quiz-entry.css

Co-authored-by: Brad Johnson <fullcolorcoder@gmail.com>

* Embed Rares' PR feedback

* Account for authored paths to include either .hlx. or .aem.

* Remove trailing space

* Properly decorate metadata for both hlx4 and hlx5

* Simplify configs

* Add separate privacy ids for hlx and aem

* Adapt codecov patches to hit the threshhold at 90%

---------

Co-authored-by: Brad Johnson <fullcolorcoder@gmail.com>
  • Loading branch information
mokimo and fullcolorcoder authored Nov 13, 2024
1 parent 031b5d2 commit 86b2210
Show file tree
Hide file tree
Showing 53 changed files with 106 additions and 84 deletions.
4 changes: 2 additions & 2 deletions .github/PULL_REQUEST_TEMPLATE/gnav.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ Resolves: [MWPW-111111](https://jira.corp.adobe.com/browse/MWPW-111111)
- After: https://main--blog--adobecom.hlx.page/?milolibs=<branch>--milo--<owner>

**Milo:**
- Before: https://main--milo--adobecom.hlx.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off
- After: https://<branch>--milo--<owner>.hlx.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off
- Before: https://main--milo--adobecom.aem.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off
- After: https://<branch>--milo--<owner>.aem.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off
4 changes: 2 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
Resolves: [MWPW-NUMBER](https://jira.corp.adobe.com/browse/MWPW-NUMBER)

**Test URLs:**
- Before: https://main--milo--adobecom.hlx.page/?martech=off
- After: https://<branch>--milo--adobecom.hlx.page/?martech=off
- Before: https://main--milo--adobecom.aem.page/?martech=off
- After: https://<branch>--milo--adobecom.aem.page/?martech=off
4 changes: 2 additions & 2 deletions .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ let body = `
**Acrobat:** https://www.stage.adobe.com/acrobat/online/sign-pdf.html
**Milo:**
- Before: https://main--milo--adobecom.hlx.live/?martech=off
- After: https://stage--milo--adobecom.hlx.live/?martech=off
- Before: https://main--milo--adobecom.aem.live/?martech=off
- After: https://stage--milo--adobecom.aem.live/?martech=off
`;

const isHighPrio = (labels) => labels.includes(LABELS.highPriority);
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ Resolves: NO TICKET - AUTOMATED CREATED PR.
- After: https://main--blog--adobecom.hlx.page/?martech=off&milolibs=${branch}--milo--adobecom
**Milo:**
- Before: https://main--milo--adobecom.hlx.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off
- After: https://${branch}--milo--adobecom.hlx.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off`;
- Before: https://main--milo--adobecom.aem.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off
- After: https://${branch}--milo--adobecom.aem.page/ch_de/drafts/ramuntea/gnav-refactor?martech=off`;

const fetchScript = (path) =>
new Promise((resolve, reject) => {
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Ensure that your PR follows the [pull request template](.github/pull_request_tem

* description contains Issue or Ticket
* description _always_ contains at least one Milo-specific testing URL
* `https://<branch>--milo--<user>.hlx.page/?martech=off`
* `https://<branch>--milo--<user>.aem.page/?martech=off`

Ensure your PR passes all checks:

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Milo is a shared set of features and services to power Franklin-based websites o
[![codecov](https://codecov.io/gh/adobecom/milo/branch/main/graph/badge.svg?token=a7ZTCbitBt)](https://codecov.io/gh/adobecom/milo)

## Environments
[Preview](https://main--milo--adobecom.hlx.page) | [Live](https://milo.adobe.com)
[Preview](https://main--milo--adobecom.aem.page) | [Live](https://milo.adobe.com)

## Getting started

Expand Down Expand Up @@ -51,11 +51,11 @@ You can then test any of the following:
```
http://localhost:3000/?milolibs=local (local code, stage content)
https://main--project--owner.hlx.page/?milolibs=local (prod code, stage content)
https://main--project--owner.aem.page/?milolibs=local (prod code, stage content)
https://main--project--owner.hlx.live/?milolibs=local (prod code, prod content)
https://main--project--owner.aem.live/?milolibs=local (prod code, prod content)
https://feat-branch--project--owner.hlx.page/?milolibs=local (feature code, stage content)
https://feat-branch--project--owner.aem.page/?milolibs=local (feature code, stage content)
```

## Testing
Expand Down
2 changes: 1 addition & 1 deletion codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ coverage:
status:
patch:
default:
target: 100%
target: 90%
threshold: 0.1%
project:
default:
Expand Down
2 changes: 1 addition & 1 deletion helix-query.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: 1
# See https://www.hlx.live/docs/setup-indexing.
# See https://www.aem.live/docs/setup-indexing.

indices:
wiki:
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/bulk-publish-v2/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const checkedIcon = `${base}/blocks/bulk-publish-v2/img/checked.svg`;
const crossedIcon = `${base}/blocks/bulk-publish-v2/img/crossed.svg`;
const indicatorIcon = `${base}/blocks/bulk-publish-v2/img/indicator.svg`;

const getHost = (host) => (host === 'localhost' ? 'main--milo--adobecom.hlx.page' : host);
const getHost = (host) => (host === 'localhost' ? 'main--milo--adobecom.aem.page' : host);

const getStatusIcon = (status) => {
switch (status) {
Expand Down
6 changes: 3 additions & 3 deletions libs/blocks/caas-marquee/caas-marquee.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-shadow, consistent-return, max-len, quote-props, prefer-const */
import { createTag, getConfig, loadMartech } from '../../utils/utils.js';
import { createTag, getConfig, loadMartech, SLD } from '../../utils/utils.js';

const SEGMENTS_MAP = {
attributes: {
Expand Down Expand Up @@ -195,8 +195,8 @@ function getMetadata(el) {

function isProd() {
const { host } = window.location;
return !(host.includes('hlx.page')
|| host.includes('hlx.live')
return !(host.includes(`${SLD}.page`)
|| host.includes(`${SLD}.live`)
|| host.includes('localhost')
|| host.includes('stage.adobe')
|| host.includes('corp.adobe'));
Expand Down
5 changes: 3 additions & 2 deletions libs/blocks/caas/caas.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
getConfig,
getMetadata,
parseEncodedConfig,
SLD,
} from '../../utils/utils.js';

const ROOT_MARGIN = 1000;
Expand Down Expand Up @@ -61,12 +62,12 @@ const loadCaas = async (a) => {

if (host.includes('stage.adobe') || env?.name === 'local' || caasEndpoint === 'stage') {
chimeraEndpoint = S_CAAS_AIO;
} else if (host.includes('.hlx.') || caasEndpoint === 'prod') {
} else if (host.includes(`.${SLD}.`) || caasEndpoint === 'prod') {
// If invoking URL is not an Acom URL, then switch to AIO
chimeraEndpoint = P_CAAS_AIO;
}

if (host.includes('hlx.page') || env?.name === 'local' || caasContainer === 'draft') {
if (host.includes(`${SLD}.page`) || env?.name === 'local' || caasContainer === 'draft') {
state.draftDb = true;
}

Expand Down
4 changes: 2 additions & 2 deletions libs/blocks/library-config/library-config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createTag } from '../../utils/utils.js';
import { createTag, SLD } from '../../utils/utils.js';

const LIBRARY_PATH = '/docs/library/library.json';

Expand Down Expand Up @@ -129,7 +129,7 @@ async function getSuppliedLibrary() {
const owner = searchParams.get('owner');
const library = searchParams.get('library');
if (!repo || !owner) return null;
return fetchLibrary(`https://main--${repo}--${owner}.hlx.live`, library);
return fetchLibrary(`https://main--${repo}--${owner}.${SLD}.live`, library);
}

async function fetchAssetsData(path) {
Expand Down
3 changes: 2 additions & 1 deletion libs/blocks/marketo/marketo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
localizeLink,
createTag,
createIntersectionObserver,
SLD,
} from '../../utils/utils.js';

const ROOT_MARGIN = 50;
Expand Down Expand Up @@ -56,7 +57,7 @@ export const decorateURL = (destination, baseURL = window.location) => {
throw new Error('URL does not have a valid host');
}

if (destinationUrl.hostname.includes('.hlx.')) {
if (destinationUrl.hostname.includes(`.${SLD}.`)) {
destinationUrl = new URL(`${pathname}${search}${hash}`, baseURL.origin);
}

Expand Down
6 changes: 3 additions & 3 deletions libs/blocks/merch/merch.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
createTag, getConfig, loadArea, loadScript, loadStyle, localizeLink,
createTag, getConfig, loadArea, loadScript, loadStyle, localizeLink, SLD,
} from '../../utils/utils.js';
import { replaceKey } from '../../features/placeholders.js';

Expand Down Expand Up @@ -240,7 +240,7 @@ export function getMasBase(hostname, maslibs) {
baseUrl = 'http://localhost:9001';
} else if (maslibs) {
const extension = /.page$/.test(hostname) ? 'page' : 'live';
baseUrl = `https://${maslibs}.hlx.${extension}`;
baseUrl = `https://${maslibs}.${SLD}.${extension}`;
} else {
baseUrl = 'https://www.adobe.com/mas';
}
Expand Down Expand Up @@ -493,7 +493,7 @@ export async function openModal(e, url, offerType, hash, extraOptions) {
}, { once: true });
}
if (isInternalModal(url)) {
const fragmentPath = url.split(/hlx.(page|live)/).pop();
const fragmentPath = url.split(/(hlx|aem).(page|live)/).pop();
modal = await openFragmentModal(fragmentPath, getModal);
} else {
modal = await openExternalModal(url, getModal, extraOptions);
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/ost/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ perform the following:
- navigate to adobe.com,
- open devtools console,
- execute `copy(adobeIMS.getAccessToken().token)`,
- add token to OST URL querystring, e.g.: `https://mwpw-127984--milo--vladen.hlx.page/tools/ost?token=eyJhb...`
- add token to OST URL querystring, e.g.: `https://mwpw-127984--milo--vladen.aem.page/tools/ost?token=eyJhb...`

## Settings

Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/pdf-viewer/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# PDF Viewer

## Feature Branch Testing
The client ids are specific to the origin (no wildcards), so the stage **pdfViewerClientId** only works for **main--milo--adobecom.hlx.page**. If you want to test the pdf on a feature branch, you need to create a new temporary client id. Alternatively, you can name your branch **pdf-viewsdk** and use the existing client id that's set up for **pdf-viewsdk--milo--adobecom.hlx.page**. You can find it in the [developer console](https://developer.adobe.com/console/) under "Milo PDF Viewer Branch".
The client ids are specific to the origin (no wildcards), so the stage **pdfViewerClientId** only works for **main--milo--adobecom.aem.page**. If you want to test the pdf on a feature branch, you need to create a new temporary client id. Alternatively, you can name your branch **pdf-viewsdk** and use the existing client id that's set up for **pdf-viewsdk--milo--adobecom.aem.page**. You can find it in the [developer console](https://developer.adobe.com/console/) under "Milo PDF Viewer Branch".

How to create a new client id:
1. Got to https://acrobatservices.adobe.com/dc-integration-creation-app-cdn/main.html?api=pdf-embed-api.
Expand Down
4 changes: 2 additions & 2 deletions libs/blocks/pdf-viewer/pdf-viewer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* global AdobeDC */

import { createTag, getConfig, loadScript } from '../../utils/utils.js';
import { createTag, getConfig, loadScript, SLD } from '../../utils/utils.js';

const API_SOURCE_URL = 'https://acrobatservices.adobe.com/view-sdk/viewer.js';
const PDF_RENDER_DIV_ID = 'adobe-dc-view';
Expand All @@ -14,7 +14,7 @@ export const getPdfConfig = () => {
let clientId = env.consumer?.pdfViewerClientId || env.pdfViewerClientId;
let reportSuiteId = env.consumer?.pdfViewerReportSuite || env.pdfViewerReportSuite;

if (host.includes('hlx.live') || query === 'live') {
if (host.includes(`${SLD}.live`) || query === 'live') {
/* c8 ignore next 2 */
clientId = live?.pdfViewerClientId || CLIENT_ID_LIVE;
reportSuiteId = live?.pdfViewerReportSuite || env.pdfViewerReportSuite;
Expand Down
3 changes: 2 additions & 1 deletion libs/blocks/preflight/panels/seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ async function checkLinks() {
&& !knownBadUrls.some((url) => url === link.hostname) // Is not a known bad url
) {
link.liveHref = link.href.replace('hlx.page', 'hlx.live');
link.liveHref = link.href.replace('aem.page', 'aem.live');
return true;
}
return false;
Expand Down Expand Up @@ -278,7 +279,7 @@ export async function sendResults() {
};

await fetch(
'https://main--milo--adobecom.hlx.page/seo/preflight',
'https://main--milo--adobecom.aem.page/seo/preflight',
{
method: 'POST',
credentials: 'same-origin',
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/quiz-entry/quiz-entry.css
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@

.carousel-arrow {
background-color: #fff;
background-image: url('https://main--milo--adobecom.hlx.page/libs/blocks/carousel/img/arrow.svg');
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='16' viewBox='0 0 10 16'%3E%3Cdefs%3E%3Cstyle%3E.a%7Bfill%3A%23f0f%3Bopacity%3A0%3B%7D.b%7Bfill%3A%23767676%3B%7D%3C/style%3E%3C/defs%3E%3Cg transform='translate(10 16) rotate(180)'%3E%3Crect class='a' width='10' height='16'/%3E%3Cpath class='b' d='M9.115,13.853l0,0L3.051,8,9.117,2.15l0,0A1.246,1.246,0,1,0,7.386.353l0,0L7.367.366h0L.382,7.1l0,0a1.237,1.237,0,0,0,0,1.794l0,0,6.982,6.732,0,0,.015.014,0,0a1.246,1.246,0,1,0,1.73-1.794Z'/%3E%3C/g%3E%3C/svg%3E");
background-size: 15px;
background-position: 50% 50%;
background-repeat: no-repeat;
Expand Down
4 changes: 2 additions & 2 deletions libs/blocks/section-metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
The card & modal-metadata blocks use this block. If making changes, please ensure there are no breaking changes for those use cases.

## Test pages
https://main--milo--adobecom.hlx.page/drafts/cmillar/section-container - Section Metadata
https://main--milo--adobecom.hlx.page/drafts/methomas/card - Card
https://main--milo--adobecom.aem.page/drafts/cmillar/section-container - Section Metadata
https://main--milo--adobecom.aem.page/drafts/methomas/card - Card
1 change: 1 addition & 0 deletions libs/blocks/version-history/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function getSiteOrigin() {
const search = new URLSearchParams(window.location.search);
const repo = search.get('repo');
const owner = search.get('owner');
// TODO ADD HLX5 SUPPORT
return repo && owner ? `https://main--${repo}--${owner}.hlx.live` : window.location.origin;
}

Expand Down
1 change: 1 addition & 0 deletions libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const normalizePath = (p, localize = true) => {

if (path.startsWith(config.codeRoot)
|| path.includes('.hlx.')
|| path.includes('.aem.')
|| path.includes('.adobe.')) {
try {
const url = new URL(path);
Expand Down
2 changes: 1 addition & 1 deletion libs/features/title-append/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# title-append

The title-append feature allows you to append an arbitrary string to an HTML document's title by populating a "title-append" column for any given row in [Franklin's bulk-metadata](https://www.hlx.live/docs/bulk-metadata).
The title-append feature allows you to append an arbitrary string to an HTML document's title by populating a "title-append" column for any given row in [Franklin's bulk-metadata](https://www.aem.live/docs/bulk-metadata).

## Example

Expand Down
4 changes: 2 additions & 2 deletions libs/mep/ace0861/section-metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
The card & modal-metadata blocks use this block. If making changes, please ensure there are no breaking changes for those use cases.

## Test pages
https://main--milo--adobecom.hlx.page/drafts/cmillar/section-container - Section Metadata
https://main--milo--adobecom.hlx.page/drafts/methomas/card - Card
https://main--milo--adobecom.aem.page/drafts/cmillar/section-container - Section Metadata
https://main--milo--adobecom.aem.page/drafts/methomas/card - Card
6 changes: 3 additions & 3 deletions libs/navigation/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const blockConfig = [
const envMap = {
prod: 'https://www.adobe.com',
stage: 'https://www.stage.adobe.com',
qa: 'https://gnav--milo--adobecom.hlx.page',
qa: 'https://gnav--milo--adobecom.aem.page',
};

const getStageDomainsMap = (stageDomainsMap) => (
Expand Down Expand Up @@ -62,7 +62,7 @@ export default async function loadBlock(configs, customLib) {
stageDomainsMap = {},
} = configs || {};
const branch = new URLSearchParams(window.location.search).get('navbranch');
const miloLibs = branch ? `https://${branch}--milo--adobecom.hlx.page` : customLib || envMap[env];
const miloLibs = branch ? `https://${branch}--milo--adobecom.aem.page` : customLib || envMap[env];
if (!header && !footer) {
// eslint-disable-next-line no-console
console.error('Global navigation Error: header and footer configurations are missing.');
Expand All @@ -78,7 +78,7 @@ export default async function loadBlock(configs, customLib) {
const paramConfigs = getParamsConfigs(configs, miloLibs);
const clientConfig = {
clientEnv: env,
origin: `https://main--federal--adobecom.hlx.${env === 'prod' ? 'live' : 'page'}`,
origin: `https://main--federal--adobecom.aem.${env === 'prod' ? 'live' : 'page'}`,
miloLibs: `${miloLibs}/libs`,
pathname: `/${locale}`,
locales: configs.locales || locales,
Expand Down
2 changes: 2 additions & 0 deletions libs/scripts/delayed.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ export const loadPrivacy = async (getConfig, loadScript) => {
const ids = {
'hlx.page': '3a6a37fe-9e07-4aa9-8640-8f358a623271-test',
'hlx.live': '926b16ce-cc88-4c6a-af45-21749f3167f3-test',
'aem.page': '01930689-3b6a-7d5f-9797-8df2c3901a05-test',
'aem.live': '01930691-c4e5-75ba-aa0e-721e1213c139-test',
};

const otDomainId = ids?.[Object.keys(ids)
Expand Down
2 changes: 1 addition & 1 deletion libs/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const stageDomainsMap = {
'business.adobe.com': 'main--bacom--adobecom.hlx.page',
},
'.business-graybox.adobe.com': { 'business.adobe.com': 'origin' },
'^https://.*--milo--.*.hlx.page': {
'^https://.*--milo--.*.*.page': {
'^https://www.adobe.com/acrobat': 'https://main--dc--adobecom.hlx.page',
'^https://business.adobe.com(?!/blog)': 'https://business.stage.adobe.com',
'^https://business.adobe.com/blog': 'https://main--bacom-blog--adobecom.hlx.page',
Expand Down
6 changes: 3 additions & 3 deletions libs/utils/federated.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getConfig } from './utils.js';
import { getConfig, SLD } from './utils.js';

let federatedContentRoot;
/* eslint-disable import/prefer-default-export */
Expand All @@ -19,8 +19,8 @@ export const getFederatedContentRoot = () => {
? origin
: 'https://www.adobe.com';

if (origin.includes('localhost') || origin.includes('.hlx.')) {
federatedContentRoot = `https://main--federal--adobecom.hlx.${origin.endsWith('.live') ? 'live' : 'page'}`;
if (origin.includes('localhost') || origin.includes(`.${SLD}.`)) {
federatedContentRoot = `https://main--federal--adobecom.aem.${origin.endsWith('.live') ? 'live' : 'page'}`;
}

return federatedContentRoot;
Expand Down
4 changes: 2 additions & 2 deletions libs/utils/service-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Get author-facing config options.
*/

import { getConfig } from './utils.js';
import { getConfig, SLD } from './utils.js';

const DOT_MILO = '/.milo/config.json';

Expand All @@ -13,7 +13,7 @@ function getSiteOrigin() {
const search = new URLSearchParams(window.location.search);
const repo = search.get('repo');
const owner = search.get('owner');
return repo && owner ? `https://main--${repo}--${owner}.hlx.live` : window.location.origin;
return repo && owner ? `https://main--${repo}--${owner}.${SLD}.live` : window.location.origin;
}

/**
Expand Down
Loading

0 comments on commit 86b2210

Please sign in to comment.