diff --git a/ecc/blocks/attendee-management-table/attendee-management-table.js b/ecc/blocks/attendee-management-table/attendee-management-table.js index da21c865..caa4f0c3 100644 --- a/ecc/blocks/attendee-management-table/attendee-management-table.js +++ b/ecc/blocks/attendee-management-table/attendee-management-table.js @@ -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, @@ -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')); } @@ -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); diff --git a/ecc/blocks/ecc-dashboard/ecc-dashboard.js b/ecc/blocks/ecc-dashboard/ecc-dashboard.js index bc81fe88..85a920ef 100644 --- a/ecc/blocks/ecc-dashboard/ecc-dashboard.js +++ b/ecc/blocks/ecc-dashboard/ecc-dashboard.js @@ -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'; @@ -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; } @@ -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; @@ -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); diff --git a/ecc/blocks/event-community-link-component/event-community-link-component.js b/ecc/blocks/event-community-link-component/event-community-link-component.js index 9b2c210a..02f964dc 100644 --- a/ecc/blocks/event-community-link-component/event-community-link-component.js +++ b/ecc/blocks/event-community-link-component/event-community-link-component.js @@ -1,3 +1,4 @@ +import { LINK_REGEX } from '../../constants/constants.js'; import { LIBS } from '../../scripts/scripts.js'; import { generateToolTip } from '../../scripts/utils.js'; @@ -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', }); diff --git a/ecc/blocks/form-handler/controllers/checkbox-component-controller.js b/ecc/blocks/form-handler/controllers/checkbox-component-controller.js index ff78c213..59674058 100644 --- a/ecc/blocks/form-handler/controllers/checkbox-component-controller.js +++ b/ecc/blocks/form-handler/controllers/checkbox-component-controller.js @@ -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 } diff --git a/ecc/blocks/form-handler/controllers/event-agenda-component-controller.js b/ecc/blocks/form-handler/controllers/event-agenda-component-controller.js index c3865d02..59759f2d 100644 --- a/ecc/blocks/form-handler/controllers/event-agenda-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-agenda-component-controller.js @@ -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 } diff --git a/ecc/blocks/form-handler/controllers/event-community-link-component-controller.js b/ecc/blocks/form-handler/controllers/event-community-link-component-controller.js index 77c76d85..ac54ce5b 100644 --- a/ecc/blocks/form-handler/controllers/event-community-link-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-community-link-component-controller.js @@ -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 } diff --git a/ecc/blocks/form-handler/controllers/event-format-component-controller.js b/ecc/blocks/form-handler/controllers/event-format-component-controller.js index bd527715..8ac4697c 100644 --- a/ecc/blocks/form-handler/controllers/event-format-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-format-component-controller.js @@ -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`); @@ -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'); @@ -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; diff --git a/ecc/blocks/form-handler/controllers/event-info-component-controller.js b/ecc/blocks/form-handler/controllers/event-info-component-controller.js index d7538031..b86323dd 100644 --- a/ecc/blocks/form-handler/controllers/event-info-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-info-component-controller.js @@ -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`); @@ -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; @@ -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) => { @@ -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) => { @@ -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; @@ -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 }); }); @@ -473,6 +484,10 @@ export default async function init(component, props) { }); component.classList.add('prefilled'); } + + updateEndTimeOptions(); + updateStartTimeOptions(); + updateTimeOptionsBasedOnDate(); } export function onEventUpdate(component, props) { diff --git a/ecc/blocks/form-handler/controllers/event-partners-component-controller.js b/ecc/blocks/form-handler/controllers/event-partners-component-controller.js index 1ecaa5d7..a250fdeb 100644 --- a/ecc/blocks/form-handler/controllers/event-partners-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-partners-component-controller.js @@ -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'); @@ -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'); diff --git a/ecc/blocks/form-handler/controllers/event-topics-component-controller.js b/ecc/blocks/form-handler/controllers/event-topics-component-controller.js index 1488807a..f0de27df 100644 --- a/ecc/blocks/form-handler/controllers/event-topics-component-controller.js +++ b/ecc/blocks/form-handler/controllers/event-topics-component-controller.js @@ -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 } diff --git a/ecc/blocks/form-handler/controllers/img-upload-component-controller.js b/ecc/blocks/form-handler/controllers/img-upload-component-controller.js index 1138f0e4..9b2f1c47 100644 --- a/ecc/blocks/form-handler/controllers/img-upload-component-controller.js +++ b/ecc/blocks/form-handler/controllers/img-upload-component-controller.js @@ -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'); diff --git a/ecc/blocks/form-handler/controllers/product-promotion-component-controller.js b/ecc/blocks/form-handler/controllers/product-promotion-component-controller.js index 65b5046d..ff1e3566 100644 --- a/ecc/blocks/form-handler/controllers/product-promotion-component-controller.js +++ b/ecc/blocks/form-handler/controllers/product-promotion-component-controller.js @@ -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'); diff --git a/ecc/blocks/form-handler/controllers/profile-component-controller.js b/ecc/blocks/form-handler/controllers/profile-component-controller.js index 999eb50b..fd63b307 100644 --- a/ecc/blocks/form-handler/controllers/profile-component-controller.js +++ b/ecc/blocks/form-handler/controllers/profile-component-controller.js @@ -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) { @@ -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) { diff --git a/ecc/blocks/form-handler/controllers/registration-details-component-controller.js b/ecc/blocks/form-handler/controllers/registration-details-component-controller.js index d19f3fad..cde7c625 100644 --- a/ecc/blocks/form-handler/controllers/registration-details-component-controller.js +++ b/ecc/blocks/form-handler/controllers/registration-details-component-controller.js @@ -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') { diff --git a/ecc/blocks/form-handler/controllers/registration-fields-component-controller.js b/ecc/blocks/form-handler/controllers/registration-fields-component-controller.js index 6fc20673..353d6bb5 100644 --- a/ecc/blocks/form-handler/controllers/registration-fields-component-controller.js +++ b/ecc/blocks/form-handler/controllers/registration-fields-component-controller.js @@ -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 } diff --git a/ecc/blocks/form-handler/controllers/terms-conditions-component-controller.js b/ecc/blocks/form-handler/controllers/terms-conditions-component-controller.js index ce84b020..9c9f7303 100644 --- a/ecc/blocks/form-handler/controllers/terms-conditions-component-controller.js +++ b/ecc/blocks/form-handler/controllers/terms-conditions-component-controller.js @@ -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) { @@ -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; } @@ -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; diff --git a/ecc/blocks/form-handler/controllers/venue-info-component-controller.js b/ecc/blocks/form-handler/controllers/venue-info-component-controller.js index 284d08d0..4b3a894b 100644 --- a/ecc/blocks/form-handler/controllers/venue-info-component-controller.js +++ b/ecc/blocks/form-handler/controllers/venue-info-component-controller.js @@ -1,7 +1,7 @@ /* eslint-disable no-unused-vars */ import { createVenue, replaceVenue } from '../../../scripts/esp-controller.js'; -import { BlockMediator, ECC_ENV } from '../../../scripts/scripts.js'; -import { changeInputValue, getSecret } from '../../../scripts/utils.js'; +import BlockMediator from '../../../scripts/deps/block-mediator.min.js'; +import { changeInputValue, getECCEnv, getSecret } from '../../../scripts/utils.js'; import { buildErrorMessage } from '../form-handler.js'; function togglePrefillableFieldsHiddenState(component, showPrefilledFields) { @@ -18,7 +18,7 @@ function togglePrefillableFieldsHiddenState(component, showPrefilledFields) { async function loadGoogleMapsAPI(callback) { const script = document.createElement('script'); - const apiKey = await getSecret(`${ECC_ENV}-google-places-api`); + const apiKey = await getSecret(`${getECCEnv()}-google-places-api`); script.src = `https://maps.googleapis.com/maps/api/js?key=${apiKey}&libraries=places&callback=onGoogleMapsApiLoaded`; script.async = true; script.defer = true; @@ -112,10 +112,14 @@ export async function onSubmit(component, props) { // do nothing. Depend on eventUpdated event. } -export async function onUpdate(component, props) { +export async function onPayloadUpdate(component, props) { // do nothing } +export async function onRespUpdate(_component, _props) { + // Do nothing +} + export default async function init(component, props) { const eventData = props.eventDataResp; diff --git a/ecc/blocks/form-handler/form-handler.js b/ecc/blocks/form-handler/form-handler.js index 972d3632..9ff3c8a4 100644 --- a/ecc/blocks/form-handler/form-handler.js +++ b/ecc/blocks/form-handler/form-handler.js @@ -1,5 +1,5 @@ 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, @@ -294,14 +294,31 @@ async function handleEventUpdate(props) { await Promise.all(allComponentPromises); } -async function updateComponents(props) { +async function updateComponentsOnPayloadChange(props) { const allComponentPromises = VANILLA_COMPONENTS.map(async (comp) => { const mappedComponents = props.el.querySelectorAll(`.${comp}-component`); if (!mappedComponents.length) return {}; const promises = Array.from(mappedComponents).map(async (component) => { - const { onUpdate } = await import(`./controllers/${comp}-component-controller.js`); - const componentPayload = await onUpdate(component, props); + const { onPayloadUpdate } = await import(`./controllers/${comp}-component-controller.js`); + const componentPayload = await onPayloadUpdate(component, props); + return componentPayload; + }); + + return Promise.all(promises); + }); + + await Promise.all(allComponentPromises); +} + +async function updateComponentsOnRespChange(props) { + const allComponentPromises = VANILLA_COMPONENTS.map(async (comp) => { + const mappedComponents = props.el.querySelectorAll(`.${comp}-component`); + if (!mappedComponents.length) return {}; + + const promises = Array.from(mappedComponents).map(async (component) => { + const { onRespUpdate } = await import(`./controllers/${comp}-component-controller.js`); + const componentPayload = await onRespUpdate(component, props); return componentPayload; }); @@ -760,13 +777,14 @@ async function buildECCForm(el) { case 'payload': { setPayloadCache(value); - updateComponents(target); + updateComponentsOnPayloadChange(target); initRequiredFieldsValidation(target); break; } case 'eventDataResp': { setResponseCache(value); + updateComponentsOnRespChange(target); updateCtas(target); if (value.error) { props.el.classList.add('show-error'); @@ -841,13 +859,6 @@ export default async function init(el) { const profile = BlockMediator.get('imsProfile'); - if (DEV_MODE === true && ['stage', 'local'].includes(MILO_CONFIG.env.name)) { - buildECCForm(el).then(() => { - el.classList.remove('loading'); - }); - return; - } - if (profile) { if (profile.noProfile || !ALLOWED_ACCOUNT_TYPES.includes(profile.account_type)) { buildNoAccessScreen(el); diff --git a/ecc/blocks/img-upload-component/img-upload-component.css b/ecc/blocks/img-upload-component/img-upload-component.css index b4ca214a..ecd11b52 100644 --- a/ecc/blocks/img-upload-component/img-upload-component.css +++ b/ecc/blocks/img-upload-component/img-upload-component.css @@ -97,6 +97,10 @@ top: 0; } +.img-upload-component .progress-wrapper.hidden { + display: none; +} + @media (min-width: 900px) { .img-upload-component .image-dropzones { grid-template-columns: 1fr 1fr 1fr; diff --git a/ecc/components/profile-container/profile-container.js b/ecc/components/profile-container/profile-container.js index eba817cb..4e6a3449 100644 --- a/ecc/components/profile-container/profile-container.js +++ b/ecc/components/profile-container/profile-container.js @@ -45,7 +45,7 @@ export class ProfileContainer extends LitElement { } isValidSpeaker(profile) { - return profile.firstName && profile.lastName && profile.title && profile.bio; + return profile.firstName && profile.lastName && profile.title; } getProfiles() { diff --git a/ecc/components/profile/profile.js b/ecc/components/profile/profile.js index cb814a9d..28090e31 100644 --- a/ecc/components/profile/profile.js +++ b/ecc/components/profile/profile.js @@ -169,7 +169,7 @@ export class Profile extends LitElement { saveDisabled() { // eslint-disable-next-line max-len - return !this.profile.firstName || !this.profile.lastName || !this.profile.title || !this.profile.bio; + return !this.profile.firstName || !this.profile.lastName || !this.profile.title; } renderNameFieldWithSearchIntegrated() { @@ -269,7 +269,7 @@ export class Profile extends LitElement { }; const bioData = { - value: this.profile?.bio, + value: this.profile?.bio ?? '', placeholder: fieldLabelsJSON.bio, helperText: fieldLabelsJSON.bioSubText, }; @@ -397,7 +397,7 @@ export class Profile extends LitElement { : nothing}
${this.profile.title}
-

