mirror of
https://github.com/bitwarden/web
synced 2025-12-20 10:13:15 +00:00
Allow Bulk Delete In Org Vault (#577)
* added the multi select checkbox to org ciphers * wired up select all/none * allowed for bulk delete of ciphers from the org vault * refactored bulk actions into a dedicated component * tweaked formatting settings and reformatted files * moved some shared code to jslib * some more formatting fixes * undid jslib connection changes * removed a function that was moved to jslib * reset jslib again? * set up delete many w/admin cipher methods * removed extra href tags * added organization id to bulk delete request model when coming from an org vault * fixed up some compiler warnings for formatting * code review fixups for bulk delete from org vault * added back a removed parameter from the vault component * seperated some imports with newlines * updated jslib * resolved some build errors * code review cleanup for bulk delete from an org vault * code review cleanup for bulk delete from an org vault * code review cleanup for bulk delete from an org vault * code review cleanup for bulk delete from an org vault * updated jslib to latest Co-authored-by: Addison Beck <addisonbeck@MacBook-Pro.local>
This commit is contained in:
@@ -4,13 +4,16 @@ import {
|
||||
Input,
|
||||
Output,
|
||||
} from '@angular/core';
|
||||
|
||||
import { ToasterService } from 'angular2-toaster';
|
||||
import { Angulartics2 } from 'angulartics2';
|
||||
|
||||
import { ApiService } from 'jslib/abstractions/api.service';
|
||||
import { CipherService } from 'jslib/abstractions/cipher.service';
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
|
||||
import { Organization } from 'jslib/models/domain/organization';
|
||||
import { CipherBulkDeleteRequest } from 'jslib/models/request/cipherBulkDeleteRequest';
|
||||
|
||||
@Component({
|
||||
selector: 'app-vault-bulk-delete',
|
||||
templateUrl: 'bulk-delete.component.html',
|
||||
@@ -18,20 +21,44 @@ import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
export class BulkDeleteComponent {
|
||||
@Input() cipherIds: string[] = [];
|
||||
@Input() permanent: boolean = false;
|
||||
@Input() organization: Organization;
|
||||
@Output() onDeleted = new EventEmitter();
|
||||
|
||||
formPromise: Promise<any>;
|
||||
|
||||
constructor(private analytics: Angulartics2, private cipherService: CipherService,
|
||||
private toasterService: ToasterService, private i18nService: I18nService) { }
|
||||
private toasterService: ToasterService, private i18nService: I18nService,
|
||||
private apiService: ApiService) { }
|
||||
|
||||
async submit() {
|
||||
this.formPromise = this.permanent ? this.cipherService.deleteManyWithServer(this.cipherIds) :
|
||||
this.cipherService.softDeleteManyWithServer(this.cipherIds);
|
||||
if (!this.organization || !this.organization.isAdmin) {
|
||||
await this.deleteCiphers();
|
||||
} else {
|
||||
await this.deleteCiphersAdmin();
|
||||
}
|
||||
|
||||
await this.formPromise;
|
||||
|
||||
this.onDeleted.emit();
|
||||
this.analytics.eventTrack.next({ action: 'Bulk Deleted Items' });
|
||||
this.toasterService.popAsync('success', null, this.i18nService.t(this.permanent ? 'permanentlyDeletedItems'
|
||||
: 'deletedItems'));
|
||||
}
|
||||
|
||||
private async deleteCiphers() {
|
||||
if (this.permanent) {
|
||||
this.formPromise = await this.cipherService.deleteManyWithServer(this.cipherIds);
|
||||
} else {
|
||||
this.formPromise = await this.cipherService.softDeleteManyWithServer(this.cipherIds);
|
||||
}
|
||||
}
|
||||
|
||||
private async deleteCiphersAdmin() {
|
||||
const deleteRequest = new CipherBulkDeleteRequest(this.cipherIds, this.organization.id);
|
||||
if (this.permanent) {
|
||||
this.formPromise = await this.apiService.deleteManyCiphersAdmin(deleteRequest);
|
||||
} else {
|
||||
this.formPromise = await this.apiService.putDeleteManyCiphersAdmin(deleteRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user