mirror of
https://github.com/bitwarden/browser
synced 2025-12-16 08:13:42 +00:00
* 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>
155 lines
5.5 KiB
TypeScript
155 lines
5.5 KiB
TypeScript
import {
|
|
Component,
|
|
ComponentFactoryResolver,
|
|
Input,
|
|
ViewChild,
|
|
ViewContainerRef,
|
|
} from '@angular/core';
|
|
import { ToasterService } from 'angular2-toaster';
|
|
|
|
import { I18nService } from 'jslib/abstractions/i18n.service';
|
|
|
|
import { Organization } from 'jslib/models/domain/organization';
|
|
|
|
import { ModalComponent } from '../modal.component';
|
|
|
|
import { BulkDeleteComponent } from './bulk-delete.component';
|
|
import { BulkMoveComponent } from './bulk-move.component';
|
|
import { BulkRestoreComponent } from './bulk-restore.component';
|
|
import { BulkShareComponent } from './bulk-share.component';
|
|
import { CiphersComponent } from './ciphers.component';
|
|
|
|
@Component({
|
|
selector: 'app-vault-bulk-actions',
|
|
templateUrl: 'bulk-actions.component.html',
|
|
})
|
|
export class BulkActionsComponent {
|
|
@Input() ciphersComponent: CiphersComponent;
|
|
@Input() modal: ModalComponent;
|
|
@Input() deleted: boolean;
|
|
@Input() organization: Organization;
|
|
|
|
@ViewChild('bulkDeleteTemplate', { read: ViewContainerRef }) bulkDeleteModalRef: ViewContainerRef;
|
|
@ViewChild('bulkRestoreTemplate', { read: ViewContainerRef }) bulkRestoreModalRef: ViewContainerRef;
|
|
@ViewChild('bulkMoveTemplate', { read: ViewContainerRef }) bulkMoveModalRef: ViewContainerRef;
|
|
@ViewChild('bulkShareTemplate', { read: ViewContainerRef }) bulkShareModalRef: ViewContainerRef;
|
|
|
|
constructor(private toasterService: ToasterService,
|
|
private i18nService: I18nService,
|
|
private componentFactoryResolver: ComponentFactoryResolver) { }
|
|
|
|
bulkDelete() {
|
|
const selectedIds = this.ciphersComponent.getSelectedIds();
|
|
if (selectedIds.length === 0) {
|
|
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
|
this.i18nService.t('nothingSelected'));
|
|
return;
|
|
}
|
|
|
|
if (this.modal != null) {
|
|
this.modal.close();
|
|
}
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
|
this.modal = this.bulkDeleteModalRef.createComponent(factory).instance;
|
|
const childComponent = this.modal.show<BulkDeleteComponent>(BulkDeleteComponent, this.bulkDeleteModalRef);
|
|
|
|
childComponent.permanent = this.deleted;
|
|
childComponent.cipherIds = selectedIds;
|
|
childComponent.organization = this.organization;
|
|
childComponent.onDeleted.subscribe(async () => {
|
|
this.modal.close();
|
|
await this.ciphersComponent.refresh();
|
|
});
|
|
|
|
this.modal.onClosed.subscribe(() => {
|
|
this.modal = null;
|
|
});
|
|
}
|
|
|
|
bulkRestore() {
|
|
const selectedIds = this.ciphersComponent.getSelectedIds();
|
|
if (selectedIds.length === 0) {
|
|
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
|
this.i18nService.t('nothingSelected'));
|
|
return;
|
|
}
|
|
|
|
if (this.modal != null) {
|
|
this.modal.close();
|
|
}
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
|
this.modal = this.bulkRestoreModalRef.createComponent(factory).instance;
|
|
const childComponent = this.modal.show<BulkRestoreComponent>(BulkRestoreComponent, this.bulkRestoreModalRef);
|
|
|
|
childComponent.cipherIds = selectedIds;
|
|
childComponent.onRestored.subscribe(async () => {
|
|
this.modal.close();
|
|
await this.ciphersComponent.refresh();
|
|
});
|
|
|
|
this.modal.onClosed.subscribe(() => {
|
|
this.modal = null;
|
|
});
|
|
}
|
|
|
|
bulkShare() {
|
|
const selectedCiphers = this.ciphersComponent.getSelected();
|
|
if (selectedCiphers.length === 0) {
|
|
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
|
this.i18nService.t('nothingSelected'));
|
|
return;
|
|
}
|
|
|
|
if (this.modal != null) {
|
|
this.modal.close();
|
|
}
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
|
this.modal = this.bulkShareModalRef.createComponent(factory).instance;
|
|
const childComponent = this.modal.show<BulkShareComponent>(BulkShareComponent, this.bulkShareModalRef);
|
|
|
|
childComponent.ciphers = selectedCiphers;
|
|
childComponent.onShared.subscribe(async () => {
|
|
this.modal.close();
|
|
await this.ciphersComponent.refresh();
|
|
});
|
|
|
|
this.modal.onClosed.subscribe(async () => {
|
|
this.modal = null;
|
|
});
|
|
}
|
|
|
|
bulkMove() {
|
|
const selectedIds = this.ciphersComponent.getSelectedIds();
|
|
if (selectedIds.length === 0) {
|
|
this.toasterService.popAsync('error', this.i18nService.t('errorOccurred'),
|
|
this.i18nService.t('nothingSelected'));
|
|
return;
|
|
}
|
|
|
|
if (this.modal != null) {
|
|
this.modal.close();
|
|
}
|
|
|
|
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
|
|
this.modal = this.bulkMoveModalRef.createComponent(factory).instance;
|
|
const childComponent = this.modal.show<BulkMoveComponent>(BulkMoveComponent, this.bulkMoveModalRef);
|
|
|
|
childComponent.cipherIds = selectedIds;
|
|
childComponent.onMoved.subscribe(async () => {
|
|
this.modal.close();
|
|
await this.ciphersComponent.refresh();
|
|
});
|
|
|
|
this.modal.onClosed.subscribe(() => {
|
|
this.modal = null;
|
|
});
|
|
}
|
|
|
|
selectAll(select: boolean) {
|
|
this.ciphersComponent.selectAll(select);
|
|
}
|
|
}
|