Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev -> Stage 27 Sept. 2024 #222

Merged
merged 16 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable max-len */
import { getAllEventAttendees, getEvents } from '../../scripts/esp-controller.js';
import { ALLOWED_ACCOUNT_TYPES } from '../../constants/constants.js';
import { DEV_MODE, LIBS, MILO_CONFIG } from '../../scripts/scripts.js';
import { LIBS } from '../../scripts/scripts.js';
import {
getIcon,
buildNoAccessScreen,
Expand Down Expand Up @@ -418,7 +418,6 @@ function buildBackToDashboardBtn(props, config) {
if (!sidePanel) return;

const url = new URL(`${window.location.origin}${config['event-dashboard-url']}`);
if (DEV_MODE) url.searchParams.set('devMode', true);
const backBtn = createTag('a', { class: 'back-btn', href: url.toString() }, 'Back', { parent: sidePanel });
backBtn.prepend(getIcon('chev-left'));
}
Expand Down Expand Up @@ -554,20 +553,11 @@ export default async function init(el) {
import(`${miloLibs}/features/spectrum-web-components/dist/link.js`),
]);

const { search } = window.location;
const urlParams = new URLSearchParams(search);
const devMode = urlParams.get('devMode');

const config = readBlockConfig(el);
el.innerHTML = '';
buildLoadingScreen(el);
const profile = BlockMediator.get('imsProfile');

if (devMode === 'true' && ['stage', 'local'].includes(MILO_CONFIG.env.name)) {
buildDashboard(el, config);
return;
}

