1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-27 13:43:41 +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;

View File

@@ -1,6 +1,5 @@
import {
Component,
ComponentFactoryResolver,
OnInit,
} from '@angular/core';
@@ -9,6 +8,8 @@ import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
import { CipherView } from 'jslib-common/models/view/cipherView';
import { CipherType } from 'jslib-common/enums/cipherType';
@@ -23,9 +24,9 @@ export class ExposedPasswordsReportComponent extends CipherReportComponent imple
exposedPasswordMap = new Map<string, number>();
constructor(protected cipherService: CipherService, protected auditService: AuditService,
componentFactoryResolver: ComponentFactoryResolver, messagingService: MessagingService,
modalService: ModalService, messagingService: MessagingService,
userService: UserService) {
super(componentFactoryResolver, userService, messagingService, true);
super(modalService, userService, messagingService, true);
}
ngOnInit() {

View File

@@ -1,6 +1,5 @@
import {
Component,
ComponentFactoryResolver,
OnInit,
} from '@angular/core';
@@ -8,6 +7,8 @@ import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
import { CipherView } from 'jslib-common/models/view/cipherView';
import { CipherType } from 'jslib-common/enums/cipherType';
@@ -24,9 +25,9 @@ export class InactiveTwoFactorReportComponent extends CipherReportComponent impl
services = new Map<string, string>();
cipherDocs = new Map<string, string>();
constructor(protected cipherService: CipherService, componentFactoryResolver: ComponentFactoryResolver,
constructor(protected cipherService: CipherService, modalService: ModalService,
messagingService: MessagingService, userService: UserService) {
super(componentFactoryResolver, userService, messagingService, true);
super(modalService, userService, messagingService, true);
}
async ngOnInit() {

View File

@@ -1,6 +1,5 @@
import {
Component,
ComponentFactoryResolver,
ViewChild,
ViewContainerRef,
} from '@angular/core';
@@ -13,7 +12,7 @@ import {
PasswordGeneratorComponent as BasePasswordGeneratorComponent,
} from 'jslib-angular/components/password-generator.component';
import { ModalComponent } from '../modal.component';
import { ModalService } from 'jslib-angular/services/modal.service';
import { PasswordGeneratorHistoryComponent } from './password-generator-history.component';
@Component({
@@ -23,25 +22,13 @@ import { PasswordGeneratorHistoryComponent } from './password-generator-history.
export class PasswordGeneratorComponent extends BasePasswordGeneratorComponent {
@ViewChild('historyTemplate', { read: ViewContainerRef, static: true }) historyModalRef: ViewContainerRef;
private modal: ModalComponent = null;
constructor(passwordGenerationService: PasswordGenerationService, platformUtilsService: PlatformUtilsService,
i18nService: I18nService, private componentFactoryResolver: ComponentFactoryResolver) {
i18nService: I18nService, private modalService: ModalService) {
super(passwordGenerationService, platformUtilsService, i18nService, window);
}
history() {
if (this.modal != null) {
this.modal.close();
}
const factory = this.componentFactoryResolver.resolveComponentFactory(ModalComponent);
this.modal = this.historyModalRef.createComponent(factory).instance;
this.modal.show<PasswordGeneratorHistoryComponent>(PasswordGeneratorHistoryComponent, this.historyModalRef);
this.modal.onClosed.subscribe(async () => {
this.modal = null;
});
async history() {
await this.modalService.openViewRef(PasswordGeneratorHistoryComponent, this.historyModalRef);
}
lengthChanged() {

View File

@@ -1,6 +1,5 @@
import {
Component,
ComponentFactoryResolver,
OnInit,
} from '@angular/core';
@@ -8,6 +7,8 @@ import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
import { CipherView } from 'jslib-common/models/view/cipherView';
import { CipherType } from 'jslib-common/enums/cipherType';
@@ -21,9 +22,9 @@ import { CipherReportComponent } from './cipher-report.component';
export class ReusedPasswordsReportComponent extends CipherReportComponent implements OnInit {
passwordUseMap: Map<string, number>;
constructor(protected cipherService: CipherService, componentFactoryResolver: ComponentFactoryResolver,
constructor(protected cipherService: CipherService, modalService: ModalService,
messagingService: MessagingService, userService: UserService) {
super(componentFactoryResolver, userService, messagingService, true);
super(modalService, userService, messagingService, true);
}
async ngOnInit() {

View File

@@ -1,6 +1,5 @@
import {
Component,
ComponentFactoryResolver,
OnInit,
} from '@angular/core';
@@ -8,6 +7,8 @@ import { CipherService } from 'jslib-common/abstractions/cipher.service';
import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
import { CipherType } from 'jslib-common/enums/cipherType';
import { CipherView } from 'jslib-common/models/view/cipherView';
@@ -19,9 +20,9 @@ import { CipherReportComponent } from './cipher-report.component';
templateUrl: 'unsecured-websites-report.component.html',
})
export class UnsecuredWebsitesReportComponent extends CipherReportComponent implements OnInit {
constructor(protected cipherService: CipherService, componentFactoryResolver: ComponentFactoryResolver,
constructor(protected cipherService: CipherService, modalService: ModalService,
messagingService: MessagingService, userService: UserService) {
super(componentFactoryResolver, userService, messagingService, true);
super(modalService, userService, messagingService, true);
}
async ngOnInit() {

View File

@@ -1,6 +1,5 @@
import {
Component,
ComponentFactoryResolver,
OnInit,
} from '@angular/core';
@@ -9,6 +8,8 @@ import { MessagingService } from 'jslib-common/abstractions/messaging.service';
import { PasswordGenerationService } from 'jslib-common/abstractions/passwordGeneration.service';
import { UserService } from 'jslib-common/abstractions/user.service';
import { ModalService } from 'jslib-angular/services/modal.service';
import { CipherView } from 'jslib-common/models/view/cipherView';
import { CipherType } from 'jslib-common/enums/cipherType';
@@ -26,9 +27,9 @@ export class WeakPasswordsReportComponent extends CipherReportComponent implemen
private passwordStrengthCache = new Map<string, number>();
constructor(protected cipherService: CipherService, protected passwordGenerationService: PasswordGenerationService,
componentFactoryResolver: ComponentFactoryResolver, messagingService: MessagingService,
modalService: ModalService, messagingService: MessagingService,
userService: UserService) {
super(componentFactoryResolver, userService, messagingService, true);
super(modalService, userService, messagingService, true);
}
async ngOnInit() {