Skip to content

Commit c6f67a2

Browse files
committed
Fixing access control for group info page.
1 parent 6d15946 commit c6f67a2

File tree

3 files changed

+26
-37
lines changed

3 files changed

+26
-37
lines changed

src/components/Groups/GroupsTree/GroupsTree.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,21 @@ const defaultButtonsCreator = (
3636
</OverlayTrigger>
3737
)}
3838

39-
<OverlayTrigger
40-
placement="bottom"
41-
overlay={
42-
<Tooltip id={`info-${group.id}`}>
43-
<FormattedMessage id="app.group.info" defaultMessage="Group Info" />
44-
</Tooltip>
45-
}>
46-
<Link to={GROUP_INFO_URI_FACTORY(group.id)}>
47-
<Button variant="primary" size="xs">
48-
<GroupIcon />
49-
</Button>
50-
</Link>
51-
</OverlayTrigger>
39+
{hasPermissions(group, 'viewPublicDetail') && (
40+
<OverlayTrigger
41+
placement="bottom"
42+
overlay={
43+
<Tooltip id={`info-${group.id}`}>
44+
<FormattedMessage id="app.group.info" defaultMessage="Group Info" />
45+
</Tooltip>
46+
}>
47+
<Link to={GROUP_INFO_URI_FACTORY(group.id)}>
48+
<Button variant="primary" size="xs">
49+
<GroupIcon />
50+
</Button>
51+
</Link>
52+
</OverlayTrigger>
53+
)}
5254

5355
{hasPermissions(group, 'viewDetail') && (
5456
<OverlayTrigger

src/components/Groups/helpers/GroupInfoTable.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,7 @@ const getDescription = (localizedTexts, locale) => {
2929
};
3030

3131
const GroupInfoTable = ({
32-
group: {
33-
id,
34-
externalId,
35-
organizational,
36-
localizedTexts,
37-
primaryAdminsIds,
38-
public: isPublic = false,
39-
privateData: { threshold, publicStats, bindings },
40-
},
41-
groups,
42-
supervisors,
32+
group: { externalId, organizational, localizedTexts, public: isPublic = false, privateData },
4333
isAdmin,
4434
locale,
4535
}) => (
@@ -53,7 +43,7 @@ const GroupInfoTable = ({
5343
unlimitedHeight>
5444
<Table>
5545
<tbody>
56-
{!organizational && (
46+
{!organizational && privateData && (
5747
<tr>
5848
<th>
5949
<FormattedMessage
@@ -63,7 +53,7 @@ const GroupInfoTable = ({
6353
:
6454
</th>
6555
<td>
66-
<SuccessOrFailureIcon success={publicStats} />
56+
<SuccessOrFailureIcon success={privateData.publicStats} />
6757
</td>
6858
</tr>
6959
)}
@@ -78,7 +68,7 @@ const GroupInfoTable = ({
7868
</td>
7969
</tr>
8070
)}
81-
{threshold !== null && !organizational && (
71+
{privateData && privateData.threshold !== null && !organizational && (
8272
<tr>
8373
<th>
8474
<FormattedMessage
@@ -88,7 +78,7 @@ const GroupInfoTable = ({
8878
:
8979
</th>
9080
<td>
91-
<FormattedNumber value={threshold} style="percent" />
81+
<FormattedNumber value={privateData.threshold} style="percent" />
9282
</td>
9383
</tr>
9484
)}
@@ -107,9 +97,10 @@ const GroupInfoTable = ({
10797
</tr>
10898
)}
10999

110-
{bindings &&
100+
{privateData &&
101+
privateData.bindings &&
111102
Object.values(
112-
objectMap(bindings, (codes, provider) =>
103+
objectMap(privateData.bindings, (codes, provider) =>
113104
codes && codes.length > 0 ? (
114105
<tr key={`bindings-${provider}`}>
115106
<th>
@@ -148,11 +139,9 @@ const GroupInfoTable = ({
148139

149140
GroupInfoTable.propTypes = {
150141
group: PropTypes.shape({
151-
id: PropTypes.string.isRequired,
152142
externalId: PropTypes.string,
153143
parentGroupId: PropTypes.string,
154144
threshold: PropTypes.number,
155-
primaryAdminsIds: PropTypes.array.isRequired,
156145
public: PropTypes.bool.isRequired,
157146
organizational: PropTypes.bool.isRequired,
158147
localizedTexts: PropTypes.array,
@@ -162,8 +151,6 @@ GroupInfoTable.propTypes = {
162151
bindings: PropTypes.object,
163152
}),
164153
}),
165-
groups: PropTypes.object.isRequired,
166-
supervisors: PropTypes.array.isRequired,
167154
isAdmin: PropTypes.bool,
168155
locale: PropTypes.string.isRequired,
169156
};

src/pages/GroupInfo/GroupInfo.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class GroupInfo extends Component {
139139

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

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

155155
<Row>
156156
<Col sm={6}>
157-
{hasPermissions(data, 'viewDetail') && (
157+
{hasPermissions(data, 'viewPublicDetail') && (
158158
<GroupInfoTable
159159
group={data}
160160
supervisors={supervisors}
@@ -224,7 +224,7 @@ class GroupInfo extends Component {
224224
)}
225225
</Col>
226226
<Col sm={6}>
227-
{hasPermissions(data, 'viewSubgroups') && (
227+
{hasPermissions(data, 'viewPublicDetail') && (
228228
<Box
229229
title={<FormattedMessage id="app.groupDetail.subgroups" defaultMessage="Subgroups Hierarchy" />}
230230
unlimitedHeight

0 commit comments

Comments
 (0)