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

MWPW-140914-Redirect user directly to firefly product page from firefly marketing page #170

Merged
merged 3 commits into from
Jan 29, 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
6 changes: 3 additions & 3 deletions creativecloud/features/firefly/firefly-interactive.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
});
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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');
});
}
Expand Down
30 changes: 12 additions & 18 deletions creativecloud/features/firefly/firefly-susi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};
}
11 changes: 1 addition & 10 deletions creativecloud/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}());
Loading