1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-22 07:50:04 +02:00

Allow for the web generation dialog to disable the margin of the tools generation components (#11565)

This commit is contained in:
Nick Krantz 2024-10-18 15:57:34 -05:00 committed by GitHub
parent 97bf459424
commit 80a4fba787
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 29 additions and 4 deletions

View File

@ -6,6 +6,7 @@
<vault-cipher-form-generator <vault-cipher-form-generator
[type]="params.type" [type]="params.type"
(valueGenerated)="onValueGenerated($event)" (valueGenerated)="onValueGenerated($event)"
disableMargin
></vault-cipher-form-generator> ></vault-cipher-form-generator>
</ng-container> </ng-container>
<ng-container bitDialogFooter> <ng-container bitDialogFooter>

View File

@ -1,4 +1,4 @@
<bit-section> <bit-section [disableMargin]="disableMargin">
<bit-section-header *ngIf="showHeader"> <bit-section-header *ngIf="showHeader">
<h6 bitTypography="h6">{{ "options" | i18n }}</h6> <h6 bitTypography="h6">{{ "options" | i18n }}</h6>
</bit-section-header> </bit-section-header>

View File

@ -1,3 +1,4 @@
import { coerceBooleanProperty } from "@angular/cdk/coercion";
import { OnInit, Input, Output, EventEmitter, Component, OnDestroy } from "@angular/core"; import { OnInit, Input, Output, EventEmitter, Component, OnDestroy } from "@angular/core";
import { FormBuilder } from "@angular/forms"; import { FormBuilder } from "@angular/forms";
import { BehaviorSubject, skip, takeUntil, Subject } from "rxjs"; import { BehaviorSubject, skip, takeUntil, Subject } from "rxjs";
@ -47,6 +48,9 @@ export class PassphraseSettingsComponent implements OnInit, OnDestroy {
@Input() @Input()
showHeader: boolean = true; showHeader: boolean = true;
/** Removes bottom margin from `bit-section` */
@Input({ transform: coerceBooleanProperty }) disableMargin = false;
/** Emits settings updates and completes if the settings become unavailable. /** Emits settings updates and completes if the settings become unavailable.
* @remarks this does not emit the initial settings. If you would like * @remarks this does not emit the initial settings. If you would like
* to receive live settings updates including the initial update, * to receive live settings updates including the initial update,

View File

@ -32,6 +32,7 @@
class="tw-mt-6" class="tw-mt-6"
*ngIf="(algorithm$ | async)?.id === 'password'" *ngIf="(algorithm$ | async)?.id === 'password'"
[userId]="this.userId$ | async" [userId]="this.userId$ | async"
[disableMargin]="disableMargin"
(onUpdated)="generate$.next()" (onUpdated)="generate$.next()"
/> />
<tools-passphrase-settings <tools-passphrase-settings
@ -39,4 +40,5 @@
*ngIf="(algorithm$ | async)?.id === 'passphrase'" *ngIf="(algorithm$ | async)?.id === 'passphrase'"
[userId]="this.userId$ | async" [userId]="this.userId$ | async"
(onUpdated)="generate$.next()" (onUpdated)="generate$.next()"
[disableMargin]="disableMargin"
/> />

View File

@ -1,3 +1,4 @@
import { coerceBooleanProperty } from "@angular/cdk/coercion";
import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output } from "@angular/core"; import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output } from "@angular/core";
import { import {
BehaviorSubject, BehaviorSubject,
@ -45,6 +46,9 @@ export class PasswordGeneratorComponent implements OnInit, OnDestroy {
@Input() @Input()
userId: UserId | null; userId: UserId | null;
/** Removes bottom margin, passed to downstream components */
@Input({ transform: coerceBooleanProperty }) disableMargin = false;
/** tracks the currently selected credential type */ /** tracks the currently selected credential type */
protected credentialType$ = new BehaviorSubject<PasswordAlgorithm>(null); protected credentialType$ = new BehaviorSubject<PasswordAlgorithm>(null);

View File

@ -1,4 +1,4 @@
<bit-section> <bit-section [disableMargin]="disableMargin">
<bit-section-header *ngIf="showHeader"> <bit-section-header *ngIf="showHeader">
<h2 bitTypography="h6">{{ "options" | i18n }}</h2> <h2 bitTypography="h6">{{ "options" | i18n }}</h2>
</bit-section-header> </bit-section-header>

View File

@ -1,3 +1,4 @@
import { coerceBooleanProperty } from "@angular/cdk/coercion";
import { OnInit, Input, Output, EventEmitter, Component, OnDestroy } from "@angular/core"; import { OnInit, Input, Output, EventEmitter, Component, OnDestroy } from "@angular/core";
import { FormBuilder } from "@angular/forms"; import { FormBuilder } from "@angular/forms";
import { BehaviorSubject, takeUntil, Subject, map, filter, tap, debounceTime, skip } from "rxjs"; import { BehaviorSubject, takeUntil, Subject, map, filter, tap, debounceTime, skip } from "rxjs";
@ -55,6 +56,9 @@ export class PasswordSettingsComponent implements OnInit, OnDestroy {
@Input() @Input()
waitMs: number = 100; waitMs: number = 100;
/** Removes bottom margin from `bit-section` */
@Input({ transform: coerceBooleanProperty }) disableMargin = false;
/** Emits settings updates and completes if the settings become unavailable. /** Emits settings updates and completes if the settings become unavailable.
* @remarks this does not emit the initial settings. If you would like * @remarks this does not emit the initial settings. If you would like
* to receive live settings updates including the initial update, * to receive live settings updates including the initial update,

View File

@ -17,11 +17,11 @@
</button> </button>
</div> </div>
</bit-card> </bit-card>
<bit-section> <bit-section [disableMargin]="disableMargin">
<bit-section-header> <bit-section-header>
<h6 bitTypography="h6">{{ "options" | i18n }}</h6> <h6 bitTypography="h6">{{ "options" | i18n }}</h6>
</bit-section-header> </bit-section-header>
<div class="tw-mb-4"> <div [ngClass]="{ 'tw-mb-4': !disableMargin }">
<bit-card> <bit-card>
<form class="box" [formGroup]="credential" class="tw-container"> <form class="box" [formGroup]="credential" class="tw-container">
<bit-form-field> <bit-form-field>

View File

@ -1,3 +1,4 @@
import { coerceBooleanProperty } from "@angular/cdk/coercion";
import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output } from "@angular/core"; import { Component, EventEmitter, Input, NgZone, OnDestroy, OnInit, Output } from "@angular/core";
import { FormBuilder } from "@angular/forms"; import { FormBuilder } from "@angular/forms";
import { import {
@ -57,6 +58,9 @@ export class UsernameGeneratorComponent implements OnInit, OnDestroy {
@Output() @Output()
readonly onGenerated = new EventEmitter<GeneratedCredential>(); readonly onGenerated = new EventEmitter<GeneratedCredential>();
/** Removes bottom margin from internal elements */
@Input({ transform: coerceBooleanProperty }) disableMargin = false;
/** Tracks the selected generation algorithm */ /** Tracks the selected generation algorithm */
protected credential = this.formBuilder.group({ protected credential = this.formBuilder.group({
type: [null as CredentialAlgorithm], type: [null as CredentialAlgorithm],

View File

@ -1,8 +1,10 @@
<tools-password-generator <tools-password-generator
*ngIf="type === 'password'" *ngIf="type === 'password'"
[disableMargin]="disableMargin"
(onGenerated)="onCredentialGenerated($event)" (onGenerated)="onCredentialGenerated($event)"
></tools-password-generator> ></tools-password-generator>
<tools-username-generator <tools-username-generator
*ngIf="type === 'username'" *ngIf="type === 'username'"
[disableMargin]="disableMargin"
(onGenerated)="onCredentialGenerated($event)" (onGenerated)="onCredentialGenerated($event)"
></tools-username-generator> ></tools-username-generator>

View File

@ -1,3 +1,4 @@
import { coerceBooleanProperty } from "@angular/cdk/coercion";
import { CommonModule } from "@angular/common"; import { CommonModule } from "@angular/common";
import { Component, EventEmitter, Input, Output } from "@angular/core"; import { Component, EventEmitter, Input, Output } from "@angular/core";
@ -21,6 +22,9 @@ export class CipherFormGeneratorComponent {
@Input({ required: true }) @Input({ required: true })
type: "password" | "username"; type: "password" | "username";
/** Removes bottom margin of internal sections */
@Input({ transform: coerceBooleanProperty }) disableMargin = false;
/** /**
* Emits an event when a new value is generated. * Emits an event when a new value is generated.
*/ */