Skip to content

Commit 2fc489c

Browse files
Added button to revoke admin rights in frontend (#3378)
* added button to revoke admin rights * made the code pretty * Update CHANGELOG.md * updated snapshots
1 parent 49819b2 commit 2fc489c

File tree

5 files changed

+51
-18
lines changed

5 files changed

+51
-18
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.md).
1414
- Added support for duplicate dataset names for different organizations [#3137](https://github.com/scalableminds/webknossos/pull/3137)
1515
- Extended the version restore view and added a view to restore older versions of a volume tracing. Access it through the dropdown next to the Save button. [#3349](https://github.com/scalableminds/webknossos/pull/3349)
1616
- Added support to watch additional dataset directories, automatically creating symbolic links to the main directory [#3330](https://github.com/scalableminds/webknossos/pull/3330)
17+
- Added a button to the users list view that revokes admin rights from all selected users. [#3378](https://github.com/scalableminds/webknossos/pull/3378)
1718
- A User can now have multiple layouts for tracing views. [#3299](https://github.com/scalableminds/webknossos/pull/3299)
1819
- The info tab in tracing views now displays the extent of the current dataset. [#3371](https://github.com/scalableminds/webknossos/pull/3371).
1920

app/assets/javascripts/admin/user/user_list_view.js

+36-18
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,11 @@ class UserListView extends React.PureComponent<Props, State> {
170170
});
171171
};
172172

173-
grantAdminRights = async () => {
173+
setAdminRightsTo = async (isAdmin: boolean) => {
174174
if (this.props.activeUser.isAdmin) {
175175
const newUserPromises = this.state.users.map(user => {
176176
if (this.state.selectedUserIds.includes(user.id)) {
177-
const newUser = Object.assign({}, user, { isAdmin: true });
177+
const newUser = Object.assign({}, user, { isAdmin });
178178

179179
return updateUser(newUser);
180180
}
@@ -305,22 +305,40 @@ class UserListView extends React.PureComponent<Props, State> {
305305
Change Experience
306306
</Button>
307307
{this.props.activeUser.isAdmin ? (
308-
<Button
309-
onClick={() =>
310-
Modal.confirm({
311-
title: messages["users.grant_admin_rights_title"],
312-
content: messages["users.grant_admin_rights"]({
313-
numUsers: this.state.selectedUserIds.length,
314-
}),
315-
onOk: this.grantAdminRights,
316-
})
317-
}
318-
icon="rocket"
319-
disabled={!hasRowsSelected}
320-
style={marginRight}
321-
>
322-
Grant Admin Rights
323-
</Button>
308+
<React.Fragment>
309+
<Button
310+
onClick={() =>
311+
Modal.confirm({
312+
title: messages["users.grant_admin_rights_title"],
313+
content: messages["users.grant_admin_rights"]({
314+
numUsers: this.state.selectedUserIds.length,
315+
}),
316+
onOk: () => this.setAdminRightsTo(true),
317+
})
318+
}
319+
icon="rocket"
320+
disabled={!hasRowsSelected}
321+
style={marginRight}
322+
>
323+
Grant Admin Rights
324+
</Button>
325+
<Button
326+
onClick={() =>
327+
Modal.confirm({
328+
title: messages["users.revoke_admin_rights_title"],
329+
content: messages["users.revoke_admin_rights"]({
330+
numUsers: this.state.selectedUserIds.length,
331+
}),
332+
onOk: () => this.setAdminRightsTo(false),
333+
})
334+
}
335+
icon="rollback"
336+
disabled={!hasRowsSelected}
337+
style={marginRight}
338+
>
339+
Revoke Admin Rights
340+
</Button>
341+
</React.Fragment>
324342
) : null}
325343
<InviteUsersPopover
326344
organizationName={this.props.activeUser.organization}

app/assets/javascripts/messages.js

+4
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ In order to restore the current window, a reload is necessary.`,
185185
"users.grant_admin_rights": _.template(
186186
"You are about to grant admin privileges to <%- numUsers %> user(s) giving them access to all teams, datasets and annotations. Do you want to proceed?",
187187
),
188+
"users.revoke_admin_rights_title": "Do you really want to revoke admin rights?",
189+
"users.revoke_admin_rights": _.template(
190+
"You are about to revoke admin privileges from <%- numUsers %> user(s). Do you want to proceed?",
191+
),
188192
"users.change_email_title": "Do you really want to change the email?",
189193
"users.change_email": _.template(
190194
"Do you really want to change the email to '<%- newEmail %>' ? The corresponding user will be logged out and unsaved changes might be lost.",

app/assets/javascripts/test/snapshots/public/test-bundle/test/enzyme/snapshot.e2e.js.md

+10
Original file line numberDiff line numberDiff line change
@@ -6060,6 +6060,16 @@ Generated by [AVA](https://ava.li).
60606060
</span>␊
60616061
</button>␊
60626062
</Button>␊
6063+
<Button onClick={[Function: onClick]} icon="rollback" disabled={true} style={{...}} prefixCls="ant-btn" loading={false} ghost={false}>␊
6064+
<button onClick={[Function]} disabled={true} style={{...}} type="button" className="ant-btn">␊
6065+
<Icon type="rollback">␊
6066+
<i className="anticon anticon-rollback" />␊
6067+
</Icon>␊
6068+
<span>␊
6069+
Revoke Admin Rights␊
6070+
</span>␊
6071+
</button>␊
6072+
</Button>␊
60636073
<InviteUsersPopover organizationName="Organization_X" visible={false} handleVisibleChange={[Function: handleVisibleChange]}>␊
60646074
<Popover trigger="click" visible={false} onVisibleChange={[Function: handleVisibleChange]} title="Invite Users" content={{...}} prefixCls="ant-popover" placement="top" transitionName="zoom-big" mouseEnterDelay={0.1} mouseLeaveDelay={0.1} overlayStyle={{...}}>␊
60656075
<Tooltip trigger="click" visible={false} onVisibleChange={[Function: handleVisibleChange]} content={{...}} prefixCls="ant-popover" placement="top" transitionName="zoom-big" mouseEnterDelay={0.1} mouseLeaveDelay={0.1} overlayStyle={{...}} overlay={{...}} arrowPointAtCenter={false} autoAdjustOverflow={true}>␊

0 commit comments

Comments
 (0)