Skip to content
This repository has been archived by the owner on Oct 6, 2019. It is now read-only.

Commit

Permalink
Merge pull request #906 from donker/removedelusersbtn
Browse files Browse the repository at this point in the history
Add "remove deleted users" button to place you'd expect it
  • Loading branch information
mitchelsellers authored May 3, 2019
2 parents c22d1c5 + 23c4c6f commit 3c459aa
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,26 @@ public HttpResponseMessage HardDeleteUser([FromUri] int userId)
}
}

[HttpPost]
[ValidateAntiForgeryToken]
public HttpResponseMessage RemoveDeletedUsers()
{
if (!UserInfo.IsSuperUser)
{
if (!UserInfo.IsInRole(PortalSettings.AdministratorRoleName))
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, Localization.GetString("InSufficientPermissions", Components.Constants.LocalResourcesFile));
}
}
UserController.RemoveDeletedUsers(PortalSettings.PortalId);
var remaining = UserController.GetDeletedUsers(PortalSettings.PortalId);
if (remaining.Count > 0)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, Localization.GetString("CouldNotRemoveAll", Components.Constants.LocalResourcesFile));
}
return Request.CreateResponse(HttpStatusCode.OK, new { Success = true });
}

[HttpPost]
[ValidateAntiForgeryToken]
[AdvancedPermission(MenuName = Components.Constants.MenuName, Permission = Components.Constants.DeleteUser)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,15 @@ const userActions = {
}, errorCallback);
};
},
removeDeletedUsers(callback) {
return (dispatch) => {
UserService.removeDeletedUsers(data => {
if (callback) {
callback(data);
}
}, errorCallback);
};
},
restoreUser(payload, filter, callback) {
return (dispatch) => {
let restoredUser = Object.assign({}, payload.userDetails);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ class UserService {
const sf = this.getServiceFramework("Users");
sf.post("HardDeleteUser?" + serializeQueryStringParameters(userDetails), null, callback, errorCallback);
}
removeDeletedUsers(callback, errorCallback) {
const sf = this.getServiceFramework("Users");
sf.post("RemoveDeletedUsers", null, callback, errorCallback);
}
restoreUser(userDetails, callback, errorCallback) {
const sf = this.getServiceFramework("Users");
sf.post("RestoreDeletedUser?" + serializeQueryStringParameters(userDetails), null, callback, errorCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ class Body extends Component {
</GridCell>;
}

onRemoveDeletedUsers() {
utilities.confirm(
Localization.get("RemoveDeleted.Confirm"),
Localization.get("Yes"),
Localization.get("No"),
() => {
this.props.dispatch(CommonUsersActions.removeDeletedUsers(() => {
let {searchParameters} = this.state;
this.props.dispatch(CommonUsersActions.getUsers(searchParameters));
utilities.notify(Localization.get("RemoveDeleted.Done"));
}));
}
);
}

toggleCreateBox() {
this.userTable.wrappedInstance.onAddUser();
}
Expand All @@ -88,6 +103,12 @@ class Body extends Component {
{Localization.get("btnCreateUser") }
</Button>
}
{
appSettings.applicationSettings.settings.isAdmin &&
<Button type="secondary" size="large" onClick={() => {this.onRemoveDeletedUsers()}} title={Localization.get("RemoveDeleted.Btn")}>
{Localization.get("RemoveDeleted.Btn") }
</Button>
}
</PersonaBarPageHeader>
<PersonaBarPageBody workSpaceTrayVisible={true} workSpaceTrayOutside={true} workSpaceTray={this.getWorkSpaceTray() } className={panelBodyMargin}>
<UserTable ref={(node) => this.userTable = node} appSettings={appSettings} filter={state.searchParameters.filter}/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
.user-emails, .user-joined{
padding-left: 15px !important;
}
.dnn-persona-bar-page-header {
button.dnn-ui-common-button {
margin-left: 10px;
}
}
.dnn-persona-bar-page-body {
&.without-margin {
margin-top: 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1286,4 +1286,16 @@
<data name="LastConsented.Text" xml:space="preserve">
<value>Last consented on</value>
</data>
<data name="RemoveDeleted.Btn" xml:space="preserve">
<value>Remove Deleted Users</value>
</data>
<data name="RemoveDeleted.Confirm" xml:space="preserve">
<value>Do you wish to permanently remove deleted users? You cannot undo this operation.</value>
</data>
<data name="RemoveDeleted.Done" xml:space="preserve">
<value>All deleted users have been removed</value>
</data>
<data name="CouldNotRemoveAll.Text" xml:space="preserve">
<value>Could not remove all users</value>
</data>
</root>

0 comments on commit 3c459aa

Please sign in to comment.