1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-19 09:43:23 +00:00

[PM-17820] - Browser/Web - update button and label state in username generator (#13189)

* add event handling for username generator

* fix specs. change function name to not be of an event type

* update specs

* rename function

* revert name change

* fix spec

* bubble algorithmSelected up to generator components. add disabled button tests

* add typeSelected event

* revert addition of onType.

* apply same logic in onAlgorithmSelected to web and desktop
This commit is contained in:
Jordan Aasen
2025-03-03 11:44:34 -08:00
committed by GitHub
parent d01f0c6bc4
commit 13213585b2
9 changed files with 205 additions and 97 deletions

View File

@@ -1,5 +1,3 @@
// FIXME: Update this file to be type safe and remove this and next line
// @ts-strict-ignore
import { coerceBooleanProperty } from "@angular/cdk/coercion";
import { CommonModule } from "@angular/common";
import { Component, EventEmitter, Input, Output } from "@angular/core";
@@ -18,9 +16,6 @@ import { AlgorithmInfo, GeneratedCredential } from "@bitwarden/generator-core";
imports: [CommonModule, GeneratorModule],
})
export class CipherFormGeneratorComponent {
@Input()
onAlgorithmSelected: (selected: AlgorithmInfo) => void;
@Input()
uri: string = "";
@@ -28,17 +23,25 @@ export class CipherFormGeneratorComponent {
* The type of generator form to show.
*/
@Input({ required: true })
type: "password" | "username";
type: "password" | "username" = "password";
/** Removes bottom margin of internal sections */
@Input({ transform: coerceBooleanProperty }) disableMargin = false;
@Output()
algorithmSelected = new EventEmitter<AlgorithmInfo>();
/**
* Emits an event when a new value is generated.
*/
@Output()
valueGenerated = new EventEmitter<string>();
/** Event handler for when an algorithm is selected */
onAlgorithmSelected = (selected: AlgorithmInfo) => {
this.algorithmSelected.emit(selected);
};
/** Event handler for both generation components */
onCredentialGenerated = (generatedCred: GeneratedCredential) => {
this.valueGenerated.emit(generatedCred.credential);