mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 22:33:35 +00:00
* [PM-7896] Adjust cipher form container to expose config and original cipher view for children * [PM-7896] Add initial additional options section * [PM-7896] Add tests * [PM-7896] Add TODO comments for Custom Fields * [PM-7896] Hide password reprompt checkbox when unavailable * [PM-7896] Fix storybook
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import { CommonModule } from "@angular/common";
|
|
import { Component, OnInit } from "@angular/core";
|
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
|
import { shareReplay } from "rxjs";
|
|
|
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
|
import { CipherRepromptType } from "@bitwarden/common/vault/enums";
|
|
import {
|
|
CardComponent,
|
|
CheckboxModule,
|
|
FormFieldModule,
|
|
SectionComponent,
|
|
SectionHeaderComponent,
|
|
TypographyModule,
|
|
} from "@bitwarden/components";
|
|
|
|
import { PasswordRepromptService } from "../../../services/password-reprompt.service";
|
|
import { CipherFormContainer } from "../../cipher-form-container";
|
|
|
|
@Component({
|
|
selector: "vault-additional-options-section",
|
|
templateUrl: "./additional-options-section.component.html",
|
|
standalone: true,
|
|
imports: [
|
|
SectionComponent,
|
|
SectionHeaderComponent,
|
|
TypographyModule,
|
|
JslibModule,
|
|
CardComponent,
|
|
FormFieldModule,
|
|
ReactiveFormsModule,
|
|
CheckboxModule,
|
|
CommonModule,
|
|
],
|
|
})
|
|
export class AdditionalOptionsSectionComponent implements OnInit {
|
|
additionalOptionsForm = this.formBuilder.group({
|
|
notes: [null as string],
|
|
reprompt: [false],
|
|
});
|
|
|
|
passwordRepromptEnabled$ = this.passwordRepromptService.enabled$.pipe(
|
|
shareReplay({ refCount: false, bufferSize: 1 }),
|
|
);
|
|
|
|
constructor(
|
|
private cipherFormContainer: CipherFormContainer,
|
|
private formBuilder: FormBuilder,
|
|
private passwordRepromptService: PasswordRepromptService,
|
|
) {
|
|
this.cipherFormContainer.registerChildForm("additionalOptions", this.additionalOptionsForm);
|
|
|
|
this.additionalOptionsForm.valueChanges.pipe(takeUntilDestroyed()).subscribe((value) => {
|
|
this.cipherFormContainer.patchCipher({
|
|
notes: value.notes,
|
|
reprompt: value.reprompt ? CipherRepromptType.Password : CipherRepromptType.None,
|
|
});
|
|
});
|
|
}
|
|
|
|
ngOnInit() {
|
|
if (this.cipherFormContainer.originalCipherView) {
|
|
this.additionalOptionsForm.patchValue({
|
|
notes: this.cipherFormContainer.originalCipherView.notes,
|
|
reprompt:
|
|
this.cipherFormContainer.originalCipherView.reprompt === CipherRepromptType.Password,
|
|
});
|
|
}
|
|
|
|
if (this.cipherFormContainer.config.mode === "partial-edit") {
|
|
this.additionalOptionsForm.disable();
|
|
}
|
|
}
|
|
}
|