From 35031a17fae2b52971f87895645a2f61890db453 Mon Sep 17 00:00:00 2001 From: Phillip Kelly Date: Mon, 16 May 2022 17:34:16 -0400 Subject: [PATCH 1/2] Access-Boston: Optimizing Group-Mgmt App --- services-js/access-boston/fixtures/apps.yaml | 1 - .../src/client/group-management/Index.tsx | 95 +++++++++++-------- .../__snapshots__/AppsRegistry.test.ts.snap | 10 +- .../src/server/services/SamlAuthFake.ts | 27 ++++-- .../__snapshots__/Storyshots.test.ts.snap | 6 +- 5 files changed, 78 insertions(+), 61 deletions(-) diff --git a/services-js/access-boston/fixtures/apps.yaml b/services-js/access-boston/fixtures/apps.yaml index 1f82e7b5b..d1c4726dd 100644 --- a/services-js/access-boston/fixtures/apps.yaml +++ b/services-js/access-boston/fixtures/apps.yaml @@ -154,7 +154,6 @@ categories: - SG_AB_HCMSECURITY - title: Group Management url: /group-management - target: _blank - title: Manager Tools apps: diff --git a/services-js/access-boston/src/client/group-management/Index.tsx b/services-js/access-boston/src/client/group-management/Index.tsx index 02edf58f4..6bc6496bc 100644 --- a/services-js/access-boston/src/client/group-management/Index.tsx +++ b/services-js/access-boston/src/client/group-management/Index.tsx @@ -48,17 +48,35 @@ export default function Index(props: Props) { const [list, dispatchList] = useReducer(listReducer, []); const [loading, setLoading] = useState(false); - // useEffect(() => { - // // Update the document title using the browser API - // if ( - // !groups || - // typeof groups !== 'object' || - // groups.length < 0 || - // groups.filter((str: string) => str.includes('_GRPMGMT_')) < 1 - // ) { - // if (window) window.location.href = '/'; - // } - // }); + // Once a selection is made, populate the list and update suggestions. + useEffect(() => { + const { mode, selected } = state; + if (mode === 'group') { + if (selected.cn) handleFetchGroupMembers(selected, groups); + } else { + if (selected.cn) handleFetchPersonsGroups(selected, groups); + } + + setApiUrl(); + + if (!state.ous || state.ous.length === 0) { + setOus(); + } + + if (!state.adminMinGroups || state.adminMinGroups.length === 0) { + getAdminMinGroups(); + } + + // Update the document title using the browser API + // if ( + // !groups || + // typeof groups !== 'object' || + // groups.length < 0 || + // groups.filter((str: string) => str.includes('_GRPMGMT_')) < 1 + // ) { + // if (window) window.location.href = '/'; + // } + }, [state.selected]); const changeView = (newView: View): void => dispatchState({ type: 'APP/CHANGE_VIEW', view: newView }); @@ -117,6 +135,8 @@ export default function Index(props: Props) { const setApiUrl = async () => { const apiURL = process.env.GROUP_MANAGEMENT_API_URL || (await fetchDataURL()); + + console.log('apiURL: ', apiURL); if (state.api === '') { dispatchState({ type: 'APP/SET_API', @@ -126,6 +146,7 @@ export default function Index(props: Props) { }; const setOus = async () => { + console.log('RUNNING: setOus'); fetchOurContainers(groups).then(result => { dispatchState({ type: 'APP/SET_OUS', @@ -134,10 +155,6 @@ export default function Index(props: Props) { }); }; - if (!state.ous || state.ous.length === 0) { - setOus(); - } - const getAdminMinGroups = async () => { fetchMinimumUserGroups(groups).then(result => { let ret = result.getMinimumUserGroups.map((entry: Group | Person) => { @@ -155,6 +172,8 @@ export default function Index(props: Props) { return remappedObj; }); + console.log('SET_ADMIN_MIN_GROUPS: '); + dispatchState({ type: 'APP/SET_ADMIN_MIN_GROUPS', dns: ret, @@ -162,10 +181,6 @@ export default function Index(props: Props) { }); }; - if (!state.adminMinGroups || state.adminMinGroups.length === 0) { - getAdminMinGroups(); - } - const handleFetchGroupMembers = ( selected: Group, dns: String[] = [], @@ -209,17 +224,6 @@ export default function Index(props: Props) { } }; - setApiUrl(); - // Once a selection is made, populate the list and update suggestions. - useEffect(() => { - const { mode, selected } = state; - if (mode === 'group') { - if (selected.cn) handleFetchGroupMembers(selected, groups); - } else { - if (selected.cn) handleFetchPersonsGroups(selected, groups); - } - }, [state.selected]); - const handleToggleItem = (item: Group | Person) => { if (item.action && item.action === 'new') { dispatchList({ type: 'LIST/DELETE_ITEM', item }); @@ -247,9 +251,11 @@ export default function Index(props: Props) { : state.selected.groups; } + let RenderComponent = <>; + switch (state.view) { case 'management': - return ( + RenderComponent = (
); + break; - case 'review': - return ( -
- +
); + break; - case 'confirmation': - return ( -
- +
); + break; default: - return ( + RenderComponent = (
); } + + return RenderComponent; } const CONTAINER_STYLING: any = { diff --git a/services-js/access-boston/src/lib/__snapshots__/AppsRegistry.test.ts.snap b/services-js/access-boston/src/lib/__snapshots__/AppsRegistry.test.ts.snap index 0a0c0e136..19c8fbf03 100644 --- a/services-js/access-boston/src/lib/__snapshots__/AppsRegistry.test.ts.snap +++ b/services-js/access-boston/src/lib/__snapshots__/AppsRegistry.test.ts.snap @@ -86,7 +86,7 @@ Array [ "groups": null, "iconUrl": null, "mfaDeviceRequired": false, - "target": "_blank", + "target": "", "title": "Group Management", "url": "/group-management", }, @@ -231,7 +231,7 @@ Array [ "groups": null, "iconUrl": null, "mfaDeviceRequired": false, - "target": "_blank", + "target": "", "title": "Group Management", "url": "/group-management", }, @@ -329,7 +329,7 @@ Array [ "groups": null, "iconUrl": null, "mfaDeviceRequired": false, - "target": "_blank", + "target": "", "title": "Group Management", "url": "/group-management", }, @@ -462,7 +462,7 @@ Array [ "groups": null, "iconUrl": null, "mfaDeviceRequired": false, - "target": "_blank", + "target": "", "title": "Group Management", "url": "/group-management", }, @@ -595,7 +595,7 @@ Array [ "groups": null, "iconUrl": null, "mfaDeviceRequired": false, - "target": "_blank", + "target": "", "title": "Group Management", "url": "/group-management", }, diff --git a/services-js/access-boston/src/server/services/SamlAuthFake.ts b/services-js/access-boston/src/server/services/SamlAuthFake.ts index a206f5562..b39c43fad 100644 --- a/services-js/access-boston/src/server/services/SamlAuthFake.ts +++ b/services-js/access-boston/src/server/services/SamlAuthFake.ts @@ -45,18 +45,25 @@ export default class SamlAuthFake implements Required { lastName: 'User', email: 'test@boston.gov', groups: [ - 'COB-Group-TestGrp01', - 'SG_AB_IAM_TEAM', - 'SG_AB_SERVICEDESK_USERS', - 'SG_AB_GRPMGMT_CIVIS', - 'SG_AB_GRPMGMT_EBUILDER', - 'SG_AB_GRPMGMT_AUDITING', - 'SG_AB_GRPMGMT_TANIUM', - 'SG_AB_TANIUM', + // 'COB-Group-TestGrp01', + // 'SG_AB_IAM_TEAM', + // 'SG_AB_SERVICEDESK_USERS', + // 'SG_AB_GRPMGMT_CIVIS', + // 'SG_AB_GRPMGMT_EBUILDER', + // 'SG_AB_GRPMGMT_AUDITING', + // 'SG_AB_GRPMGMT_TANIUM', + // 'SG_AB_TANIUM', + 'SG_AB_CONFIRMID', // 'SG_AB_GRPMGMT_PSHCM', + // 'SG_AB_BLDGMAINTREQ', // 'SG_AB_GRPMGMT_Lagan_Groups', - 'SG_AB_BLDGMAINTREQ', - 'SG_AB_CONFIRMID', + 'SG_AB_GRPMGMT_LAGAN_GROUPS', + 'SG_AB_GRPMGMT_DRUPAL', + 'SG_AB_DRUPAL', + 'SG_AB_CYBERARK', + 'SG_AB_AGILEPOINT', + 'SG_AB_ALLSPONSORED', + 'SG_AB_PROOFPOINT', ], needsNewPassword: isNewUser, needsMfaDevice: isNewUser && userId !== 'NEW88888', diff --git a/services-js/access-boston/src/stories/__snapshots__/Storyshots.test.ts.snap b/services-js/access-boston/src/stories/__snapshots__/Storyshots.test.ts.snap index 726fc5b13..34a87a561 100644 --- a/services-js/access-boston/src/stories/__snapshots__/Storyshots.test.ts.snap +++ b/services-js/access-boston/src/stories/__snapshots__/Storyshots.test.ts.snap @@ -7963,7 +7963,7 @@ exports[`Storyshots IndexPage change password success 1`] = ` className="p-a300" href="/group-management" id="app-link-Group Management" - target="_blank" + target="_self" > Date: Tue, 17 May 2022 16:13:57 -0400 Subject: [PATCH 2/2] Access-Boston: Optimizing Group-Mgmt App - show more groups in init view --- services-js/access-boston/src/client/group-management/Index.tsx | 2 +- .../access-boston/src/client/group-management/InitialView.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/services-js/access-boston/src/client/group-management/Index.tsx b/services-js/access-boston/src/client/group-management/Index.tsx index 6bc6496bc..02b814a1f 100644 --- a/services-js/access-boston/src/client/group-management/Index.tsx +++ b/services-js/access-boston/src/client/group-management/Index.tsx @@ -136,8 +136,8 @@ export default function Index(props: Props) { const apiURL = process.env.GROUP_MANAGEMENT_API_URL || (await fetchDataURL()); - console.log('apiURL: ', apiURL); if (state.api === '') { + console.log('apiURL (set URL): ', apiURL); dispatchState({ type: 'APP/SET_API', api: apiURL, diff --git a/services-js/access-boston/src/client/group-management/InitialView.tsx b/services-js/access-boston/src/client/group-management/InitialView.tsx index 6348d4e2e..74550dafa 100644 --- a/services-js/access-boston/src/client/group-management/InitialView.tsx +++ b/services-js/access-boston/src/client/group-management/InitialView.tsx @@ -43,7 +43,7 @@ export default function InitialView(props: Props) { const showMinGroupDisplay = adminMinGroups && adminMinGroups.length > 0 && - adminMinGroups.length < 4 && + adminMinGroups.length < 11 && mode === 'group'; return (