Skip to content

Commit

Permalink
Merge pull request #996 from adobecom/2507fix
Browse files Browse the repository at this point in the history
DC Milo 2.507 Fix
  • Loading branch information
joaquinrivero authored Feb 12, 2025
2 parents cdd1a93 + eec0321 commit 86e0bf5
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 18 deletions.
12 changes: 8 additions & 4 deletions acrobat/blocks/rnr/rnr.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,13 @@ const { createTag } = await import(`${miloLibs}/utils/utils.js`);

// #region Constants

const isProd = window.location.hostname === 'main--dc--adobecom.hlx.page'
|| window.location.hostname === 'main--dc--adobecom.hlx.live'
|| window.location.hostname === 'www.adobe.com';
const isProd = [
'main--dc--adobecom.aem.page',
'main--dc--adobecom.aem.live',
'main--dc--adobecom.hlx.page',
'main--dc--adobecom.hlx.live',
'www.adobe.com',
].includes(window.location.hostname);

const COMMENTS_MAX_LENGTH = 500;
const COMMENTS_MAX_LENGTH_ALLOWED = 10000;
Expand Down Expand Up @@ -195,7 +199,7 @@ async function postReview(data) {
const headers = {
Accept: 'application/vnd.adobe-review.review-data-v1+json',
'Content-Type': 'application/vnd.adobe-review.review-request-v1+json',
'x-api-key': 'rnr-client',
'x-api-key': RNR_API_KEY,
Authorization: window.adobeIMS.getAccessToken()?.token,
};

Expand Down
52 changes: 38 additions & 14 deletions acrobat/scripts/frictionless.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,62 @@
/* eslint-disable ecmalist/no-object-fromentries */
import reviewAlloy from './alloy/review.js';
import reviewFeedbackAlloy from './alloy/reviewFeedback.js';
import browserExtAlloy from './alloy/browserExt.js'

const reviewBlock = document.querySelectorAll('.review')
import browserExtAlloy from './alloy/browserExt.js';

export default function init(verb) {

// Review Alloy
if (reviewBlock) {
const miloReviewBlock = document.querySelector('.review');
const rnrBlock = document.querySelector('.rnr');
/**
* TODO the milo block related code can be removed once all frictionless
* pages transition to rnr. For now, handle both.
*/
if (miloReviewBlock || rnrBlock) {
reviewAlloy();
const reviewWait = setInterval(() => {
const reviewForm = document.querySelectorAll('.hlx-Review');
if (reviewForm.length > 0) {
// Milo block handling
const [miloReviewForm] = document.querySelectorAll('.hlx-Review');
if (miloReviewForm) {
clearInterval(reviewWait);
reviewForm[0].addEventListener('submit', (e) => {
miloReviewForm.addEventListener('submit', (e) => {
const data = Object.fromEntries(new FormData(e.target).entries());
// verb, rating, comment
reviewFeedbackAlloy(verb, data.rating, data['rating-comments']);
});
const reviewTooltip = reviewBlock[0].querySelectorAll('.tooltip');
const reviewTooltip = miloReviewForm.querySelectorAll('.tooltip');
if (reviewTooltip.length > 0) {
reviewTooltip[3].addEventListener('click', () => {
reviewFeedbackAlloy(verb, '4');
})
});
reviewTooltip[4].addEventListener('click', () => {
reviewFeedbackAlloy(verb, '5');
})
});
}
}
// Rnr block handling
const [rnrForm] = document.querySelectorAll('.rnr-form');
if (rnrForm) {
clearInterval(reviewWait);
rnrForm.addEventListener('submit', (e) => {
const data = Object.fromEntries(new FormData(e.target).entries());
// verb, rating, comment
reviewFeedbackAlloy(verb, data.rating, data.comments);
});
const stars = rnrForm.querySelectorAll('.rnr-rating-fieldset input');
if (stars.length > 0) {
stars[3]?.addEventListener('click', () => {
reviewFeedbackAlloy(verb, '4');
});
stars[4]?.addEventListener('click', () => {
reviewFeedbackAlloy(verb, '5');
});
}
}
}, 1000);
}

// Browser Ext. Alloy
window.addEventListener('modal:open', ()=> {
window.addEventListener('modal:open', () => {
let extName;
const { name: browserName } = window.browser;
if (browserName === 'Chrome') {
Expand All @@ -42,12 +66,12 @@ export default function init(verb) {
if (browserName === 'Microsoft Edge') {
extName = '#edgeext';
}
const extensionWait = setInterval( ()=> {
const extensionWait = setInterval(() => {
const browserExtModal = document.querySelector(extName);
const browserExtClose = browserExtModal?.querySelector('.dialog-close');
const browserExtGetLink = browserExtModal?.querySelector('.browser-extension a');

if(!browserExtModal || !browserExtClose || !browserExtGetLink){
if (!browserExtModal || !browserExtClose || !browserExtGetLink) {
return;
}
clearInterval(extensionWait);
Expand Down

0 comments on commit 86e0bf5

Please sign in to comment.