1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

Tools - Prefer signal & change detection (#16941)

This commit is contained in:
Oscar Hinton
2025-10-21 15:49:22 +02:00
committed by GitHub
parent 6abaaa7b13
commit f23f3f87bd
66 changed files with 329 additions and 11 deletions

View File

@@ -33,6 +33,8 @@ import { CredentialGeneratorService, GenerateRequest, Type } from "@bitwarden/ge
import { SendFormConfig } from "../../abstractions/send-form-config.service";
import { SendFormContainer } from "../../send-form-container";
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
@Component({
selector: "tools-send-options",
templateUrl: "./send-options.component.html",
@@ -52,8 +54,12 @@ import { SendFormContainer } from "../../send-form-container";
],
})
export class SendOptionsComponent implements OnInit {
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-signals
@Input({ required: true })
config: SendFormConfig;
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-signals
@Input()
originalSendView: SendView;
disableHideEmail = false;

View File

@@ -47,6 +47,8 @@ export interface DatePresetSelectOption {
value: DatePreset | string;
}
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
@Component({
selector: "tools-send-details",
templateUrl: "./send-details.component.html",
@@ -68,7 +70,11 @@ export interface DatePresetSelectOption {
],
})
export class SendDetailsComponent implements OnInit {
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-signals
@Input() config: SendFormConfig;
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-signals
@Input() originalSendView?: SendView;
FileSendType = SendType.File;

View File

@@ -17,6 +17,8 @@ import {
import { SendFormConfig } from "../../abstractions/send-form-config.service";
import { SendFormContainer } from "../../send-form-container";
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
@Component({
selector: "tools-send-file-details",
templateUrl: "./send-file-details.component.html",
@@ -32,8 +34,8 @@ import { SendFormContainer } from "../../send-form-container";
],
})
export class SendFileDetailsComponent implements OnInit {
config = input.required<SendFormConfig>();
originalSendView = input<SendView>();
readonly config = input.required<SendFormConfig>();
readonly originalSendView = input<SendView>();
sendFileDetailsForm = this.formBuilder.group({
file: this.formBuilder.control<SendFileView | null>(null, Validators.required),

View File

@@ -10,6 +10,8 @@ import { CheckboxModule, FormFieldModule, SectionComponent } from "@bitwarden/co
import { SendFormConfig } from "../../abstractions/send-form-config.service";
import { SendFormContainer } from "../../send-form-container";
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
@Component({
selector: "tools-send-text-details",
templateUrl: "./send-text-details.component.html",
@@ -23,8 +25,8 @@ import { SendFormContainer } from "../../send-form-container";
],
})
export class SendTextDetailsComponent implements OnInit {
config = input.required<SendFormConfig>();
originalSendView = input<SendView>();
readonly config = input.required<SendFormConfig>();
readonly originalSendView = input<SendView>();
sendTextDetailsForm = this.formBuilder.group({
text: new FormControl("", Validators.required),

View File

@@ -38,6 +38,8 @@ import { SendForm, SendFormContainer } from "../send-form-container";
import { SendDetailsComponent } from "./send-details/send-details.component";
// FIXME(https://bitwarden.atlassian.net/browse/CL-764): Migrate to OnPush
// eslint-disable-next-line @angular-eslint/prefer-on-push-component-change-detection
@Component({
selector: "tools-send-form",
templateUrl: "./send-form.component.html",
@@ -59,6 +61,8 @@ import { SendDetailsComponent } from "./send-details/send-details.component";
],
})
export class SendFormComponent implements AfterViewInit, OnInit, OnChanges, SendFormContainer {
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-signals
@ViewChild(BitSubmitDirective)
private bitSubmit: BitSubmitDirective;
private destroyRef = inject(DestroyRef);
@@ -68,27 +72,37 @@ export class SendFormComponent implements AfterViewInit, OnInit, OnChanges, Send
/**
* The form ID to use for the form. Used to connect it to a submit button.
*/
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-signals
@Input({ required: true }) formId: string;
/**
* The configuration for the add/edit form. Used to determine which controls are shown and what values are available.
*/
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-signals
@Input({ required: true }) config: SendFormConfig;
/**
* Optional submit button that will be disabled or marked as loading when the form is submitting.
*/
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-signals
@Input()
submitBtn?: ButtonComponent;
/**
* Event emitted when the send is created successfully.
*/
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-output-emitter-ref
@Output() onSendCreated = new EventEmitter<SendView>();
/**
* Event emitted when the send is updated successfully.
*/
// FIXME(https://bitwarden.atlassian.net/browse/CL-903): Migrate to Signals
// eslint-disable-next-line @angular-eslint/prefer-output-emitter-ref
@Output() onSendUpdated = new EventEmitter<SendView>();
/**