Bulk remove organization users (#970)

* Add support for bulk removal of org users

* Rename to UserBulkDeleteRequest

* Use OrganizationUserBulkRequest

* Bump jslib

* Fix linting
This commit is contained in:
Oscar Hinton 2021-05-18 10:27:52 +02:00 committed by GitHub
parent 34be07c220
commit 45c31aa089
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 5 deletions

2
jslib

@ -1 +1 @@
Subproject commit 92dbf24ab895443d8f5bd404e749d4fd83f32207 Subproject commit 6b9246c272fc74cd644bc4b94cb99f936c6f44f8

View File

@ -191,17 +191,17 @@ import {
DatePipe, DatePipe,
registerLocaleData, registerLocaleData,
} from '@angular/common'; } from '@angular/common';
import localeBg from '@angular/common/locales/bg';
import localeCa from '@angular/common/locales/ca'; import localeCa from '@angular/common/locales/ca';
import localeCs from '@angular/common/locales/cs'; import localeCs from '@angular/common/locales/cs';
import localeBg from '@angular/common/locales/bg';
import localeDa from '@angular/common/locales/da'; import localeDa from '@angular/common/locales/da';
import localeDe from '@angular/common/locales/de'; import localeDe from '@angular/common/locales/de';
import localeEl from '@angular/common/locales/el'; import localeEl from '@angular/common/locales/el';
import localeEnGb from '@angular/common/locales/en-GB'; import localeEnGb from '@angular/common/locales/en-GB';
import localeEnIn from '@angular/common/locales/en-IN'; import localeEnIn from '@angular/common/locales/en-IN';
import localeEo from '@angular/common/locales/eo';
import localeEs from '@angular/common/locales/es'; import localeEs from '@angular/common/locales/es';
import localeEt from '@angular/common/locales/et'; import localeEt from '@angular/common/locales/et';
import localeEo from '@angular/common/locales/eo';
import localeFi from '@angular/common/locales/fi'; import localeFi from '@angular/common/locales/fi';
import localeFr from '@angular/common/locales/fr'; import localeFr from '@angular/common/locales/fr';
import localeHe from '@angular/common/locales/he'; import localeHe from '@angular/common/locales/he';

View File

@ -35,6 +35,10 @@
<i class="fa fa-fw fa-envelope-o" aria-hidden="true"></i> <i class="fa fa-fw fa-envelope-o" aria-hidden="true"></i>
{{'reinviteSelected' | i18n}} {{'reinviteSelected' | i18n}}
</button> </button>
<button class="dropdown-item text-danger" appStopClick (click)="bulkRemove()">
<i class="fa fa-fw fa-remove" aria-hidden="true"></i>
{{'remove' | i18n}}
</button>
<div class="dropdown-divider"></div> <div class="dropdown-divider"></div>
<button class="dropdown-item" appStopClick (click)="selectAll(true)"> <button class="dropdown-item" appStopClick (click)="selectAll(true)">
<i class="fa fa-fw fa-check-square-o" aria-hidden="true"></i> <i class="fa fa-fw fa-check-square-o" aria-hidden="true"></i>

View File

@ -25,7 +25,7 @@ import { UserService } from 'jslib/abstractions/user.service';
import { OrganizationUserConfirmRequest } from 'jslib/models/request/organizationUserConfirmRequest'; import { OrganizationUserConfirmRequest } from 'jslib/models/request/organizationUserConfirmRequest';
import { UserBulkReinviteRequest } from 'jslib/models/request/userBulkReinviteRequest'; import { OrganizationUserBulkRequest } from 'jslib/models/request/organizationUserBulkRequest';
import { OrganizationUserUserDetailsResponse } from 'jslib/models/response/organizationUserResponse'; import { OrganizationUserUserDetailsResponse } from 'jslib/models/response/organizationUserResponse';
import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType'; import { OrganizationUserStatusType } from 'jslib/enums/organizationUserStatusType';
@ -260,6 +260,37 @@ export class PeopleComponent implements OnInit {
this.actionPromise = null; this.actionPromise = null;
} }
async bulkRemove() {
if (this.actionPromise != null) {
return;
}
const users = this.getCheckedUsers();
if (users.length <= 0) {
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
this.i18nService.t('noSelectedUsersApplicable'));
return;
}
const confirmed = await this.platformUtilsService.showDialog(
this.i18nService.t('removeSelectedUsersConfirmation'), this.i18nService.t('remove'),
this.i18nService.t('yes'), this.i18nService.t('no'), 'warning');
if (!confirmed) {
return false;
}
const request = new OrganizationUserBulkRequest(users.map(user => user.id));
this.actionPromise = this.apiService.deleteManyOrganizationUsers(this.organizationId, request);
try {
await this.actionPromise;
this.toasterService.popAsync('success', null, this.i18nService.t('usersHasBeenRemoved'));
await this.load();
} catch (e) {
this.validationService.showError(e);
}
this.actionPromise = null;
}
async bulkReinvite() { async bulkReinvite() {
if (this.actionPromise != null) { if (this.actionPromise != null) {
return; return;
@ -273,7 +304,7 @@ export class PeopleComponent implements OnInit {
return; return;
} }
const request = new UserBulkReinviteRequest(users.map(user => user.id)); const request = new OrganizationUserBulkRequest(users.map(user => user.id));
this.actionPromise = this.apiService.postManyOrganizationUserReinvite(this.organizationId, request); this.actionPromise = this.apiService.postManyOrganizationUserReinvite(this.organizationId, request);
try { try {
await this.actionPromise; await this.actionPromise;

View File

@ -3905,5 +3905,11 @@
}, },
"usersHasBeenReinvited": { "usersHasBeenReinvited": {
"message": "The selected users have been reinvited." "message": "The selected users have been reinvited."
},
"removeSelectedUsersConfirmation": {
"message": "Are you sure you want to remove the selected users?"
},
"usersHasBeenRemoved": {
"message": "The selected users have been removed."
} }
} }