Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
addressing feedback
  • Loading branch information
robert-bogos committed Jan 26, 2026
commit f36d20bc612b7778a8146b84ae3c1b550948e4cf
7 changes: 7 additions & 0 deletions libs/blocks/preflight/checks/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ export const STATUS = {
EMPTY: 'empty',
};

export const STATUS_TO_ICON_MAP = {
[STATUS.PASS]: 'green',
[STATUS.FAIL]: 'red',
[STATUS.LIMBO]: 'orange',
[STATUS.EMPTY]: 'empty',
};

export const SEVERITY = {
CRITICAL: 'critical',
WARNING: 'warning',
Expand Down
5 changes: 0 additions & 5 deletions libs/blocks/preflight/checks/localization.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ async function getStatus(url) {
return res?.status || 0;
}

function isAllowedHost(hostname) {
return ['adobe.com', 'aem.page', 'aem.live'].some((domain) => hostname === domain || hostname.endsWith(`.${domain}`));
}

function removeLocale(pathname, locales) {
const { prefix } = getLocale(locales, pathname);
if (!prefix) return pathname;
Expand Down Expand Up @@ -41,7 +37,6 @@ export async function runChecks({ area = document } = {}) {
const href = linkEl.getAttribute('href');
if (!href || href.startsWith('#')) return null;
const url = new URL(href, window.location.origin);
if (!isAllowedHost(url.hostname)) return null;
const basePath = removeLocale(url.pathname, locales);
if (url.hash && normalizePath(basePath) === '/') return null;
const key = `${url.origin}${normalizePath(url.pathname)}`;
Expand Down
19 changes: 3 additions & 16 deletions libs/blocks/preflight/panels/general.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { html, signal, useEffect } from '../../../deps/htm-preact.js';
import { STATUS, STRUCTURE_TITLES } from '../checks/constants.js';
import { STATUS_TO_ICON_MAP, STRUCTURE_TITLES } from '../checks/constants.js';
import { runChecks as runStructureChecks } from '../checks/structure.js';
import userCanPublishPage from '../../../tools/utils/publish.js';
import { runChecks as runLocalizationChecks } from '../checks/localization.js';
Expand Down Expand Up @@ -35,16 +35,9 @@ async function getStructureResults() {
];
const checks = runStructureChecks({ area: document });

const statusToIconMap = {
[STATUS.PASS]: 'green',
[STATUS.FAIL]: 'red',
[STATUS.LIMBO]: 'orange',
[STATUS.EMPTY]: 'empty',
};

await Promise.all(checks.map((result, index) => Promise.resolve(result)
.then((res) => {
const icon = statusToIconMap[res.status] || 'orange';
const icon = STATUS_TO_ICON_MAP[res.status] || 'orange';
signals[index].value = {
icon,
title: res.title,
Expand All @@ -63,14 +56,8 @@ async function getStructureResults() {
async function getLocalizationResults() {
try {
const [res] = await runLocalizationChecks({ area: document });
const statusToIconMap = {
[STATUS.PASS]: 'green',
[STATUS.FAIL]: 'red',
[STATUS.LIMBO]: 'orange',
[STATUS.EMPTY]: 'empty',
};
localizationResult.value = {
icon: statusToIconMap[res.status] || 'orange',
icon: STATUS_TO_ICON_MAP[res.status] || 'orange',
title: res.title,
description: res.description,
};
Expand Down
9 changes: 2 additions & 7 deletions libs/blocks/preflight/panels/performance.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { html, signal, useEffect } from '../../../deps/htm-preact.js';
import preflightApi from '../checks/preflightApi.js';
import { STATUS } from '../checks/constants.js';
import { STATUS_TO_ICON_MAP } from '../checks/constants.js';

const { getLcpEntry, runChecks } = preflightApi.performance;

Expand Down Expand Up @@ -34,12 +34,7 @@ async function getResults() {
const signalResult = signals[index];
return Promise.resolve(resultOrPromise)
.then((result) => {
const statusToIconMap = {
[STATUS.PASS]: 'green',
[STATUS.FAIL]: 'red',
[STATUS.EMPTY]: 'empty',
};
const icon = statusToIconMap[result.status] ?? 'orange';
const icon = STATUS_TO_ICON_MAP[result.status] ?? 'orange';
signalResult.value = {
icon,
title: result.title.replace('Performance - ', ''),
Expand Down
Loading