PM-4977 Migrate Preferences component (#8663)

* PM-4977 Migrate Preferences component

* PM-4977 Addressed the review comments

* PM-4977 Updated css in preferences html

* PM-4977 Removed the class applied on bit-hint
This commit is contained in:
KiruthigaManivannan 2024-06-06 20:46:59 +05:30 committed by GitHub
parent 0f9f7f4df6
commit c8eac6fa12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 77 additions and 112 deletions

View File

@ -1,10 +1,8 @@
<app-header></app-header> <app-header></app-header>
<bit-container> <bit-container>
<p>{{ "preferencesDesc" | i18n }}</p> <p bitTypography="body1">{{ "preferencesDesc" | i18n }}</p>
<form [formGroup]="form" (ngSubmit)="submit()" ngNativeValidate> <form [formGroup]="form" [bitSubmit]="submit" class="tw-w-1/2">
<div class="row">
<div class="col-6">
<app-callout type="info" *ngIf="vaultTimeoutPolicyCallout | async as policy"> <app-callout type="info" *ngIf="vaultTimeoutPolicyCallout | async as policy">
<span *ngIf="policy.timeout && policy.action"> <span *ngIf="policy.timeout && policy.action">
{{ {{
@ -25,54 +23,36 @@
ngDefaultControl ngDefaultControl
> >
</app-vault-timeout-input> </app-vault-timeout-input>
</div>
</div>
<ng-container *ngIf="availableVaultTimeoutActions$ | async as availableVaultTimeoutActions"> <ng-container *ngIf="availableVaultTimeoutActions$ | async as availableVaultTimeoutActions">
<div *ngIf="availableVaultTimeoutActions.length > 1" class="form-group"> <bit-radio-group
<label>{{ "vaultTimeoutAction" | i18n }}</label> formControlName="vaultTimeoutAction"
<div *ngIf="availableVaultTimeoutActions.length > 1"
>
<bit-label>{{ "vaultTimeoutAction" | i18n }}</bit-label>
<bit-radio-button
*ngIf="availableVaultTimeoutActions.includes(VaultTimeoutAction.Lock)" *ngIf="availableVaultTimeoutActions.includes(VaultTimeoutAction.Lock)"
class="form-check form-check-block"
>
<input
class="form-check-input"
type="radio"
name="vaultTimeoutAction"
id="vaultTimeoutActionLock" id="vaultTimeoutActionLock"
value="{{ VaultTimeoutAction.Lock }}" [value]="VaultTimeoutAction.Lock"
formControlName="vaultTimeoutAction"
/>
<label class="form-check-label" for="vaultTimeoutActionLock">
{{ "lock" | i18n }}
<small>{{ "vaultTimeoutActionLockDesc" | i18n }}</small>
</label>
</div>
<div
*ngIf="availableVaultTimeoutActions.includes(VaultTimeoutAction.LogOut)"
class="form-check mt-2 form-check-block"
> >
<input <bit-label>{{ "lock" | i18n }}</bit-label>
class="form-check-input" <bit-hint>{{ "vaultTimeoutActionLockDesc" | i18n }}</bit-hint>
type="radio" </bit-radio-button>
name="vaultTimeoutAction" <bit-radio-button
*ngIf="availableVaultTimeoutActions.includes(VaultTimeoutAction.LogOut)"
id="vaultTimeoutActionLogOut" id="vaultTimeoutActionLogOut"
value="{{ VaultTimeoutAction.LogOut }}" [value]="VaultTimeoutAction.LogOut"
formControlName="vaultTimeoutAction" >
/> <bit-label>{{ "logOut" | i18n }}</bit-label>
<label class="form-check-label" for="vaultTimeoutActionLogOut"> <bit-hint>{{ "vaultTimeoutActionLogOutDesc" | i18n }}</bit-hint>
{{ "logOut" | i18n }} </bit-radio-button>
<small>{{ "vaultTimeoutActionLogOutDesc" | i18n }}</small> </bit-radio-group>
</label>
</div>
</div>
</ng-container> </ng-container>
<div class="row"> <bit-form-field>
<div class="col-6"> <bit-label
<div class="form-group"> >{{ "language" | i18n }}
<div class="d-flex">
<label for="locale">{{ "language" | i18n }}</label>
<a <a
class="ml-auto" bitLink
class="tw-float-right"
href="https://bitwarden.com/help/localization/" href="https://bitwarden.com/help/localization/"
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
@ -80,27 +60,18 @@
> >
<i class="bwi bwi-question-circle" aria-hidden="true"></i> <i class="bwi bwi-question-circle" aria-hidden="true"></i>
</a> </a>
</div> </bit-label>
<select id="locale" name="Locale" formControlName="locale" class="form-control"> <bit-select formControlName="locale" id="locale">
<option *ngFor="let o of localeOptions" [ngValue]="o.value">{{ o.name }}</option> <bit-option *ngFor="let o of localeOptions" [value]="o.value" [label]="o.name"></bit-option>
</select> </bit-select>
<small class="form-text text-muted">{{ "languageDesc" | i18n }}</small> <bit-hint>{{ "languageDesc" | i18n }}</bit-hint>
</div> </bit-form-field>
</div> <bit-form-control>
</div> <input type="checkbox" bitCheckbox formControlName="enableFavicons" />
<div class="form-group"> <bit-label
<div class="form-check"> >{{ "enableFavicon" | i18n }}
<input
class="form-check-input"
type="checkbox"
id="enableFavicons"
name="enableFavicons"
formControlName="enableFavicons"
/>
<label class="form-check-label" for="enableFavicons">
{{ "enableFavicon" | i18n }}
</label>
<a <a
bitLink
href="https://bitwarden.com/help/website-icons/" href="https://bitwarden.com/help/website-icons/"
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
@ -108,22 +79,16 @@
> >
<i class="bwi bwi-question-circle" aria-hidden="true"></i> <i class="bwi bwi-question-circle" aria-hidden="true"></i>
</a> </a>
</div> </bit-label>
<small class="form-text text-muted">{{ "faviconDesc" | i18n }}</small> <bit-hint>{{ "faviconDesc" | i18n }}</bit-hint>
</div> </bit-form-control>
<div class="row"> <bit-form-field>
<div class="col-6"> <bit-label>{{ "theme" | i18n }}</bit-label>
<div class="form-group"> <bit-select formControlName="theme" id="theme">
<label for="theme">{{ "theme" | i18n }}</label> <bit-option *ngFor="let o of themeOptions" [value]="o.value" [label]="o.name"></bit-option>
<select id="theme" name="theme" formControlName="theme" class="form-control"> </bit-select>
<option *ngFor="let o of themeOptions" [ngValue]="o.value">{{ o.name }}</option> <bit-hint>{{ "themeDesc" | i18n }}</bit-hint>
</select> </bit-form-field>
<small class="form-text text-muted">{{ "themeDesc" | i18n }}</small> <button bitButton bitFormButton type="submit" buttonType="primary">{{ "save" | i18n }}</button>
</div>
</div>
</div>
<button type="submit" class="btn btn-primary">
{{ "save" | i18n }}
</button>
</form> </form>
</bit-container> </bit-container>

View File

@ -158,7 +158,7 @@ export class PreferencesComponent implements OnInit {
this.form.setValue(initialFormValues, { emitEvent: false }); this.form.setValue(initialFormValues, { emitEvent: false });
} }
async submit() { submit = async () => {
if (!this.form.controls.vaultTimeout.valid) { if (!this.form.controls.vaultTimeout.valid) {
this.platformUtilsService.showToast( this.platformUtilsService.showToast(
"error", "error",
@ -188,7 +188,7 @@ export class PreferencesComponent implements OnInit {
this.i18nService.t("preferencesUpdated"), this.i18nService.t("preferencesUpdated"),
); );
} }
} };
ngOnDestroy() { ngOnDestroy() {
this.destroy$.next(); this.destroy$.next();