Skip to content

Commit

Permalink
Merged in bugfix/SHIBUI-2506 (pull request #639)
Browse files Browse the repository at this point in the history
Fixed issue with group names

Approved-by: Doug Sonaty
  • Loading branch information
rmathis committed Feb 16, 2023
2 parents 2ddbd01 + 77f9edf commit e1f8909
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
15 changes: 15 additions & 0 deletions ui/src/app/admin/component/ApproversList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';

export function ApproversList ({ group, children }) {

const list = React.useMemo(() => {
if (group.approversList?.length > 0) {
return group.approversList[0].approverGroupIds;
}
return [];
}, [group]);

return (<>
{ list.length > 0 ? children(list) : '-' }
</>)
}
7 changes: 7 additions & 0 deletions ui/src/app/admin/component/GroupName.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

export function GroupName ({id, groups}) {
const group = React.useMemo(() => groups.find(g => g.resourceId === id), [id, groups]);

return (<>{ group.name }</>);
}
18 changes: 16 additions & 2 deletions ui/src/app/admin/container/GroupsList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Fragment } from 'react';
import { faEdit, faPlusCircle, faTrash } from '@fortawesome/free-solid-svg-icons';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';

Expand All @@ -9,6 +9,9 @@ import { Translate } from '../../i18n/components/translate';

import { DeleteConfirmation } from '../../core/components/DeleteConfirmation';

import { GroupName } from '../component/GroupName';
import { ApproversList } from '../component/ApproversList';

export function GroupsList({ groups, onDelete }) {

const remove = (id) => {
Expand Down Expand Up @@ -54,7 +57,18 @@ export function GroupsList({ groups, onDelete }) {
<tr key={i}>
<td>{group.name}</td>
<td>{group.description || ''}</td>
<td>{group.approversList?.length > 0 ? group.approversList[0].approverGroupIds.join(', ') : '-'}</td>
<td>
<ApproversList group={group}>
{(list) => (list.map((id, idx) => {
return (
<Fragment key={idx}>
<GroupName id={id} groups={groups} />
{ idx < (list.length - 1) && ', ' }
</Fragment>
);
}))}
</ApproversList>
</td>
<td className="text-end">
<Link to={`../${group.resourceId}/edit`} className="btn btn-link text-primary"
id={`group-edit-${i}`}>
Expand Down

0 comments on commit e1f8909

Please sign in to comment.