${this.profile.bio}

+ ${this.profile.bio ? html`

${this.profile.bio}

` : nothing}
${this.profile?.socialMedia?.length ? html`
diff --git a/ecc/icons/icons.svg.js b/ecc/icons/icons.svg.js index 97d9713e..b7ca471e 100644 --- a/ecc/icons/icons.svg.js +++ b/ecc/icons/icons.svg.js @@ -57,6 +57,12 @@ export const icons = svg` + + Tiktok + Tiktok Logo + + + diff --git a/ecc/scripts/esp-controller.js b/ecc/scripts/esp-controller.js index dbc25b44..8331a0e2 100644 --- a/ecc/scripts/esp-controller.js +++ b/ecc/scripts/esp-controller.js @@ -1,4 +1,4 @@ -import { ECC_ENV } from './scripts.js'; +import { getECCEnv } from './utils.js'; export const getCaasTags = (() => { let cache; @@ -62,12 +62,16 @@ function waitForAdobeIMS() { }); } -async function constructRequestOptions(method, body = null) { +export async function constructRequestOptions(method, body = null) { await waitForAdobeIMS(); const headers = new Headers(); const authToken = window.adobeIMS?.getAccessToken()?.token; + + if (!authToken) window.lana?.log('Error: Failed to get Adobe IMS auth token'); + headers.append('Authorization', `Bearer ${authToken}`); + headers.append('x-api-key', 'acom_event_service'); headers.append('content-type', 'application/json'); const options = { @@ -83,7 +87,7 @@ async function constructRequestOptions(method, body = null) { export async function uploadImage(file, configs, tracker, imageId = null) { await waitForAdobeIMS(); - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const authToken = window.adobeIMS?.getAccessToken()?.token; let respJson = null; @@ -96,6 +100,7 @@ export async function uploadImage(file, configs, tracker, imageId = null) { xhr.open(method, url); xhr.setRequestHeader('x-image-alt-text', configs.altText || ''); xhr.setRequestHeader('x-image-kind', configs.type); + xhr.setRequestHeader('x-api-key', 'acom_event_service'); xhr.setRequestHeader('Authorization', `Bearer ${authToken}`); if (tracker) { @@ -172,7 +177,7 @@ function convertToSpeaker(speaker) { export async function deleteImage(configs, imageId) { await waitForAdobeIMS(); - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('DELETE'); try { @@ -193,7 +198,7 @@ export async function deleteImage(configs, imageId) { } export async function createVenue(eventId, venueData) { - const { host } = getAPIConfig().esl[ECC_ENV]; + const { host } = getAPIConfig().esl[getECCEnv()]; const raw = JSON.stringify(venueData); const options = await constructRequestOptions('POST', raw); @@ -214,7 +219,7 @@ export async function createVenue(eventId, venueData) { } export async function replaceVenue(eventId, venueId, venueData) { - const { host } = getAPIConfig().esl[ECC_ENV]; + const { host } = getAPIConfig().esl[getECCEnv()]; const raw = JSON.stringify(venueData); const options = await constructRequestOptions('PUT', raw); @@ -235,7 +240,7 @@ export async function replaceVenue(eventId, venueId, venueData) { } export async function createEvent(payload) { - const { host } = getAPIConfig().esl[ECC_ENV]; + const { host } = getAPIConfig().esl[getECCEnv()]; const raw = JSON.stringify({ ...payload, liveUpdate: false }); const options = await constructRequestOptions('POST', raw); @@ -258,7 +263,7 @@ export async function createEvent(payload) { export async function createSpeaker(profile, seriesId) { const nSpeaker = convertToNSpeaker(profile); - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify({ ...nSpeaker, seriesId }); const options = await constructRequestOptions('POST', raw); @@ -279,7 +284,7 @@ export async function createSpeaker(profile, seriesId) { } export async function createSponsor(sponsorData, seriesId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify(sponsorData); const options = await constructRequestOptions('POST', raw); @@ -300,7 +305,7 @@ export async function createSponsor(sponsorData, seriesId) { } export async function updateSponsor(sponsorData, sponsorId, seriesId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify(sponsorData); const options = await constructRequestOptions('PUT', raw); @@ -321,7 +326,7 @@ export async function updateSponsor(sponsorData, sponsorId, seriesId) { } export async function addSponsorToEvent(sponsorData, eventId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify(sponsorData); const options = await constructRequestOptions('POST', raw); @@ -342,7 +347,7 @@ export async function addSponsorToEvent(sponsorData, eventId) { } export async function updateSponsorInEvent(sponsorData, sponsorId, eventId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify(sponsorData); const options = await constructRequestOptions('PUT', raw); @@ -363,7 +368,7 @@ export async function updateSponsorInEvent(sponsorData, sponsorId, eventId) { } export async function removeSponsorFromEvent(sponsorId, eventId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('DELETE'); try { @@ -383,7 +388,7 @@ export async function removeSponsorFromEvent(sponsorId, eventId) { } export async function getSponsor(seriesId, sponsorId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -403,7 +408,7 @@ export async function getSponsor(seriesId, sponsorId) { } export async function getSponsors(seriesId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -423,7 +428,7 @@ export async function getSponsors(seriesId) { } export async function getSponsorImages(seriesId, sponsorId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -443,7 +448,7 @@ export async function getSponsorImages(seriesId, sponsorId) { } export async function addSpeakerToEvent(speakerData, eventId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify(speakerData); const options = await constructRequestOptions('POST', raw); @@ -464,7 +469,7 @@ export async function addSpeakerToEvent(speakerData, eventId) { } export async function updateSpeakerInEvent(speakerData, speakerId, eventId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify(speakerData); const options = await constructRequestOptions('PUT', raw); @@ -485,7 +490,7 @@ export async function updateSpeakerInEvent(speakerData, speakerId, eventId) { } export async function removeSpeakerFromEvent(speakerId, eventId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('DELETE'); try { @@ -506,7 +511,7 @@ export async function removeSpeakerFromEvent(speakerId, eventId) { export async function updateSpeaker(profile, seriesId) { const nSpeaker = convertToNSpeaker(profile); - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify({ ...nSpeaker, seriesId }); const options = await constructRequestOptions('PUT', raw); @@ -527,7 +532,7 @@ export async function updateSpeaker(profile, seriesId) { } export async function updateEvent(eventId, payload) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify({ ...payload, liveUpdate: false }); const options = await constructRequestOptions('PUT', raw); @@ -548,7 +553,7 @@ export async function updateEvent(eventId, payload) { } export async function publishEvent(eventId, payload) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify({ ...payload, published: true, liveUpdate: true }); const options = await constructRequestOptions('PUT', raw); @@ -569,7 +574,7 @@ export async function publishEvent(eventId, payload) { } export async function unpublishEvent(eventId, payload) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify({ ...payload, published: false, liveUpdate: true }); const options = await constructRequestOptions('PUT', raw); @@ -590,7 +595,7 @@ export async function unpublishEvent(eventId, payload) { } export async function deleteEvent(eventId) { - const { host } = getAPIConfig().esl[ECC_ENV]; + const { host } = getAPIConfig().esl[getECCEnv()]; const options = await constructRequestOptions('DELETE'); try { @@ -611,7 +616,7 @@ export async function deleteEvent(eventId) { } export async function getEvents() { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -631,7 +636,7 @@ export async function getEvents() { } export async function getEvent(eventId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -651,7 +656,7 @@ export async function getEvent(eventId) { } export async function getVenue(eventId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -671,7 +676,7 @@ export async function getVenue(eventId) { } export async function getSpeaker(seriesId, speakerId) { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -703,7 +708,7 @@ export async function getClouds() { } export async function getSeries() { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -725,7 +730,7 @@ export async function getSeries() { export async function createAttendee(eventId, attendeeData) { if (!eventId || !attendeeData) return false; - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify(attendeeData); const options = await constructRequestOptions('POST', raw); @@ -748,7 +753,7 @@ export async function createAttendee(eventId, attendeeData) { export async function updateAttendee(eventId, attendeeId, attendeeData) { if (!eventId || !attendeeData) return false; - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const raw = JSON.stringify(attendeeData); const options = await constructRequestOptions('PUT', raw); @@ -771,7 +776,7 @@ export async function updateAttendee(eventId, attendeeId, attendeeData) { export async function deleteAttendee(eventId, attendeeId) { if (!eventId || !attendeeId) return false; - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('DELETE'); try { @@ -793,7 +798,7 @@ export async function deleteAttendee(eventId, attendeeId) { export async function getEventAttendees(eventId) { if (!eventId) return false; - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -814,7 +819,7 @@ export async function getEventAttendees(eventId) { export async function getAllEventAttendees(eventId) { const recurGetAttendees = async (fullAttendeeArr = [], nextPageToken = null) => { - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); const fetchUrl = nextPageToken ? `${host}/v1/events/${eventId}/attendees?nextPageToken=${nextPageToken}` : `${host}/v1/events/${eventId}/attendees`; @@ -846,7 +851,7 @@ export async function getAllEventAttendees(eventId) { export async function getAttendee(eventId, attendeeId) { if (!eventId || !attendeeId) return false; - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -868,7 +873,7 @@ export async function getAttendee(eventId, attendeeId) { export async function getSpeakers(seriesId) { if (!seriesId) return false; - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -890,7 +895,7 @@ export async function getSpeakers(seriesId) { export async function getEventImages(eventId) { if (!eventId) return false; - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('GET'); try { @@ -912,7 +917,7 @@ export async function getEventImages(eventId) { export async function deleteSpeakerImage(speakerId, seriesId, imageId) { if (!speakerId || !seriesId || !imageId) return false; - const { host } = getAPIConfig().esp[ECC_ENV]; + const { host } = getAPIConfig().esp[getECCEnv()]; const options = await constructRequestOptions('DELETE'); try { diff --git a/ecc/scripts/scripts.js b/ecc/scripts/scripts.js index e8b8866e..5714e828 100644 --- a/ecc/scripts/scripts.js +++ b/ecc/scripts/scripts.js @@ -75,27 +75,6 @@ export function decorateArea(area = document) { }); } -function getECCEnv(miloConfig) { - const { env } = miloConfig; - - if (env.name === 'prod') return 'prod'; - - if (env.name === 'stage') { - const { host, search } = window.location; - const usp = new URLSearchParams(search); - const eccEnv = usp.get('eccEnv'); - - if (eccEnv) return eccEnv; - - if (host.startsWith('main--')) return 'prod'; - if (host.startsWith('stage--') || host.startsWith('www.stage')) return 'stage'; - if (host.startsWith('dev--') || host.startsWith('www.dev')) return 'dev'; - } - - // fallback to dev - return 'dev'; -} - const locales = { '': { ietf: 'en-US', tk: 'jdq5hay.css' }, br: { ietf: 'pt-BR', tk: 'inq1xob.css' }, @@ -151,8 +130,6 @@ export const LIBS = (() => { return branch.includes('--') ? `https://${branch}.hlx.live/libs` : `https://${branch}--milo--adobecom.hlx.live/libs`; })(); -export const BlockMediator = await import('./deps/block-mediator.min.js').then((mod) => mod.default); - (function loadStyles() { const paths = [`${LIBS}/styles/styles.css`]; if (STYLES) { paths.push(STYLES); } @@ -164,12 +141,9 @@ export const BlockMediator = await import('./deps/block-mediator.min.js').then(( }); }()); -const { loadArea, setConfig, loadLana } = await import(`${LIBS}/utils/utils.js`); -export const MILO_CONFIG = setConfig({ ...CONFIG, miloLibs: LIBS }); -export const ECC_ENV = getECCEnv(MILO_CONFIG); -export const DEV_MODE = new URLSearchParams(window.location.search).has('devMode'); - (async function loadPage() { + const { loadArea, setConfig, loadLana } = await import(`${LIBS}/utils/utils.js`); + setConfig({ ...CONFIG, miloLibs: LIBS }); await loadLana({ clientId: 'ecc-milo' }); await loadArea().then(() => { lazyCaptureProfile(); diff --git a/ecc/scripts/utils.js b/ecc/scripts/utils.js index 01744da4..908ded19 100644 --- a/ecc/scripts/utils.js +++ b/ecc/scripts/utils.js @@ -1,13 +1,36 @@ -import { MILO_CONFIG, LIBS, ECC_ENV } from './scripts.js'; +import { LIBS } from './scripts.js'; -const { createTag } = await import(`${LIBS}/utils/utils.js`); +const { createTag, getConfig } = await import(`${LIBS}/utils/utils.js`); let secretCache = []; +export function getECCEnv() { + const validEnvs = ['dev', 'stage', 'prod']; + const { host, search } = window.location; + const SLD = host.includes('.aem.') ? 'aem' : 'hlx'; + const usp = new URLSearchParams(search); + const eccEnv = usp.get('eccEnv'); + + if (validEnvs.includes(eccEnv)) return eccEnv; + + if (((host.includes(`${SLD}.page`) || host.includes(`${SLD}.live`)) && host.startsWith('dev--')) + || host.includes('localhost')) return 'dev'; + + if (((host.includes(`${SLD}.page`) || host.includes(`${SLD}.live`)) && host.startsWith('stage--')) + || host.includes('stage.adobe') + || host.includes('corp.adobe') + || host.includes('graybox.adobe')) return 'stage'; + + if (((host.includes(`${SLD}.page`) || host.includes(`${SLD}.live`)) && host.startsWith('main--')) || host.endsWith === 'adobe.com') return 'prod'; + + // fallback to dev + return 'dev'; +} + export function getIcon(tag) { const img = document.createElement('img'); img.className = `icon icon-${tag}`; - img.src = `${MILO_CONFIG.codeRoot}/icons/${tag}.svg`; + img.src = `${getConfig().codeRoot}/icons/${tag}.svg`; img.alt = tag; return img; @@ -47,7 +70,7 @@ export function convertTo24HourFormat(timeStr) { if (period === 'PM' && hours !== 12) { hours += 12; } else if (period === 'AM' && hours === 12) { - hours = 24; + hours = 0; } const formattedHours = hours.toString().padStart(2, '0'); @@ -58,7 +81,7 @@ export function convertTo24HourFormat(timeStr) { export function getEventPageHost() { if (window.location.href.includes('.hlx.')) { - return window.location.origin.replace(window.location.hostname, `${ECC_ENV}--events-milo--adobecom.hlx.page`); + return window.location.origin.replace(window.location.hostname, `${getECCEnv()}--events-milo--adobecom.hlx.page`); } return window.location.origin; @@ -232,12 +255,8 @@ export function getServiceName(link) { export async function miloReplaceKey(key) { try { - const [utils, placeholders] = await Promise.all([ - import(`${LIBS}/utils/utils.js`), - import(`${LIBS}/features/placeholders.js`), - ]); + const placeholders = await import(`${LIBS}/features/placeholders.js`); - const { getConfig } = utils; const { replaceKey } = placeholders; const config = getConfig(); diff --git a/ecc/styles/styles.css b/ecc/styles/styles.css index ad0dcc00..5f5a1b9d 100644 --- a/ecc/styles/styles.css +++ b/ecc/styles/styles.css @@ -14,7 +14,7 @@ --spectrum-color-gray-400: #A1A1A1; --spectrum-color-gray-500: #909090; --spectrum-color-gray-600: #686868; - --spectrum-color-gray-700: #444444; + --spectrum-color-gray-700: #444; --spectrum-color-gray-800: #242424; --spectrum-color-text: #2C2C2C; }