if (profile) {
if (profile.noProfile || !ALLOWED_ACCOUNT_TYPES.includes(profile.account_type)) {
buildNoAccessScreen(el);
Expand Down
9 changes: 1 addition & 8 deletions ecc/blocks/ecc-dashboard/ecc-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
unpublishEvent,
} from '../../scripts/esp-controller.js';
import { ALLOWED_ACCOUNT_TYPES } from '../../constants/constants.js';
import { LIBS, MILO_CONFIG, DEV_MODE } from '../../scripts/scripts.js';
import { LIBS } from '../../scripts/scripts.js';
import { getIcon, buildNoAccessScreen, getEventPageHost, readBlockConfig } from '../../scripts/utils.js';
import { quickFilter } from '../form-handler/data-handler.js';
import BlockMediator from '../../scripts/deps/block-mediator.min.js';
Expand Down Expand Up @@ -388,7 +388,6 @@ function buildStatusTag(event) {
function buildEventTitleTag(config, eventObj) {
const url = new URL(`${window.location.origin}${config['create-form-url']}`);
url.searchParams.set('eventId', eventObj.eventId);
if (DEV_MODE) url.searchParams.set('devMode', true);
const eventTitleTag = createTag('a', { class: 'event-title-link', href: url.toString() }, eventObj.title);
return eventTitleTag;
}
Expand All @@ -407,7 +406,6 @@ function buildRSVPTag(config, eventObj) {

const url = new URL(`${window.location.origin}${config['attendee-dashboard-url']}`);
url.searchParams.set('eventId', eventObj.eventId);
if (DEV_MODE) url.searchParams.set('devMode', true);

const rsvpTag = createTag('a', { class: 'rsvp-tag', href: url }, text);
return rsvpTag;
Expand Down Expand Up @@ -709,11 +707,6 @@ export default async function init(el) {
buildLoadingScreen(el);
const profile = BlockMediator.get('imsProfile');

if (DEV_MODE === true && ['stage', 'local'].includes(MILO_CONFIG.env.name)) {
buildDashboard(el, config);
return;
}

if (profile) {
if (profile.noProfile || !ALLOWED_ACCOUNT_TYPES.includes(profile.account_type)) {
buildNoAccessScreen(el);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { LINK_REGEX } from '../../constants/constants.js';
import { LIBS } from '../../scripts/scripts.js';
import { generateToolTip } from '../../scripts/utils.js';

Expand All @@ -14,7 +15,7 @@ async function decorateFields(row) {
id: 'community-url-details',
class: 'text-input',
placeholder: text,
pattern: '^https:\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(\\/.*)?$',
pattern: LINK_REGEX,
size: 'xl',
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export default function init(component, props) {
});
}

export async function onUpdate(_component, _props) {
export async function onPayloadUpdate(_component, _props) {
// Do nothing
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export function onSubmit(component, props) {
props.payload = { ...props.payload, ...agendaInfo };
}

export async function onUpdate(_component, _props) {
export async function onPayloadUpdate(_component, _props) {
// Do nothing
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ export function onSubmit(component, props) {
}
}

export async function onUpdate(_component, _props) {
export async function onPayloadUpdate(_component, _props) {
// Do nothing
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-unused-vars */
import { getSeries } from '../../../scripts/esp-controller.js';
import { LIBS, BlockMediator } from '../../../scripts/scripts.js';
import BlockMediator from '../../../scripts/deps/block-mediator.min.js';
import { LIBS } from '../../../scripts/scripts.js';
import { changeInputValue } from '../../../scripts/utils.js';

const { createTag } = await import(`${LIBS}/utils/utils.js`);
Expand Down Expand Up @@ -52,7 +53,7 @@ function initStepLock(component) {
onFormatChange();
}

export async function onUpdate(component, props) {
export async function onPayloadUpdate(component, props) {
const { seriesId } = props.payload;
if (seriesId) {
const partnerSelectorGroups = document.querySelectorAll('partner-selector-group');
Expand All @@ -67,6 +68,10 @@ export async function onUpdate(component, props) {
}
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

async function populateSeriesOptions(props, component) {
const seriesSelect = component.querySelector('#series-select-input');
if (!seriesSelect) return;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable no-unused-vars */
/* eslint-disable no-use-before-define */
import { getEvents } from '../../../scripts/esp-controller.js';
import { BlockMediator, LIBS } from '../../../scripts/scripts.js';
import BlockMediator from '../../../scripts/deps/block-mediator.min.js';
import { LIBS } from '../../../scripts/scripts.js';
import { changeInputValue } from '../../../scripts/utils.js';

const { createTag, getConfig } = await import(`${LIBS}/utils/utils.js`);
Expand Down Expand Up @@ -342,10 +343,14 @@ export function onSubmit(component, props) {
props.payload = { ...props.payload, ...eventInfo };
}

export async function onUpdate(component, props) {
export async function onPayloadUpdate(component, props) {
// do nothing
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

function checkEventDuplication(event, compareMetrics) {
const titleMatch = event.title === compareMetrics.title;
const startDateMatch = event.localStartDate === compareMetrics.startDate;
Expand Down Expand Up @@ -376,7 +381,7 @@ export default async function init(component, props) {
BlockMediator.set('eventDupMetrics', { ...BlockMediator.get('eventDupMetrics'), title: eventTitleInput.value });
});

endTimeInput.addEventListener('change', () => {
const updateEndTimeOptions = () => {
if (datePicker.dataset.startDate !== datePicker.dataset.endDate) return;
const allOptions = startTimeInput.querySelectorAll('sp-menu-item');
allOptions.forEach((option) => {
Expand All @@ -386,9 +391,9 @@ export default async function init(component, props) {
option.disabled = false;
}
});
});
};

startTimeInput.addEventListener('change', () => {
const updateStartTimeOptions = () => {
if (datePicker.dataset.startDate !== datePicker.dataset.endDate) return;
const allOptions = endTimeInput.querySelectorAll('sp-menu-item');
allOptions.forEach((option) => {
Expand All @@ -398,9 +403,9 @@ export default async function init(component, props) {
option.disabled = false;
}
});
});
};

datePicker.addEventListener('change', () => {
const updateTimeOptionsBasedOnDate = () => {
if (datePicker.dataset.startDate !== datePicker.dataset.endDate) {
startTimeInput?.querySelectorAll('sp-menu-item')?.forEach((option) => {
option.disabled = false;
Expand All @@ -409,7 +414,13 @@ export default async function init(component, props) {
option.disabled = false;
});
}
};

endTimeInput.addEventListener('change', updateEndTimeOptions);
startTimeInput.addEventListener('change', updateStartTimeOptions);

datePicker.addEventListener('change', () => {
updateTimeOptionsBasedOnDate();
BlockMediator.set('eventDupMetrics', { ...BlockMediator.get('eventDupMetrics'), startDate: datePicker.dataset.startDate });
});

Expand Down Expand Up @@ -473,6 +484,10 @@ export default async function init(component, props) {
});
component.classList.add('prefilled');
}

updateEndTimeOptions();
updateStartTimeOptions();
updateTimeOptionsBasedOnDate();
}

export function onEventUpdate(component, props) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export async function onSubmit(component, props) {
props.payload = { ...props.payload, showSponsors };
}

export async function onUpdate(component, props) {
export async function onPayloadUpdate(component, props) {
if (!PARTNERS_SERIES_ID || PARTNERS_SERIES_ID !== props.eventDataResp.seriesId) {
const partnersGroup = component.querySelector('partner-selector-group');

Expand All @@ -108,6 +108,10 @@ export async function onUpdate(component, props) {
}
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

export default async function init(component, props) {
const eventData = props.eventDataResp;
const partnersGroup = component.querySelector('partner-selector-group');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ export function onSubmit(component, props) {
props.payload = { ...props.payload, topics, fullTopicsValue };
}

export async function onUpdate(_component, _props) {
export async function onPayloadUpdate(_component, _props) {
// Do nothing
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ function updateImgUploadComponentConfigs(component) {
component.dataset.configs = JSON.stringify(configs);
}

export async function onUpdate(component, props) {
export async function onPayloadUpdate(component, props) {
updateImgUploadComponentConfigs(component);
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

export default async function init(component, props) {
const type = getComponentImageType(component);
const dropzones = component.querySelectorAll('image-dropzone');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,14 @@ async function updateProductSelector(component, props) {
});
}

export async function onUpdate(component, props) {
export async function onPayloadUpdate(component, props) {
await updateProductSelector(component, props);
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

export default async function init(component, props) {
const eventData = props.eventDataResp;
const productGroup = component.querySelector('product-selector-group');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export async function onSubmit(component, props) {
}
}

export async function onUpdate(component, props) {
export async function onPayloadUpdate(component, props) {
const containers = component.querySelectorAll('profile-container');
containers.forEach(async (container) => {
if (props.payload.seriesId && props.payload.seriesId !== container.seriesId) {
Expand All @@ -113,6 +113,10 @@ export async function onUpdate(component, props) {
});
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

async function prefillProfiles(props) {
const d = await props.eventDataResp;
if (d?.eventId && d.seriesId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ export function onSubmit(component, props) {
props.payload = { ...props.payload, ...rsvpData };
}

export async function onUpdate(component, props) {
export async function onPayloadUpdate(component, props) {
// Do nothing
}

export async function onRespUpdate(component, props) {
if (!props.eventDataResp) return;

if (props.eventDataResp.cloudType === 'CreativeCloud') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ export function onSubmit(component, props) {
props.payload = { ...props.payload, rsvpFormFields };
}

export async function onUpdate(_component, _props) {
export async function onPayloadUpdate(_component, _props) {
// Do nothing
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
/* eslint-disable no-unused-vars */
import { ECC_ENV, LIBS } from '../../../scripts/scripts.js';
import { LIBS } from '../../../scripts/scripts.js';
import HtmlSanitizer from '../../../scripts/deps/html-sanitizer.js';
import { fetchThrottledMemoizedText, getEventPageHost } from '../../../scripts/utils.js';
import { getFilteredCachedResponse } from '../data-handler.js';
import { fetchThrottledMemoizedText, getECCEnv } from '../../../scripts/utils.js';

const { customFetch } = await import(`${LIBS}/utils/helpers.js`);
const { createTag } = await import(`${LIBS}/utils/utils.js`);

function buildTerms(terms) {
Expand Down Expand Up @@ -37,7 +35,7 @@ async function loadPreview(component, templateId) {

let host;
if (window.location.href.includes('.hlx.')) {
host = window.location.origin.replace(window.location.hostname, `${ECC_ENV}--events-milo--adobecom.hlx.page`);
host = window.location.origin.replace(window.location.hostname, `${getECCEnv()}--events-milo--adobecom.hlx.page`);
} else {
host = window.location.origin;
}
Expand All @@ -63,12 +61,16 @@ async function loadPreview(component, templateId) {
}
}

export async function onUpdate(component, props) {
export async function onPayloadUpdate(component, props) {
const { templateId } = props.payload;
if (!templateId) return;
await loadPreview(component, templateId);
}

export async function onRespUpdate(_component, _props) {
// Do nothing
}

export default async function init(component, props) {
const { templateId } = props.payload;
if (!templateId) return;
Expand Down
Loading
Loading