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

Kodiak Fixes Round 2 #367

Merged
merged 11 commits into from
Feb 18, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ export default async function init(el) {
buildLoadingScreen(el);

const devToken = getLocalDevToken();
if (devToken && ['local', 'dev'].includes(getEventServiceEnv())) {
if (devToken && getEventServiceEnv() === 'dev') {
buildDashboard(el, config);
return;
}
Expand Down
9 changes: 7 additions & 2 deletions ecc/blocks/cmc/cmc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { LIBS } from '../../scripts/scripts.js';
import { getCaasTags, getClouds } from '../../scripts/esp-controller.js';
import {
buildNoAccessScreen, generateToolTip, getLocalDevToken, getEventServiceEnv, readBlockConfig, signIn,
buildNoAccessScreen,
generateToolTip,
getLocalDevToken,
getEventServiceEnv,
readBlockConfig,
signIn,
} from '../../scripts/utils.js';
import CloudManagementConsole from '../../components/cmc/cmc.js';
import { initProfileLogicTree } from '../../scripts/profile.js';
Expand Down Expand Up @@ -94,7 +99,7 @@ export default async function init(el) {
const loadingScreen = buildLoadingScreen(el);

const devToken = getLocalDevToken();
if (devToken && ['local', 'dev'].includes(getEventServiceEnv())) {
if (devToken && getEventServiceEnv() === 'dev') {
buildCMC(el, blockConfig);
loadingScreen.remove();
return;
Expand Down
12 changes: 4 additions & 8 deletions ecc/blocks/ecc-dashboard/ecc-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,11 @@ function buildThumbnail(data) {
const heroImage = images.find((photo) => photo.imageKind === 'event-hero-image');
const venueImage = images.find((photo) => photo.imageKind === 'venue-image');

// TODO: remove after no more adobe.com images
const imgSrc = (cardImage?.sharepointUrl
&& `${getEventPageHost()}${cardImage?.sharepointUrl.replace('https://www.adobe.com', '')}`)
const imgSrc = cardImage?.sharepointUrl
|| cardImage?.imageUrl
|| (heroImage?.sharepointUrl
&& `${getEventPageHost()}${heroImage?.sharepointUrl.replace('https://www.adobe.com', '')}`)
|| heroImage?.sharepointUrl
|| heroImage?.imageUrl
|| (venueImage?.sharepointUrl
&& `${getEventPageHost()}${venueImage?.sharepointUrl.replace('https://www.adobe.com', '')}`)
|| venueImage?.sharepointUrl
|| venueImage?.imageUrl
|| images[0]?.imageUrl;

Expand Down Expand Up @@ -791,7 +787,7 @@ export default async function init(el) {
buildLoadingScreen(el);

const devToken = getLocalDevToken();
if (devToken && ['local', 'dev'].includes(getEventServiceEnv())) {
if (devToken && getEventServiceEnv() === 'dev') {
buildDashboard(el, config);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion ecc/blocks/form-handler/form-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ export default async function init(el) {
]);

const devToken = getLocalDevToken();
if (devToken && ['local', 'dev'].includes(getEventServiceEnv())) {
if (devToken && getEventServiceEnv() === 'dev') {
buildECCForm(el).then(() => {
el.classList.remove('loading');
});
Expand Down
2 changes: 1 addition & 1 deletion ecc/blocks/series-creation-form/series-creation-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ export default async function init(el) {
]);

const devToken = getLocalDevToken();
if (devToken && ['local', 'dev'].includes(getEventServiceEnv())) {
if (devToken && getEventServiceEnv() === 'dev') {
buildForm(el).then(() => {
el.classList.remove('loading');
});
Expand Down
2 changes: 1 addition & 1 deletion ecc/blocks/series-dashboard/series-dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ export default async function init(el) {
buildLoadingScreen(el);

const devToken = getLocalDevToken();
if (devToken && ['local', 'dev'].includes(getEventServiceEnv())) {
if (devToken && getEventServiceEnv() === 'dev') {
buildDashboard(el, config);
return;
}
Expand Down
11 changes: 9 additions & 2 deletions ecc/blocks/venue-info-component/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@ function togglePrefillableFieldsHiddenState(component) {
}

async function loadGoogleMapsAPI(callback) {
const secretEnv = ['local', 'dev'].includes(getEventServiceEnv()) ? 'dev' : getEventServiceEnv();
const ALLOWED_ENVS = new Set(['dev', 'stage', 'prod']);

const currentEnv = getEventServiceEnv();

if (!ALLOWED_ENVS.has(currentEnv)) {
throw new Error('Invalid environment detected.');
}

const script = document.createElement('script');
const apiKey = await getSecret(`${secretEnv}-google-places-api`);
const apiKey = await getSecret(`${currentEnv}-google-places-api`);
script.src = `https://maps.googleapis.com/maps/api/js?loading=async&key=${apiKey}&libraries=places&callback=onGoogleMapsApiLoaded`;
script.async = true;
script.defer = true;
Expand Down
2 changes: 1 addition & 1 deletion ecc/components/partner-selector/partner-selector.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LIBS } from '../../scripts/scripts.js';
import { style } from './partner-selector.css.js';
import { createSponsor, deleteImage, updateSponsor, uploadImage } from '../../scripts/esp-controller.js';
import { LINK_REGEX } from '../../constants/constants.js';
import { LINK_REGEX } from '../../scripts/constants.js';

const { LitElement, html } = await import(`${LIBS}/deps/lit-all.min.js`);

Expand Down
2 changes: 1 addition & 1 deletion ecc/components/profile/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { style } from './profile.css.js';
import { createSpeaker, deleteSpeakerImage, updateSpeaker, uploadImage } from '../../scripts/esp-controller.js';
import { getServiceName } from '../../scripts/utils.js';
import { icons } from '../../icons/icons.svg.js';
import { LINK_REGEX } from '../../constants/constants.js';
import { LINK_REGEX } from '../../scripts/constants.js';

const { LitElement, html, repeat, nothing } = await import(`${LIBS}/deps/lit-all.min.js`);

Expand Down
3 changes: 0 additions & 3 deletions ecc/constants/constants.js

This file was deleted.

2 changes: 1 addition & 1 deletion ecc/samples/sample-form/sample-form.sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ export default async function init(el) {
]);

const devToken = getLocalDevToken();
if (devToken && ['local', 'dev'].includes(getEventServiceEnv())) {
if (devToken && getEventServiceEnv() === 'dev') {
buildForm(el).then(() => {
el.classList.remove('loading');
});
Expand Down
41 changes: 41 additions & 0 deletions ecc/scripts/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export const LINK_REGEX = '^https:\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,63}(:[0-9]{1,5})?(\\/.*)?$';
export const ALLOWED_ACCOUNT_TYPES = ['type3', 'type2e'];
export const SUPPORTED_CLOUDS = [{ id: 'CreativeCloud', name: 'Creative Cloud' }, { id: 'ExperienceCloud', name: 'Experience Cloud' }];
export const API_CONFIG = {
esl: {
local: { host: 'http://localhost:8499' },
dev: { host: 'https://wcms-events-service-layer-deploy-ethos102-stage-va-9c3ecd.stage.cloud.adobe.io' },
dev02: { host: 'https://wcms-events-service-layer-deploy-ethos102-stage-va-d5dc93.stage.cloud.adobe.io' },
stage: { host: 'https://events-service-layer-stage.adobe.io' },
stage02: { host: 'https://wcms-events-service-layer-deploy-ethos105-stage-or-8f7ce1.stage.cloud.adobe.io' },
prod: { host: 'https://events-service-layer.adobe.io' },
},
esp: {
local: { host: 'http://localhost:8500' },
dev: { host: 'https://wcms-events-service-platform-deploy-ethos102-stage-caff5f.stage.cloud.adobe.io' },
dev02: { host: 'https://wcms-events-service-platform-deploy-ethos102-stage-c81eb6.stage.cloud.adobe.io' },
stage: { host: 'https://events-service-platform-stage-or2.adobe.io' },
stage02: { host: 'https://wcms-events-service-platform-deploy-ethos105-stage-9a5fdc.stage.cloud.adobe.io' },
prod: { host: 'https://events-service-platform.adobe.io' },
},
};
export const ALLOWED_HOSTS = {
localhost: true,
'events-service-layer.adobe.io': true,
'events-service-layer-stage.adobe.io': true,
'events-service-platform.adobe.io': true,
'events-service-platform-stage-or2.adobe.io': true,
'www.adobe.com': true,
'www.stage.adobe.com': true,

...Object.values(API_CONFIG.esl).reduce((acc, env) => {
const url = new URL(env.host);
acc[url.hostname] = true;
return acc;
}, {}),
...Object.values(API_CONFIG.esp).reduce((acc, env) => {
const url = new URL(env.host);
acc[url.hostname] = true;
return acc;
}, {}),
};
Loading