Skip to content

Commit

Permalink
Merge branch 'main' of github.com:adobe/assets-distribution-portal
Browse files Browse the repository at this point in the history
  • Loading branch information
synox committed Dec 1, 2023
2 parents 7a78ad3 + 34aae7b commit 58fc064
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions scripts/card-html-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function createCardElement(

const card = document.createElement('div');
card.classList.add(`filetype-${fileType}`);
card.setAttribute('data-item-name', name);

card.innerHTML = `
<div class="preview preview-${toClassName(getFileType(mimeType))}">
Expand Down
23 changes: 20 additions & 3 deletions scripts/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { waitForDependency, logError } from './scripts.js';

let ccEverywhere;
const adminConfig = await getAdminConfig();
const userProfile = await getUserProfile();

function buildHostInfo(clientId, appName) {
const hostInfo = {
Expand Down Expand Up @@ -153,17 +154,33 @@ function isCCESupported() {
}

export function isCCEConfigured() {
return isCCESupported() && (adminConfig.adobeExpressClientId !== undefined) && (adminConfig.adobeExpressAppName !== undefined);
return isCCESupported() && hasEntitlement() && (adminConfig.adobeExpressClientId !== undefined)
&& (adminConfig.adobeExpressAppName !== undefined);
}

export function isCCEInitialized() {
return (ccEverywhere !== undefined);
}

function hasEntitlement() {
let sparkCtx;
const productContext = userProfile.projectedProductContext;

productContext.forEach((context) => {
if (context.prodCtx.serviceCode === 'spark') {
sparkCtx = context.prodCtx;
}
});

if (!(sparkCtx === undefined) && (sparkCtx.statusCode === 'ACTIVE')) {
return true;
}
return false;
}

export async function startCCE() {
if (isCCESupported()) {
// create static config objects
// todo check if clientid and appname values are null/missing
const clientId = adminConfig.adobeExpressClientId;
const appName = adminConfig.adobeExpressAppName;

Expand Down Expand Up @@ -206,7 +223,7 @@ export async function openInExpress(base64Blob, assetHeight, assetWidth, assetTy
await window.adobeIMS?.refreshToken();
await startCCE();
}
// todo fix video

const userInfo = await buildUserInfo();
const authInfo = await buildAuthInfo();
ccEverywhere.createDesign({
Expand Down

0 comments on commit 58fc064

Please sign in to comment.