Skip to content

Commit 6056560

Browse files
Fix/modal refresh after login [] (#11273)
* closes modal when auth token is not present and updates validation * closes modal when auth token is not present and updates validation
1 parent 82027f0 commit 6056560

3 files changed

Lines changed: 67 additions & 39 deletions

File tree

apps/aem-assets/README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,24 @@ This app lets editors browse, select, sort, and remove AEM DAM assets from a Con
88

99
## Configuration
1010

11+
### Installation Parameters
12+
1113
| Field | Required | Description |
1214
| --- | --- | --- |
1315
| IMS Client ID | Yes | Client ID from Adobe IMS. Must be requested from Adobe support — not the standard Adobe Developer Console. |
14-
| IMS Organization | Yes | The Adobe IMS org ID assigned when AEM as a Cloud Service was provisioned for your organization. |
15-
| Repository ID | No | Restricts asset selection to a single AEM repository. |
16-
| AEM Tier | No | Restricts the tier(s) searched (`delivery`, `author`). Defaults to both. |
17-
| Environment | No | Specifies the AEM repository environment (`prod`, `stage`). |
18-
| Hide Asset Upload Button | No | Hides the upload-to-AEM button inside the picker. Defaults to hidden. |
16+
| IMS Organization | Yes | The Adobe Identity Management System (IMS) ID provided by Adobe when provisioning Adobe AEM CS for your organization. |
17+
| Repository ID | No | Restricts the asset selector to a single repository. |
18+
| AEM Tier | No | Restricts the asset selector to repositories in the selected tier(s). |
19+
| Environment | No | Restricts the asset selector to repositories in the selected environment. |
20+
| Prefill Selected Assets | No | Specifies if selected assets are pre-selected in the asset picker. |
21+
| Hide Asset Upload Button | No | Specifies if the upload button is displayed in the asset picker. |
22+
23+
### Instance Parameters
24+
25+
| Field | Required | Description |
26+
| --- | --- | --- |
27+
| Hide Tree Nav | Yes | Specifies whether to show or hide the assets tree navigation sidebar |
28+
| Selection Type | No | Specifies if the field supports single or multiple asset selection. |
1929

2030
## Important setup requirement: origin allowlisting
2131

apps/aem-assets/src/index.css

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,32 @@ div {
1717
position: relative;
1818
}
1919

20+
.content-advisor-toolbar {
21+
display: flex;
22+
flex-direction: row-reverse;
23+
justify-content: space-between;
24+
align-items: center;
25+
}
26+
27+
#content-advisor-dialog {
28+
display: flex;
29+
flex-direction: column;
30+
gap: 1rem;
31+
height: 100%;
32+
width: 100%;
33+
overflow: hidden;
34+
}
35+
2036
/* Colors match Forma 36 tokens red100/red500/red700 (@contentful/f36-tokens) */
21-
.content-advisor-error {
37+
#content-advisor-error {
2238
background-color: #fff2f2;
2339
border: 1px solid #da294a;
2440
color: #990017;
2541
padding: 12px 16px;
26-
margin-bottom: 8px;
2742
font-size: 14px;
2843
line-height: 1.4;
2944
}
3045

31-
.content-advisor-error[hidden] {
46+
#content-advisor-error[hidden] {
3247
display: none;
33-
}
34-
35-
.content-advisor-toolbar {
36-
display: flex;
37-
justify-content: flex-end;
38-
padding: 8px 16px 0;
3948
}

