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

Access-Boston: Optimizing Group-Mgmt App #906

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
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
1 change: 0 additions & 1 deletion services-js/access-boston/fixtures/apps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ categories:
- SG_AB_HCMSECURITY
- title: Group Management
url: /group-management
target: _blank

- title: Manager Tools
apps:
Expand Down
95 changes: 53 additions & 42 deletions services-js/access-boston/src/client/group-management/Index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,35 @@ export default function Index(props: Props) {
const [list, dispatchList] = useReducer(listReducer, []);
const [loading, setLoading] = useState<boolean>(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 });
Expand Down Expand Up @@ -117,7 +135,9 @@ export default function Index(props: Props) {
const setApiUrl = async () => {
const apiURL =
process.env.GROUP_MANAGEMENT_API_URL || (await fetchDataURL());

if (state.api === '') {
console.log('apiURL (set URL): ', apiURL);
dispatchState({
type: 'APP/SET_API',
api: apiURL,
Expand All @@ -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',
Expand All @@ -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) => {
Expand All @@ -155,17 +172,15 @@ export default function Index(props: Props) {
return remappedObj;
});

console.log('SET_ADMIN_MIN_GROUPS: ');

dispatchState({
type: 'APP/SET_ADMIN_MIN_GROUPS',
dns: ret,
});
});
};

if (!state.adminMinGroups || state.adminMinGroups.length === 0) {
getAdminMinGroups();
}

const handleFetchGroupMembers = (
selected: Group,
dns: String[] = [],
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -247,9 +251,11 @@ export default function Index(props: Props) {
: state.selected.groups;
}

let RenderComponent = <></>;

switch (state.view) {
case 'management':
return (
RenderComponent = (
<div css={CONTAINER_STYLING}>
<ManagementView
mode={state.mode}
Expand Down Expand Up @@ -292,37 +298,40 @@ export default function Index(props: Props) {
/>
</div>
);
break;

case 'review':
return (
<div css={CONTAINER_STYLING}>
<ReviewChangesView
case 'confirmation':
RenderComponent = (
<div css={CONFIRMATION_CONTAINER_STYLING}>
<ReviewConfirmationView
mode={state.mode}
selected={state.selected}
changeView={changeView}
resetAll={resetAll}
items={list}
dns={groups}
getAdminMinGroups={getAdminMinGroups}
/>
</div>
);
break;

case 'confirmation':
return (
<div css={CONFIRMATION_CONTAINER_STYLING}>
<ReviewConfirmationView
case 'review':
RenderComponent = (
<div css={CONTAINER_STYLING}>
<ReviewChangesView
mode={state.mode}
selected={state.selected}
changeView={changeView}
resetAll={resetAll}
items={list}
dns={groups}
getAdminMinGroups={getAdminMinGroups}
/>
</div>
);
break;

default:
return (
RenderComponent = (
<div css={CONTAINER_STYLING}>
<InitialView
mode={state.mode}
Expand All @@ -344,6 +353,8 @@ export default function Index(props: Props) {
</div>
);
}

return RenderComponent;
}

const CONTAINER_STYLING: any = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Array [
"groups": null,
"iconUrl": null,
"mfaDeviceRequired": false,
"target": "_blank",
"target": "",
"title": "Group Management",
"url": "/group-management",
},
Expand Down Expand Up @@ -231,7 +231,7 @@ Array [
"groups": null,
"iconUrl": null,
"mfaDeviceRequired": false,
"target": "_blank",
"target": "",
"title": "Group Management",
"url": "/group-management",
},
Expand Down Expand Up @@ -329,7 +329,7 @@ Array [
"groups": null,
"iconUrl": null,
"mfaDeviceRequired": false,
"target": "_blank",
"target": "",
"title": "Group Management",
"url": "/group-management",
},
Expand Down Expand Up @@ -462,7 +462,7 @@ Array [
"groups": null,
"iconUrl": null,
"mfaDeviceRequired": false,
"target": "_blank",
"target": "",
"title": "Group Management",
"url": "/group-management",
},
Expand Down Expand Up @@ -595,7 +595,7 @@ Array [
"groups": null,
"iconUrl": null,
"mfaDeviceRequired": false,
"target": "_blank",
"target": "",
"title": "Group Management",
"url": "/group-management",
},
Expand Down
27 changes: 17 additions & 10 deletions services-js/access-boston/src/server/services/SamlAuthFake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,25 @@ export default class SamlAuthFake implements Required<SamlAuth> {
lastName: 'User',
email: '[email protected]',
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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
>
<span
className="t--info"
Expand Down Expand Up @@ -9003,7 +9003,7 @@ exports[`Storyshots IndexPage default 1`] = `
className="p-a300"
href="/group-management"
id="app-link-Group Management"
target="_blank"
target="_self"
>
<span
className="t--info"
Expand Down Expand Up @@ -10097,7 +10097,7 @@ exports[`Storyshots IndexPage hasn’t registered MFA 1`] = `
className="p-a300"
href="/group-management"
id="app-link-Group Management"
target="_blank"
target="_self"
>
<span
className="t--info"
Expand Down