1
0
mirror of https://github.com/bitwarden/web synced 2025-12-19 17:53:22 +00:00

Add show/hide button to password prompt (#1034)

This commit is contained in:
Oscar Hinton
2021-08-27 14:50:58 +02:00
committed by GitHub
parent 7c8e95d408
commit fa4e5250b9
41 changed files with 697 additions and 1234 deletions

View File

@@ -1,5 +1,4 @@
import {
ComponentFactoryResolver,
Directive,
ViewChild,
ViewContainerRef,
@@ -9,13 +8,14 @@ import { CipherView } from 'jslib-common/models/view/cipherView';
import { Organization } from 'jslib-common/models/domain/organization';
import { ModalComponent } from '../modal.component';
import { AddEditComponent as OrgAddEditComponent } from '../organizations/vault/add-edit.component';
import { AddEditComponent } from '../vault/add-edit.component';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
@Directive()
export class CipherReportComponent {
@ViewChild('cipherAddEdit', { read: ViewContainerRef, static: true }) cipherAddEditModalRef: ViewContainerRef;
@@ -25,9 +25,7 @@ export class CipherReportComponent {
ciphers: CipherView[] = [];
organization: Organization;
private modal: ModalComponent = null;
constructor(private componentFactoryResolver: ComponentFactoryResolver, protected userService: UserService,
constructor(private modalService: ModalService, protected userService: UserService,
protected messagingService: MessagingService, public requiresPaid: boolean) { }
async load() {
@@ -37,40 +35,29 @@ export class CipherReportComponent {
this.hasLoaded = true;
}
selectCipher(cipher: CipherView) {
if (this.modal != null) {
this.modal.close();
}
async selectCipher(cipher: CipherView) {
const type = this.organization != null ? OrgAddEditComponent : AddEditComponent;
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
this.modal = this.cipherAddEditModalRef.createComponent(factory).instance;
let childComponent: OrgAddEditComponent | AddEditComponent;
if (this.organization != null) {
childComponent = this.modal.show<OrgAddEditComponent>(OrgAddEditComponent, this.cipherAddEditModalRef);
(childComponent as OrgAddEditComponent).organization = this.organization;
} else {
childComponent = this.modal.show<AddEditComponent>(AddEditComponent, this.cipherAddEditModalRef);
}
const [modal, childComponent] = await this.modalService.openViewRef(type, this.cipherAddEditModalRef, (comp: OrgAddEditComponent | AddEditComponent) => {
if (this.organization != null) {
(comp as OrgAddEditComponent).organization = this.organization;
comp.organizationId = this.organization.id;
}
childComponent.cipherId = cipher == null ? null : cipher.id;
if (this.organization != null) {
childComponent.organizationId = this.organization.id;
}
childComponent.onSavedCipher.subscribe(async (c: CipherView) => {
this.modal.close();
await this.load();
});
childComponent.onDeletedCipher.subscribe(async (c: CipherView) => {
this.modal.close();
await this.load();
});
childComponent.onRestoredCipher.subscribe(async (c: CipherView) => {
this.modal.close();
await this.load();
});
comp.cipherId = cipher == null ? null : cipher.id;
comp.onSavedCipher.subscribe(async (c: CipherView) => {
modal.close();
await this.load();
});
comp.onDeletedCipher.subscribe(async (c: CipherView) => {
modal.close();
await this.load();
});
comp.onRestoredCipher.subscribe(async (c: CipherView) => {
modal.close();
await this.load();
});
this.modal.onClosed.subscribe(() => {
this.modal = null;
});
return childComponent;