1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 14:23:32 +00:00

use valueLabel with appCopyClick directive (#11718)

* add `valueLabel` to `appCopyClick` directives 
* move generated value description to the configuration
This commit is contained in:
✨ Audrey ✨
2024-10-25 17:43:49 -04:00
committed by GitHub
parent 5f0755d74d
commit c780cbc77e
10 changed files with 46 additions and 4 deletions

View File

@@ -32,6 +32,7 @@
showToast showToast
[appA11yTitle]="credentialTypeCopyLabel$ | async" [appA11yTitle]="credentialTypeCopyLabel$ | async"
[appCopyClick]="value$ | async" [appCopyClick]="value$ | async"
[valueLabel]="credentialTypeLabel$ | async"
></button> ></button>
</div> </div>
</bit-card> </bit-card>

View File

@@ -468,6 +468,14 @@ export class CredentialGeneratorComponent implements OnInit, OnDestroy {
map(({ generate }) => generate), map(({ generate }) => generate),
); );
/**
* Emits the copy credential toast respective of the selected credential type
*/
protected credentialTypeLabel$ = this.algorithm$.pipe(
filter((algorithm) => !!algorithm),
map(({ generatedValue }) => generatedValue),
);
/** Emits hint key for the currently selected credential type */ /** Emits hint key for the currently selected credential type */
protected credentialTypeHint$ = new ReplaySubject<string>(1); protected credentialTypeHint$ = new ReplaySubject<string>(1);

View File

@@ -30,6 +30,7 @@
showToast showToast
[appA11yTitle]="credentialTypeCopyLabel$ | async" [appA11yTitle]="credentialTypeCopyLabel$ | async"
[appCopyClick]="value$ | async" [appCopyClick]="value$ | async"
[valueLabel]="credentialTypeLabel$ | async"
></button> ></button>
</div> </div>
</bit-card> </bit-card>

View File