apps/aem-assets/src/index.jsx

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ async function openDialog(sdk, _currentValue, _config) {
6262

6363
function prepareAEMAssetsHTML() {
6464
return `
65-
<dialog id='content-advisor-dialog' style='width:100%;height:100%;'>
66-
<div id='content-advisor-error' class='content-advisor-error' role='alert' hidden></div>
65+
<dialog id='content-advisor-dialog'>
6766
<div class='content-advisor-toolbar'>
6867
<div id='content-advisor-logout-container'></div>
68+
<div id='content-advisor-error' role='alert' hidden></div>
6969
</div>
70-
<div id='content-advisor' style='overflow-x:auto;width:100%;height:100%;'></div>
70+
<div id='content-advisor' style='width:100%;height:95%;'></div>
7171
</dialog>
7272
`;
7373
}
@@ -226,10 +226,11 @@ async function renderDialog(sdk) {
226226
onLogout={async () => {
227227
if (!imsInstance) return;
228228
try {
229-
await imsInstance.signOut();
230-
showAuthError(
231-
'You have been logged out of Adobe. Close this dialog and reopen the asset selector to sign in again.'
232-
);
229+
await imsInstance.signOut().then(() => {
230+
showAuthError(
231+
'You have been logged out of Adobe. Close this dialog and reopen the asset selector to sign in again.'
232+
);
233+
});
233234
} catch (error) {
234235
showAuthError(`Failed to log out of Adobe: ${error?.message || error}`);
235236
}
@@ -240,6 +241,7 @@ async function renderDialog(sdk) {
240241

241242
const imsAuthProps = {
242243
imsClientId: imsClientId,
244+
imsOrg: imsOrg,
243245
imsScope: IMS_SCOPE,
244246
redirectUrl: window.location.href,
245247
modalMode: true,
@@ -253,15 +255,21 @@ async function renderDialog(sdk) {
253255
'Your Adobe session has expired. Close this dialog and try selecting assets again.'
254256
);
255257
},
256-
onAccessTokenReceived: () => {
257-
hideAuthError();
258+
onAccessTokenReceived: (imsToken) => {
259+
if (imsToken) {
260+
hideAuthError();
261+
} else {
262+
// Close the modal if we don't have a valid IMS token. The IMS login modal should open.
263+
// After signing in, the user can re-open the asset selector by clicking the select assets button.
264+
sdk.close();
265+
}
258266
},
259267
};
260268

261269
const contentAdvisorProps = {
262270
imsOrg,
263271
repositoryId,
264-
aemTierType: aemTierType ? aemTierType.split(',') : ['delivery', 'author'],
272+
aemTierType: aemTierType && aemTierType !== 'both' ? [aemTierType] : ['delivery', 'author'],
265273
env: env === 'stage' ? 'stage' : undefined,
266274
hideTreeNav,
267275
selectedAssets:
@@ -272,7 +280,7 @@ async function renderDialog(sdk) {
272280
uploadConfig: {
273281
hideUploadButton: hideUploadButton === 'Yes' ? true : false,
274282
},
275-
alwaysUseDMDelivery: true,
283+
alwaysUseDMDelivery: aemTierType !== 'author',
276284
// handleAssetSelection, // only enabled for testing
277285
handleSelection,
278286
onClose,
@@ -333,10 +341,13 @@ function isDisabled() {
333341
return false;
334342
}
335343

336-
function validateParameters({ imsClientId }) {
344+
function validateParameters({ imsClientId, imsOrg }) {
337345
if (!imsClientId) {
338346
return 'Please add your IMS Client ID';
339347
}
348+
if (!imsOrg) {
349+
return 'Please add your IMS Organization';
350+
}
340351
return null;
341352
}
342353

@@ -352,32 +363,32 @@ setup({
352363
id: 'imsClientId',
353364
type: 'Symbol',
354365
name: 'IMS Client ID',
355-
description: 'Your Client ID from Adobe IMS.',
366+
description:
367+
'The Adobe Identity Management System (IMS) Client ID provided by Adobe for your Adobe AEM CS organization.',
356368
required: true,
357369
},
358370
{
359371
id: 'imsOrg',
360372
name: 'IMS Organization',
361373
type: 'Symbol',
362374
description:
363-
'Adobe Identity Management System (IMS) ID that is assigned while provisioning Adobe Experience Manager as a Cloud Service for your organization',
375+
'The Adobe Identity Management System (IMS) ID provided by Adobe when provisioning Adobe AEM CS for your organization.',
364376
required: true,
365377
},
366378
{
367379
id: 'repositoryId',
368-
name: 'Repository ID',
380+
name: 'Repository',
369381
type: 'Symbol',
370-
description: 'Restricts access to a single repository',
382+
description: 'Restricts the asset selector to a single repository.',
371383
required: false,
372384
},
373385
{
374386
id: 'aemTierType',
375387
name: 'AEM Tier',
376388
type: 'List',
377-
value: 'delivery,author',
378-
default: '',
379-
description:
380-
'Specifies the tier type for the app (defaults to delivery and author if no selection made)',
389+
value: 'delivery,author,both',
390+
default: 'both',
391+
description: 'Restricts the asset selector to repositories in the selected tier(s).',
381392
required: false,
382393
},
383394
{
@@ -386,25 +397,23 @@ setup({
386397
type: 'List',
387398
value: 'prod,stage',
388399
default: 'prod',
389-
description:
390-
'Specifies the AEM repository environment for the app (defaults to prod if no selection made)',
400+
description: 'Restricts the asset selector to repositories in the selected environment.',
391401
},
392402
{
393403
id: 'prefillSelectedAssets',
394404
name: 'Prefill Selected Assets',
395405
type: 'List',
396406
value: 'No,Yes',
397407
default: 'Yes',
398-
description:
399-
'Determines whether the selected assets will be prefilled when opening the asset picker.',
408+
description: 'Specifies if selected assets are pre-selected in the asset picker.',
400409
},
401410
{
402411
id: 'hideUploadButton',
403412
name: 'Hide Asset Upload Button',
404413
type: 'List',
405414
value: 'Yes, No',
406415
default: 'Yes',
407-
description: 'Specifies whether to show or hide the upload button',
416+
description: 'Specifies if the upload button is displayed in the asset picker.',
408417
},
409418
],
410419
customUpdateStateValue,

0 commit comments

Comments
 (0)