Skip to content

Commit

Permalink
[QA fixes] Jan 8th findings (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyundai authored Jan 9, 2025
1 parent 9110747 commit c51cf87
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,16 @@ async function populateRow(props, index) {

const row = createTag('tr', { class: 'attendee-row', 'data-attendee-id': attendee.attendeeId }, '', { parent: tBody });

const getDisplayVal = (key) => {
if (key === 'checkedIn') {
return attendee[key] ? 'yes' : 'no';
}

return attendee[key];
};

ATTENDEE_ATTR_MAP.forEach(({ key, fallback }, i, arr) => {
const td = createTag('td', {}, attendee[key] || fallback, { parent: row });
const td = createTag('td', {}, getDisplayVal(key) || fallback, { parent: row });
if (stickyColumns.includes(key)) {
td.classList.add(`sticky-right-${arr.length - i}`, 'actions');
}
Expand Down
54 changes: 36 additions & 18 deletions ecc/blocks/event-creation-form/event-creation-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ function closeDialog(props) {
if (dialog) dialog.innerHTML = '';
}

function buildPreviewLoadingDialog(props) {
function buildPreviewLoadingDialog(props, targetHref, poll) {
const spTheme = props.el.querySelector('#form-app');
if (!spTheme) return null;

Expand Down Expand Up @@ -595,14 +595,28 @@ function buildPreviewLoadingDialog(props) {
dialog.appendChild(style);
dialog.appendChild(progressBar);
const buttonContainer = createTag('div', { class: 'button-container' }, '', { parent: dialog });
createTag('sp-button', { variant: 'cta', slot: 'button', id: 'cancel-preview' }, 'Cancel', { parent: buttonContainer });
const seePreviewButton = createTag('sp-button', { variant: 'secondary', slot: 'button', id: 'see-preview' }, 'Go to preview page now', { parent: buttonContainer });
const cancelButton = createTag('sp-button', { variant: 'cta', slot: 'button', id: 'cancel-preview' }, 'Cancel', { parent: buttonContainer });

underlay.open = true;

seePreviewButton.addEventListener('click', () => {
window.open(targetHref);
closeDialog(props);
if (poll.interval) clearInterval(poll.interval);
poll.resolve();
});

cancelButton.addEventListener('click', () => {
closeDialog(props);
if (poll.interval) clearInterval(poll.interval);
poll.resolve();
});

return dialog;
}

function buildPreviewLoadingFailedDialog(props) {
function buildPreviewLoadingFailedDialog(props, targetHref) {
const spTheme = props.el.querySelector('#form-app');
if (!spTheme) return;

Expand All @@ -615,15 +629,22 @@ function buildPreviewLoadingFailedDialog(props) {
dialog.innerHTML = '';

createTag('h1', { slot: 'heading' }, 'Preview generation failed.', { parent: dialog });
createTag('p', {}, 'Your changes have been saved. Our system is working in the background to update the page.', { parent: dialog });
createTag('p', {}, 'Our system is working in the background to update the page.', { parent: dialog });
const slackLink = createTag('a', { href: 'https://adobe.enterprise.slack.com/archives/C07KPJYA760' }, 'Slack');
const emailLink = createTag('a', { href: 'mailto:Grp-acom-milo-events-support@adobe.com' }, 'Grp-acom-milo-events-support@adobe.com');
createTag('p', {}, `Please try again later. If the issue persists, please feel free to contact us on <b>${slackLink.outerHTML}</b> or email <b>${emailLink.outerHTML}</b>`, { parent: dialog });
const buttonContainer = createTag('div', { class: 'button-container' }, '', { parent: dialog });
const seePreviewButton = createTag('sp-button', { variant: 'secondary', slot: 'button', id: 'see-preview' }, 'Go to preview page now', { parent: buttonContainer });
const cancelButton = createTag('sp-button', { variant: 'cta', slot: 'button', id: 'cancel-preview' }, 'OK', { parent: buttonContainer });

underlay.open = true;

seePreviewButton.addEventListener('click', () => {
window.open(targetHref);
closeDialog(props);
dialog.innerHTML = '';
});

cancelButton.addEventListener('click', () => {
closeDialog(props);
dialog.innerHTML = '';
Expand Down Expand Up @@ -655,12 +676,13 @@ async function getNonProdPreviewDataById(props) {

async function validatePreview(props, oldResp, cta) {
let retryCount = 0;
const previewHref = cta.href;

const currentData = { ...props.eventDataResp };
const oldData = { ...oldResp };

if (!hasContentChanged(currentData, oldData) || !Object.keys(oldData).length) {
window.open(cta.href);
window.open(previewHref);
return Promise.resolve();
}

Expand All @@ -678,12 +700,12 @@ async function validatePreview(props, oldResp, cta) {
if (metadataJson && modificationTimeMatch(metadataJson)) {
clearInterval(interval);
closeDialog(props);
window.open(cta.href);
window.open(previewHref);
resolve();
} else if (retryCount >= 30) {
} else if (!metadataJson || retryCount >= 30) {
clearInterval(interval);
buildPreviewLoadingFailedDialog(props);
window.lana?.log('Error: Failed to match metadata after 30 retries');
buildPreviewLoadingFailedDialog(props, previewHref);
window.lana?.log('Error: Failed to fetch metadata');
resolve();
}
} catch (error) {
Expand All @@ -693,16 +715,12 @@ async function validatePreview(props, oldResp, cta) {
}
}, Math.floor(Math.random() * (2000 - 1000 + 1)) + 1000);

const dialog = buildPreviewLoadingDialog(props, interval);
const poll = {
interval,
resolve,
};

if (dialog) {
const cancelButton = dialog.querySelector('#cancel-preview');
cancelButton.addEventListener('click', () => {
closeDialog(props);
if (interval) clearInterval(interval);
resolve();
});
}
buildPreviewLoadingDialog(props, previewHref, poll);
});
}

Expand Down
54 changes: 36 additions & 18 deletions ecc/blocks/form-handler/form-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ function closeDialog(props) {
if (dialog) dialog.innerHTML = '';
}

function buildPreviewLoadingDialog(props) {
function buildPreviewLoadingDialog(props, targetHref, poll) {
const spTheme = props.el.querySelector('#form-app');
if (!spTheme) return null;

Expand Down Expand Up @@ -601,14 +601,28 @@ function buildPreviewLoadingDialog(props) {
dialog.appendChild(style);
dialog.appendChild(progressBar);
const buttonContainer = createTag('div', { class: 'button-container' }, '', { parent: dialog });
createTag('sp-button', { variant: 'cta', slot: 'button', id: 'cancel-preview' }, 'Cancel', { parent: buttonContainer });
const seePreviewButton = createTag('sp-button', { variant: 'secondary', slot: 'button', id: 'see-preview' }, 'Go to preview page now', { parent: buttonContainer });
const cancelButton = createTag('sp-button', { variant: 'cta', slot: 'button', id: 'cancel-preview' }, 'Cancel', { parent: buttonContainer });

underlay.open = true;

seePreviewButton.addEventListener('click', () => {
window.open(targetHref);
closeDialog(props);
if (poll.interval) clearInterval(poll.interval);
poll.resolve();
});

cancelButton.addEventListener('click', () => {
closeDialog(props);
if (poll.interval) clearInterval(poll.interval);
poll.resolve();
});

return dialog;
}

function buildPreviewLoadingFailedDialog(props) {
function buildPreviewLoadingFailedDialog(props, targetHref) {
const spTheme = props.el.querySelector('#form-app');
if (!spTheme) return;

Expand All @@ -621,15 +635,22 @@ function buildPreviewLoadingFailedDialog(props) {
dialog.innerHTML = '';

createTag('h1', { slot: 'heading' }, 'Preview generation failed.', { parent: dialog });
createTag('p', {}, 'Your changes have been saved. Our system is working in the background to update the page.', { parent: dialog });
createTag('p', {}, 'Our system is working in the background to update the page.', { parent: dialog });
const slackLink = createTag('a', { href: 'https://adobe.enterprise.slack.com/archives/C07KPJYA760' }, 'Slack');
const emailLink = createTag('a', { href: 'mailto:Grp-acom-milo-events-support@adobe.com' }, 'Grp-acom-milo-events-support@adobe.com');
createTag('p', {}, `Please try again later. If the issue persists, please feel free to contact us on <b>${slackLink.outerHTML}</b> or email <b>${emailLink.outerHTML}</b>`, { parent: dialog });
const buttonContainer = createTag('div', { class: 'button-container' }, '', { parent: dialog });
const seePreviewButton = createTag('sp-button', { variant: 'secondary', slot: 'button', id: 'see-preview' }, 'Go to preview page now', { parent: buttonContainer });
const cancelButton = createTag('sp-button', { variant: 'cta', slot: 'button', id: 'cancel-preview' }, 'OK', { parent: buttonContainer });

underlay.open = true;

seePreviewButton.addEventListener('click', () => {
window.open(targetHref);
closeDialog(props);
dialog.innerHTML = '';
});

cancelButton.addEventListener('click', () => {
closeDialog(props);
dialog.innerHTML = '';
Expand Down Expand Up @@ -661,12 +682,13 @@ async function getNonProdPreviewDataById(props) {

async function validatePreview(props, oldResp, cta) {
let retryCount = 0;
const previewHref = cta.href;

const currentData = { ...props.eventDataResp };
const oldData = { ...oldResp };

if (!hasContentChanged(currentData, oldData) || !Object.keys(oldData).length) {
window.open(cta.href);
window.open(previewHref);
return Promise.resolve();
}

Expand All @@ -684,12 +706,12 @@ async function validatePreview(props, oldResp, cta) {
if (metadataJson && modificationTimeMatch(metadataJson)) {
clearInterval(interval);
closeDialog(props);
window.open(cta.href);
window.open(previewHref);
resolve();
} else if (retryCount >= 30) {
} else if (!metadataJson || retryCount >= 30) {
clearInterval(interval);
buildPreviewLoadingFailedDialog(props);
window.lana?.log('Error: Failed to match metadata after 30 retries');
buildPreviewLoadingFailedDialog(props, previewHref);
window.lana?.log('Error: Failed to fetch metadata');
resolve();
}
} catch (error) {
Expand All @@ -699,16 +721,12 @@ async function validatePreview(props, oldResp, cta) {
}
}, Math.floor(Math.random() * (2000 - 1000 + 1)) + 1000);

const dialog = buildPreviewLoadingDialog(props, interval);
const poll = {
interval,
resolve,
};

if (dialog) {
const cancelButton = dialog.querySelector('#cancel-preview');
cancelButton.addEventListener('click', () => {
closeDialog(props);
if (interval) clearInterval(interval);
resolve();
});
}
buildPreviewLoadingDialog(props, previewHref, poll);
});
}

Expand Down
1 change: 0 additions & 1 deletion ecc/blocks/series-creation-form/series-creation-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ function initRequiredFieldsValidation(props) {

function validatePublishFields(props) {
const publishAttributesFilled = PUBLISHABLE_ATTRS.every((attr) => props.payload[attr]);
console.log('publishAttributesFilled', publishAttributesFilled);
const publishButton = props.el.querySelector('.series-creation-form-ctas-panel .next-button');

publishButton.classList.toggle('disabled', !publishAttributesFilled);
Expand Down
6 changes: 3 additions & 3 deletions ecc/blocks/series-dashboard/series-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ function initMoreOptions(props, config, seriesObj, row) {
updateDashboardData(resp, props);

sortData(props, config, { resort: true });
showToast(props, buildToastMsgWithEventTitle(seriesObj.title, config['unpublished-msg']), { variant: 'positive' });
showToast(props, buildToastMsgWithEventTitle(seriesObj.seriesName, config['unpublished-msg']), { variant: 'positive' });
});
} else {
const pub = buildTool(toolBox, 'Publish', 'publish-rocket');
Expand All @@ -190,7 +190,7 @@ function initMoreOptions(props, config, seriesObj, row) {

sortData(props, config, { resort: true });

showToast(props, buildToastMsgWithEventTitle(seriesObj.title, config['published-msg']), { variant: 'positive' });
showToast(props, buildToastMsgWithEventTitle(seriesObj.seriesName, config['published-msg']), { variant: 'positive' });
});
}
}
Expand Down Expand Up @@ -259,7 +259,7 @@ function initMoreOptions(props, config, seriesObj, row) {
clone.addEventListener('click', async (e) => {
e.preventDefault();
const payload = { ...quickFilter(seriesObj), seriesStatus: 'draft' };
payload.title = `${seriesObj.title} - copy`;
payload.seriesName = `${seriesObj.seriesName} - copy`;
toolBox.remove();
row.classList.add('pending');
const newSeriesObj = await createSeries(payload);
Expand Down

0 comments on commit c51cf87

Please sign in to comment.