From d876a814ab4a789caeb8a6b1b53f22fd72b5e9a9 Mon Sep 17 00:00:00 2001 From: Ruchika Sinha <69535463+Ruchika4@users.noreply.github.com> Date: Tue, 23 Jan 2024 21:02:54 -0800 Subject: [PATCH 1/3] Update firefly-susi.js --- .../features/firefly/firefly-susi.js | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/creativecloud/features/firefly/firefly-susi.js b/creativecloud/features/firefly/firefly-susi.js index d8b53065e..fe90ca72a 100644 --- a/creativecloud/features/firefly/firefly-susi.js +++ b/creativecloud/features/firefly/firefly-susi.js @@ -10,31 +10,25 @@ function generateRandomSeed(min = 1, max = 100000) { return Math.floor(Math.random() * (max - min + 1)) + min; } -export function redirectWithParam() { - const url = new URL(window.location.href); - let prompt; +function redirectUrl(prompt, paramKey) { let windowLocation = ''; const queryParam = 'ff_channel=adobe_com&ff_campaign=ffly_homepage&ff_source=firefly_seo'; - if (window.location.search.includes('goToFireflyGenFill')) { + if (paramKey === 'goToFireflyGenFill') { windowLocation = env === 'prod' ? `${fireflyprod}/upload/inpaint?${queryParam}` : `${fireflystage}/upload/inpaint?&${queryParam}`; - } else if (window.location.search.includes('goToFireflyEffects')) { - prompt = url.searchParams.get('goToFireflyEffects'); - const effectsPath = `generate/font-styles?prompt=${prompt}&${queryParam}`; + } else if (paramKey === 'goToFireflyEffects') { + const effectsPath = `generate/font-styles?prompt=${encodeURI(prompt)}&${queryParam}`; windowLocation = env === 'prod' ? `${fireflyprod}/${effectsPath}` : `${fireflystage}/${effectsPath}`; - } else if (window.location.search.includes('goToFirefly')) { - prompt = url.searchParams.get('goToFirefly'); - const fireflyPath = `generate/images?prompt=${prompt}&${queryParam}&seed=${generateRandomSeed()}&seed=${generateRandomSeed()}&seed=${generateRandomSeed()}&seed=${generateRandomSeed()}&modelInputVersion=v2&modelConfig=v2`; + } else if (paramKey === 'goToFirefly') { + const fireflyPath = `generate/images?prompt=${encodeURI(prompt)}&${queryParam}&seed=${generateRandomSeed()}&seed=${generateRandomSeed()}&seed=${generateRandomSeed()}&seed=${generateRandomSeed()}&modelInputVersion=v2&modelConfig=v2`; windowLocation = env === 'prod' ? `${fireflyprod}/${fireflyPath}` : `${fireflystage}/${fireflyPath}`; } - if (windowLocation) window.location = windowLocation; + return windowLocation; } -export const signIn = (prompt, paramKey) => { - const url = new URL(window.location.href); - url.searchParams.delete('goToFirefly', 'goToFireflyEffects', 'goToFireflyGenFill', 'prompt', 'seed', 'ff_channel', 'ff_campaign', 'ff_source'); - url.searchParams.set(paramKey, encodeURI(prompt)); - const stageSigninObj = { dctx_id: 'v:2,s,f,bg:firefly2023,2e2b3d80-4e50-11ee-acbc-ab67eaa89524', redirect_uri: url.href }; - const prodSigninObj = { dctx_id: 'v:2,s,f,bg:firefly2023,cea19bc0-4e72-11ee-888a-c95a795c7f23', redirect_uri: url.href }; +export default function signIn(prompt, paramKey) { + const redirectUri = redirectUrl(prompt, paramKey); + const stageSigninObj = { dctx_id: 'v:2,s,f,bg:firefly2023,2e2b3d80-4e50-11ee-acbc-ab67eaa89524', redirect_uri: redirectUri }; + const prodSigninObj = { dctx_id: 'v:2,s,f,bg:firefly2023,cea19bc0-4e72-11ee-888a-c95a795c7f23', redirect_uri: redirectUri }; if (env === 'stage') window.adobeIMS?.signIn(stageSigninObj); else window.adobeIMS?.signIn(prodSigninObj); -}; +} From 9c9d239a843e9c622e12b4a937bcc444eb85c8bd Mon Sep 17 00:00:00 2001 From: Ruchika Sinha <69535463+Ruchika4@users.noreply.github.com> Date: Tue, 23 Jan 2024 21:03:47 -0800 Subject: [PATCH 2/3] Update scripts.js --- creativecloud/scripts/scripts.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/creativecloud/scripts/scripts.js b/creativecloud/scripts/scripts.js index cdc35e12a..ef1f39c58 100644 --- a/creativecloud/scripts/scripts.js +++ b/creativecloud/scripts/scripts.js @@ -186,17 +186,8 @@ const miloLibs = setLibs(LIBS); }()); (async function loadPage() { - const { loadArea, setConfig, loadLana, loadIms } = await import(`${miloLibs}/utils/utils.js`); + const { loadArea, setConfig, loadLana } = await import(`${miloLibs}/utils/utils.js`); setConfig({ ...CONFIG, miloLibs }); loadLana({ clientId: 'cc' }); await loadArea(); - if ((window.location.search.includes('goToFirefly') - || window.location.search.includes('goToFireflyEffects') - || window.location.search.includes('goToFireflyGenFill'))) { - try { await loadIms(); } catch { return; } - if (window.adobeIMS?.isSignedInUser()) { - const { redirectWithParam } = await import('../features/firefly/firefly-susi.js'); - redirectWithParam(); - } - } }()); From 95bca54c6f2707f445ab89cb6f0fae1e58f1cd4d Mon Sep 17 00:00:00 2001 From: Ruchika Sinha <69535463+Ruchika4@users.noreply.github.com> Date: Tue, 23 Jan 2024 21:12:14 -0800 Subject: [PATCH 3/3] Update firefly-interactive.js --- creativecloud/features/firefly/firefly-interactive.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/creativecloud/features/firefly/firefly-interactive.js b/creativecloud/features/firefly/firefly-interactive.js index bfb32796f..35d7ab200 100644 --- a/creativecloud/features/firefly/firefly-interactive.js +++ b/creativecloud/features/firefly/firefly-interactive.js @@ -30,7 +30,7 @@ function eventOnGenerate(generateButton, media) { const btnConfig = btnConfigs[className]; const dall = userprompt === '' ? btnConfig[0] : btnConfig[1]; e.target.setAttribute('daa-ll', dall); - const { signIn } = await import('./firefly-susi.js'); + const { default: signIn } = await import('./firefly-susi.js'); signIn(prompt, btnConfig[2]); } }); @@ -73,7 +73,7 @@ async function eventOnSelectorOption(option, prompt, media, mediaP, createPrompt genfilprompt.classList.add('genfill-promptbar'); const genFillButton = media.querySelector('#genfill'); genFillButton.addEventListener('click', async () => { - const { signIn } = await import('./firefly-susi.js'); + const { default: signIn } = await import('./firefly-susi.js'); signIn('', 'goToFireflyGenFill'); }); } else { @@ -167,7 +167,7 @@ export default async function setInteractiveFirefly(el) { media.append(genfillPrompt, fireflyPrompt); const genFillButton = media.querySelector('#genfill'); genFillButton.addEventListener('click', async () => { - const { signIn } = await import('./firefly-susi.js'); + const { default: signIn } = await import('./firefly-susi.js'); signIn('', 'goToFireflyGenFill'); }); }