Skip to content

Commit

Permalink
Fixing access control for group info page.
Browse files Browse the repository at this point in the history
  • Loading branch information
krulis-martin committed Nov 3, 2023
1 parent 6d15946 commit c6f67a2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 37 deletions.
28 changes: 15 additions & 13 deletions src/components/Groups/GroupsTree/GroupsTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,21 @@ const defaultButtonsCreator = (
</OverlayTrigger>
)}

<OverlayTrigger
placement="bottom"
overlay={
<Tooltip id={`info-${group.id}`}>
<FormattedMessage id="app.group.info" defaultMessage="Group Info" />
</Tooltip>
}>
<Link to={GROUP_INFO_URI_FACTORY(group.id)}>
<Button variant="primary" size="xs">
<GroupIcon />
</Button>
</Link>
</OverlayTrigger>
{hasPermissions(group, 'viewPublicDetail') && (
<OverlayTrigger
placement="bottom"
overlay={
<Tooltip id={`info-${group.id}`}>
<FormattedMessage id="app.group.info" defaultMessage="Group Info" />
</Tooltip>
}>
<Link to={GROUP_INFO_URI_FACTORY(group.id)}>
<Button variant="primary" size="xs">
<GroupIcon />
</Button>
</Link>
</OverlayTrigger>
)}

{hasPermissions(group, 'viewDetail') && (
<OverlayTrigger
Expand Down
29 changes: 8 additions & 21 deletions src/components/Groups/helpers/GroupInfoTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,7 @@ const getDescription = (localizedTexts, locale) => {
};

const GroupInfoTable = ({
group: {
id,
externalId,
organizational,
localizedTexts,
primaryAdminsIds,
public: isPublic = false,
privateData: { threshold, publicStats, bindings },
},
groups,
supervisors,
group: { externalId, organizational, localizedTexts, public: isPublic = false, privateData },
isAdmin,
locale,
}) => (
Expand All @@ -53,7 +43,7 @@ const GroupInfoTable = ({
unlimitedHeight>
<Table>
<tbody>
{!organizational && (
{!organizational && privateData && (
<tr>
<th>
<FormattedMessage
Expand All @@ -63,7 +53,7 @@ const GroupInfoTable = ({
:
</th>
<td>
<SuccessOrFailureIcon success={publicStats} />
<SuccessOrFailureIcon success={privateData.publicStats} />
</td>
</tr>
)}
Expand All @@ -78,7 +68,7 @@ const GroupInfoTable = ({
</td>
</tr>
)}
{threshold !== null && !organizational && (
{privateData && privateData.threshold !== null && !organizational && (
<tr>
<th>
<FormattedMessage
Expand All @@ -88,7 +78,7 @@ const GroupInfoTable = ({
:
</th>
<td>
<FormattedNumber value={threshold} style="percent" />
<FormattedNumber value={privateData.threshold} style="percent" />
</td>
</tr>
)}
Expand All @@ -107,9 +97,10 @@ const GroupInfoTable = ({
</tr>
)}

{bindings &&
{privateData &&
privateData.bindings &&
Object.values(
objectMap(bindings, (codes, provider) =>
objectMap(privateData.bindings, (codes, provider) =>
codes && codes.length > 0 ? (
<tr key={`bindings-${provider}`}>
<th>
Expand Down Expand Up @@ -148,11 +139,9 @@ const GroupInfoTable = ({

GroupInfoTable.propTypes = {
group: PropTypes.shape({
id: PropTypes.string.isRequired,
externalId: PropTypes.string,
parentGroupId: PropTypes.string,
threshold: PropTypes.number,
primaryAdminsIds: PropTypes.array.isRequired,
public: PropTypes.bool.isRequired,
organizational: PropTypes.bool.isRequired,
localizedTexts: PropTypes.array,
Expand All @@ -162,8 +151,6 @@ GroupInfoTable.propTypes = {
bindings: PropTypes.object,
}),
}),
groups: PropTypes.object.isRequired,
supervisors: PropTypes.array.isRequired,
isAdmin: PropTypes.bool,
locale: PropTypes.string.isRequired,
};
Expand Down
6 changes: 3 additions & 3 deletions src/pages/GroupInfo/GroupInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class GroupInfo extends Component {

<GroupArchivedWarning {...data} groupsDataAccessor={groupsAccessor} linkFactory={GROUP_INFO_URI_FACTORY} />

{!hasPermissions(data, 'viewDetail') && (
{!hasPermissions(data, 'viewPublicDetail') && (
<Row>
<Col sm={12}>
<Callout variant="warning" className="larger" icon={<BanIcon />}>
Expand All @@ -154,7 +154,7 @@ class GroupInfo extends Component {

<Row>
<Col sm={6}>
{hasPermissions(data, 'viewDetail') && (
{hasPermissions(data, 'viewPublicDetail') && (
<GroupInfoTable
group={data}
supervisors={supervisors}
Expand Down Expand Up @@ -224,7 +224,7 @@ class GroupInfo extends Component {
)}
</Col>
<Col sm={6}>
{hasPermissions(data, 'viewSubgroups') && (
{hasPermissions(data, 'viewPublicDetail') && (
<Box
title={<FormattedMessage id="app.groupDetail.subgroups" defaultMessage="Subgroups Hierarchy" />}
unlimitedHeight
Expand Down

0 comments on commit c6f67a2

Please sign in to comment.