Skip to content

Commit

Permalink
[Release] Stage to Main (#2874)
Browse files Browse the repository at this point in the history
  • Loading branch information
milo-pr-merge[bot] authored Sep 16, 2024
2 parents a35fcb3 + 6fa9558 commit b60741a
Show file tree
Hide file tree
Showing 70 changed files with 4,281 additions and 3,640 deletions.
2 changes: 1 addition & 1 deletion libs/blocks/article-feed/article-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export async function loadTaxonomy() {
a.href = tax.link;
} else {
// eslint-disable-next-line no-console
window.lana.log(`Trying to get a link for an unknown topic: ${topic} (current page)`, { tags: 'errorType=warn,module=article-feed' });
window.lana.log(`Trying to get a link for an unknown topic: ${topic} (current page)`, { tags: 'article-feed' });
a.href = '#';
}
delete a.dataset.topicLink;
Expand Down
17 changes: 11 additions & 6 deletions libs/blocks/bulk-publish-v2/components/bulk-publisher.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import './job-process.js';
import { LitElement, html } from '../../../deps/lit-all.min.js';
import { getSheet } from '../../../../tools/utils/utils.js';
import { authenticate, startJob } from '../services.js';
import { authenticate, getPublishable, startJob } from '../services.js';
import { getConfig } from '../../../utils/utils.js';
import {
delay,
Expand Down Expand Up @@ -95,7 +95,8 @@ class BulkPublish2 extends LitElement {
this.validateUrls();
}

setJobErrors(errors) {
setJobErrors(jobErrors, authErrors) {
const errors = [...jobErrors, ...authErrors];
const urls = [];
errors.forEach((error) => {
const matched = this.urls.filter((url) => {
Expand Down Expand Up @@ -323,7 +324,8 @@ class BulkPublish2 extends LitElement {
class="panel-title"
@click=${handleToggle}>
<span class="title">
Job Results
${this.jobs.length ? html`<strong>${this.jobs.length}</strong>` : ''}
Job Result${this.jobs.length > 1 ? 's' : ''}
</span>
<div class="jobs-tools${showList}">
<div
Expand Down Expand Up @@ -380,16 +382,17 @@ class BulkPublish2 extends LitElement {
async submit() {
if (!this.isDisabled()) {
this.processing = 'started';
const { authorized, unauthorized } = await getPublishable(this);
const job = await startJob({
urls: this.urls,
urls: authorized,
process: this.process.toLowerCase(),
useBulk: this.user.permissions[this.process]?.useBulk ?? false,
});
const { complete, error } = processJobResult(job);
this.jobs = [...this.jobs, ...complete];
this.processing = complete.length ? 'job' : false;
if (error.length) {
this.setJobErrors(error);
if (error.length || unauthorized.length) {
this.setJobErrors(error, unauthorized);
} else {
if (this.mode === 'full') this.openJobs = true;
this.reset();
Expand All @@ -407,6 +410,7 @@ class BulkPublish2 extends LitElement {

renderPromptLoader() {
setTimeout(() => {
/* c8 ignore next 4 */
const loader = this.renderRoot.querySelector('.load-indicator');
const message = this.renderRoot.querySelector('.message');
loader?.classList.add('hide');
Expand All @@ -427,6 +431,7 @@ class BulkPublish2 extends LitElement {
const canUse = Object.values(this.user.permissions).filter((perms) => perms.canUse);
if (canUse.length) return html``;
message = 'Current user is not authorized to use Bulk Publishing Tool';
/* c8 ignore next 3 */
} else {
message = 'Please sign in to AEM sidekick to continue';
}
Expand Down
25 changes: 25 additions & 0 deletions libs/blocks/bulk-publish-v2/services.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import userCanPublishPage from '../../tools/utils/publish.js';
import {
PROCESS_TYPES,
getErrorText,
Expand Down Expand Up @@ -246,8 +247,32 @@ const updateRetry = async ({ queue, urls, process }) => {
return newQueue;
};

// publish authentication service
const getPublishable = async ({ urls, process, user }) => {
let publishable = { authorized: [], unauthorized: [] };
if (!isLive(process)) {
publishable.authorized = urls;
} else {
const { permissions, profile } = user;
const live = { permissions: ['read'] };
if (permissions?.publish?.canUse) {
live.permissions.push('write');
}
publishable = await urls.reduce(async (init, url) => {
const result = await init;
const detail = { webPath: new URL(url).pathname, live, profile };
const { canPublish, message } = await userCanPublishPage(detail);
if (canPublish) result.authorized.push(url);
else result.unauthorized.push({ href: url, message });
return result;
}, Promise.resolve(publishable));
}
return publishable;
};

export {
authenticate,
getPublishable,
pollJobStatus,
startJob,
updateRetry,
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/event-rich-results/event-rich-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function logNullValues(obj) {
Object.keys(obj).forEach((key) => {
const value = obj[key];
if (!value || value === '') {
window.lana.log(`Event property ${key} is not defined`, { tags: 'errorType=warn,module=event-rich-results' });
window.lana.log(`Event property ${key} is not defined`, { tags: 'event-rich-results' });
}
logNullValues(value);
});
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/faas/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ const beforeSubmitCallback = () => {
}),
})
.catch((error) => {
window.lana.log(`AA Sandbox Error: ${error.reason || error.error || error.message || error}`, { tags: 'errorType=info,module=faas' });
window.lana.log(`AA Sandbox Error: ${error.reason || error.error || error.message || error}`, { tags: 'faas', errorType: 'i' });
});
}
};
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/library-config/lists/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function formatDom(aemDom, path) {

async function formatTemplate(path) {
const resp = await fetch(path);
if (!resp.ok) window.lana.log('Could not fetch template path', { tags: 'errorType=info,module=sidekick-templates' });
if (!resp.ok) window.lana.log('Could not fetch template path', { tags: 'sidekick-templates', errorType: 'i' });

const html = await resp.text();
const dom = new DOMParser().parseFromString(html, 'text/html');
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/mobile-app-banner/mobile-app-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function getECID() {
if (window.alloy) {
await window.alloy('getIdentity').then((data) => {
ecid = data?.identity?.ECID;
}).catch((err) => window.lana.log(`Error fetching ECID: ${err}`, { tags: 'errorType=error,module=mobile-app-banner' }));
}).catch((err) => window.lana.log(`Error fetching ECID: ${err}`, { tags: 'mobile-app-banner' }));
}
return ecid;
}
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/path-finder/path-finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function buildUi(el, path) {
async function setup(el) {
await login({ scopes: SCOPES, telemetry: TELEMETRY });
if (!account.value.username) {
window.lana.log('Could not login to MS Graph', { tags: 'errorType=info,module=path-finder' });
window.lana.log('Could not login to MS Graph', { tags: 'path-finder', errorType: 'i' });
return;
}
el.innerHTML = '';
Expand Down
4 changes: 2 additions & 2 deletions libs/blocks/preflight/panels/seo.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async function spidyCheck(url) {
connectionError();
} catch (e) {
connectionError();
window.lana.log(`There was a problem connecting to the link check API ${url}. ${e}`, { tags: 'errorType=info,module=preflight' });
window.lana.log(`There was a problem connecting to the link check API ${url}. ${e}`, { tags: 'preflight', errorType: 'i' });
}
return false;
}
Expand All @@ -182,7 +182,7 @@ async function getSpidyResults(url, opts) {
return acc;
}, []);
} catch (e) {
window.lana.log(`There was a problem connecting to the link check API ${url}/api/url-http-status. ${e}`, { tags: 'errorType=info,module=preflight' });
window.lana.log(`There was a problem connecting to the link check API ${url}/api/url-http-status. ${e}`, { tags: 'preflight', errorType: 'i' });
return [];
}
}
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/quiz-entry/mlField.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const getMLResults = async (endpoint, apiKey, threshold, input, count, va
body: JSON.stringify(params),
})
.then((response) => response.json())
.catch((error) => window.lana.log(`ERROR: Fetching fi codes ${error}`, { tags: 'errorType=info,module=quiz-entry' }));
.catch((error) => window.lana.log(`ERROR: Fetching fi codes ${error}`, { tags: 'quiz-entry', errorType: 'i' }));

let value;
let highestProb = null;
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/quiz-entry/quiz-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const App = ({
}
if (fiResults.errors) error = fiResults.errors[0].title;
if (fiResults.error_code) error = fiResults.message;
window.lana.log(`ML results error - ${error}`, { tags: 'errorType=info,module=quiz-entry' });
window.lana.log(`ML results error - ${error}`, { tags: 'quiz-entry', errorType: 'i' });
sendMLFieldAnalytics(fallback, false);
}

Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/quiz-entry/quizPopover.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const getSuggestions = async (endpoint, clientId, input, scope) => {
});

if (!response.ok) {
window.lana.log('Failed to fetch suggestions', { tags: 'errorType=info,module=quiz-entry' });
window.lana.log('Failed to fetch suggestions', { tags: 'quiz-entry', errorType: 'i' });
return '';
}

Expand Down
4 changes: 2 additions & 2 deletions libs/blocks/quiz-results/quiz-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ async function loadFragments(el, experiences) {

function redirectPage(quizUrl, debug, message) {
const url = quizUrl ? getLocalizedURL(quizUrl.text) : 'https://adobe.com';
window.lana.log(message, { tags: 'errorType=error,module=quiz-results' });
window.lana.log(message, { tags: 'quiz-results' });

if (debug === 'quiz-results') {
// eslint-disable-next-line no-console
Expand Down Expand Up @@ -97,7 +97,7 @@ export default async function init(el, debug = null, localStoreKey = null) {

loadFragments(el, basic);
} else {
window.lana.log(`${LOADING_ERROR} The quiz-results block is misconfigured`, { tags: 'errorType=error,module=quiz-results' });
window.lana.log(`${LOADING_ERROR} The quiz-results block is misconfigured`, { tags: 'quiz-results' });
return;
}

Expand Down
15 changes: 9 additions & 6 deletions libs/blocks/table/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const DESKTOP_SIZE = 900;
const MOBILE_SIZE = 768;
const tableHighlightLoadedEvent = new Event('milo:table:highlight:loaded');
let tableIndex = 0;
const isMobileLandscape = () => (window.matchMedia('(orientation: landscape)').matches && window.innerHeight <= MOBILE_SIZE);
function defineDeviceByScreenSize() {
const screenWidth = window.innerWidth;
if (screenWidth >= DESKTOP_SIZE) {
Expand All @@ -17,6 +18,12 @@ function defineDeviceByScreenSize() {
return 'TABLET';
}

function isStickyHeader(el) {
return el.classList.contains('sticky')
|| (el.classList.contains('sticky-desktop-up') && defineDeviceByScreenSize() === 'DESKTOP')
|| (el.classList.contains('sticky-tablet-up') && defineDeviceByScreenSize() !== 'MOBILE' && !isMobileLandscape());
}

function handleHeading(table, headingCols) {
const isPriceBottom = table.classList.contains('pricing-bottom');
headingCols.forEach((col, i) => {
Expand Down Expand Up @@ -382,7 +389,7 @@ function applyStylesBasedOnScreenSize(table, originTable) {
}

if ((!isMerch && !table.querySelector('.col-3'))
|| (isMerch && !table.querySelector('.col-2'))) return;
|| (isMerch && !table.querySelector('.col-2'))) return;

const filterChangeEvent = () => {
table.innerHTML = originTable.innerHTML;
Expand Down Expand Up @@ -501,10 +508,6 @@ export default function init(el) {
expandSection = handleSection(sectionParams);
});

const isStickyHeader = el.classList.contains('sticky')
|| (el.classList.contains('sticky-desktop-up') && defineDeviceByScreenSize() === 'DESKTOP')
|| (el.classList.contains('sticky-tablet-up') && defineDeviceByScreenSize() !== 'MOBILE');

handleHighlight(el);
if (isMerch) formatMerchTable(el);

Expand All @@ -525,7 +528,7 @@ export default function init(el) {

const handleResize = () => {
applyStylesBasedOnScreenSize(el, originTable);
if (isStickyHeader) handleScrollEffect(el);
if (isStickyHeader(el)) handleScrollEffect(el);
};
handleResize();

Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/tag-selector/tag-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ const TagSelector = ({ consumerUrls = [] }) => {

const fetchCasS = async () => {
const { tags, errorMsg } = await loadCaasTags(caasTagUrl);
if (errorMsg) window.lana.log(`Tag Selector. Error fetching caas tags: ${errorMsg}`, { tags: 'errorType=info,module=tag-selector' });
if (errorMsg) window.lana.log(`Tag Selector. Error fetching caas tags: ${errorMsg}`, { tags: 'tag-selector', errorType: 'i' });

setTagSelectorTags((prevConsumerTags) => ({ CaaS: tags, ...prevConsumerTags }));
};
Expand Down
8 changes: 4 additions & 4 deletions libs/blocks/video-metadata/video-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function addBroadcastEventField(videoObj, blockKey, blockValue) {
videoObj.publication[i][camelize(key)] = blockValue;
break;
default:
window.lana.log(`VideoMetadata -- Unknown BroadcastEvent property: ${blockKey}`, { tags: 'errorType=warn,module=video-metadata' });
window.lana.log(`VideoMetadata -- Unknown BroadcastEvent property: ${blockKey}`, { tags: 'video-metadata' });
break;
}
}
Expand All @@ -45,7 +45,7 @@ function addClipField(videoObj, blockKey, blockValue) {
videoObj.hasPart[i][camelize(key)] = blockValue;
break;
default:
window.lana.log(`VideoMetadata -- Unhandled Clip property: ${blockKey}`, { tags: 'errorType=warn,module=video-metadata' });
window.lana.log(`VideoMetadata -- Unhandled Clip property: ${blockKey}`, { tags: 'video-metadata' });
break;
}
}
Expand All @@ -61,7 +61,7 @@ function addSeekToActionField(videoObj, blockKey, blockValue) {
videoObj.potentialAction['startOffset-input'] = blockValue;
break;
default:
window.lana.log(`VideoMetadata -- Unhandled SeekToAction property: ${blockKey}`, { tags: 'errorType=warn,module=video-metadata' });
window.lana.log(`VideoMetadata -- Unhandled SeekToAction property: ${blockKey}`, { tags: 'video-metadata' });
break;
}
}
Expand Down Expand Up @@ -96,7 +96,7 @@ export function createVideoObject(record) {
addSeekToActionField(video, blockKey, blockVal);
break;
default:
window.lana.log(`VideoMetadata -- Unhandled VideoObject property: ${blockKey}`, { tags: 'errorType=warn,module=video-metadata' });
window.lana.log(`VideoMetadata -- Unhandled VideoObject property: ${blockKey}`, { tags: 'video-metadata' });
break;
}
});
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/vimeo/vimeo.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class LiteVimeo extends HTMLElement {
this.style.backgroundImage = `url("${thumbnailUrl}")`;
})
.catch((e) => {
window.lana.log(`Error fetching Vimeo thumbnail: ${e}`, { tags: 'errorType=info,module=vimeo' });
window.lana.log(`Error fetching Vimeo thumbnail: ${e}`, { tags: 'vimeo', errorType: 'i' });
});
}

Expand Down
Loading

0 comments on commit b60741a

Please sign in to comment.