@@ -233,6 +233,14 @@ export class PasswordGeneratorComponent implements OnInit, OnDestroy {
map(({ generate }) => generate), map(({ generate }) => generate),
); );
/**
* Emits the copy credential toast respective of the selected credential type
*/
protected credentialTypeLabel$ = this.algorithm$.pipe(
filter((algorithm) => !!algorithm),
map(({ generatedValue }) => generatedValue),
);
private toOptions(algorithms: AlgorithmInfo[]) { private toOptions(algorithms: AlgorithmInfo[]) {
const options: Option<CredentialAlgorithm>[] = algorithms.map((algorithm) => ({ const options: Option<CredentialAlgorithm>[] = algorithms.map((algorithm) => ({
value: algorithm.id, value: algorithm.id,

View File

@@ -19,6 +19,7 @@
showToast showToast
[appA11yTitle]="credentialTypeCopyLabel$ | async" [appA11yTitle]="credentialTypeCopyLabel$ | async"
[appCopyClick]="value$ | async" [appCopyClick]="value$ | async"
[valueLabel]="credentialTypeLabel$ | async"
> >
{{ credentialTypeCopyLabel$ | async }} {{ credentialTypeCopyLabel$ | async }}
</button> </button>

View File

@@ -390,6 +390,14 @@ export class UsernameGeneratorComponent implements OnInit, OnDestroy {
map(({ generate }) => generate), map(({ generate }) => generate),
); );
/**
* Emits the copy credential toast respective of the selected credential type
*/
protected credentialTypeLabel$ = this.algorithm$.pipe(
filter((algorithm) => !!algorithm),
map(({ generatedValue }) => generatedValue),
);
/** Emits hint key for the currently selected credential type */ /** Emits hint key for the currently selected credential type */
protected credentialTypeHint$ = new ReplaySubject<string>(1); protected credentialTypeHint$ = new ReplaySubject<string>(1);

View File

@@ -53,6 +53,7 @@ const PASSPHRASE = Object.freeze({
category: "password", category: "password",
nameKey: "passphrase", nameKey: "passphrase",
generateKey: "generatePassphrase", generateKey: "generatePassphrase",
generatedValueKey: "passphrase",
copyKey: "copyPassphrase", copyKey: "copyPassphrase",
onlyOnRequest: false, onlyOnRequest: false,
request: [], request: [],
@@ -95,6 +96,7 @@ const PASSWORD = Object.freeze({
category: "password", category: "password",
nameKey: "password", nameKey: "password",
generateKey: "generatePassword", generateKey: "generatePassword",
generatedValueKey: "password",
copyKey: "copyPassword", copyKey: "copyPassword",
onlyOnRequest: false, onlyOnRequest: false,
request: [], request: [],
@@ -145,6 +147,7 @@ const USERNAME = Object.freeze({
category: "username", category: "username",
nameKey: "randomWord", nameKey: "randomWord",
generateKey: "generateUsername", generateKey: "generateUsername",
generatedValueKey: "username",
copyKey: "copyUsername", copyKey: "copyUsername",
onlyOnRequest: false, onlyOnRequest: false,
request: [], request: [],
@@ -181,6 +184,7 @@ const CATCHALL = Object.freeze({
nameKey: "catchallEmail", nameKey: "catchallEmail",
descriptionKey: "catchallEmailDesc", descriptionKey: "catchallEmailDesc",
generateKey: "generateEmail", generateKey: "generateEmail",
generatedValueKey: "email",
copyKey: "copyEmail", copyKey: "copyEmail",
onlyOnRequest: false, onlyOnRequest: false,
request: [], request: [],
@@ -217,6 +221,7 @@ const SUBADDRESS = Object.freeze({
nameKey: "plusAddressedEmail", nameKey: "plusAddressedEmail",
descriptionKey: "plusAddressedEmailDesc", descriptionKey: "plusAddressedEmailDesc",
generateKey: "generateEmail", generateKey: "generateEmail",
generatedValueKey: "email",
copyKey: "copyEmail", copyKey: "copyEmail",
onlyOnRequest: false, onlyOnRequest: false,
request: [], request: [],
@@ -256,6 +261,7 @@ export function toCredentialGeneratorConfiguration<Settings extends ApiSettings
nameKey: configuration.name, nameKey: configuration.name,
descriptionKey: "forwardedEmailDesc", descriptionKey: "forwardedEmailDesc",
generateKey: "generateEmail", generateKey: "generateEmail",
generatedValueKey: "email",
copyKey: "copyEmail", copyKey: "copyEmail",
onlyOnRequest: true, onlyOnRequest: true,
request: configuration.forwarder.request, request: configuration.forwarder.request,

View File

@@ -73,6 +73,7 @@ const SomeAlgorithm = "passphrase";
const SomeCategory = "password"; const SomeCategory = "password";
const SomeNameKey = "passphraseKey"; const SomeNameKey = "passphraseKey";
const SomeGenerateKey = "generateKey"; const SomeGenerateKey = "generateKey";
const SomeGeneratedValueKey = "generatedValueKey";
const SomeCopyKey = "copyKey"; const SomeCopyKey = "copyKey";
// fake the configuration // fake the configuration
@@ -81,6 +82,7 @@ const SomeConfiguration: CredentialGeneratorConfiguration<SomeSettings, SomePoli
category: SomeCategory, category: SomeCategory,
nameKey: SomeNameKey, nameKey: SomeNameKey,
generateKey: SomeGenerateKey, generateKey: SomeGenerateKey,
generatedValueKey: SomeGeneratedValueKey,
copyKey: SomeCopyKey, copyKey: SomeCopyKey,
onlyOnRequest: false, onlyOnRequest: false,
request: [], request: [],

View File

@@ -258,6 +258,7 @@ export class CredentialGeneratorService {
category: generator.category, category: generator.category,
name: integration ? integration.name : this.i18nService.t(generator.nameKey), name: integration ? integration.name : this.i18nService.t(generator.nameKey),
generate: this.i18nService.t(generator.generateKey), generate: this.i18nService.t(generator.generateKey),
generatedValue: this.i18nService.t(generator.generatedValueKey),
copy: this.i18nService.t(generator.copyKey), copy: this.i18nService.t(generator.copyKey),
onlyOnRequest: generator.onlyOnRequest, onlyOnRequest: generator.onlyOnRequest,
request: generator.request, request: generator.request,

View File

@@ -37,6 +37,9 @@ export type AlgorithmInfo = {
/* Localized copy button label */ /* Localized copy button label */
copy: string; copy: string;
/* Localized generated value label */
generatedValue: string;
/** Localized algorithm description */ /** Localized algorithm description */
description?: string; description?: string;
@@ -67,18 +70,21 @@ export type CredentialGeneratorInfo = {
/** The kind of credential generated by this configuration */ /** The kind of credential generated by this configuration */
category: CredentialCategory; category: CredentialCategory;
/** Key used to localize the credential name in the I18nService */ /** Localization key for the credential name */
nameKey: string; nameKey: string;
/** Key used to localize the credential description in the I18nService */ /** Localization key for the credential description*/
descriptionKey?: string; descriptionKey?: string;
/* Localized generate button label */ /* Localization key for the generate command label */
generateKey: string; generateKey: string;
/* Localized copy button label */ /* Localization key for the copy button label */
copyKey: string; copyKey: string;
/* Localization key for describing values generated by this generator */
generatedValueKey: string;
/** When true, credential generation must be explicitly requested. /** When true, credential generation must be explicitly requested.
* @remarks this property is useful when credential generation * @remarks this property is useful when credential generation
* carries side effects, such as configuring a service external * carries side effects, such as configuring a service external