mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +00:00
Use Signal inputs and make files ts-strict compliant (#16778)
Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
da8a0104ea
commit
0df7215d6e
@@ -1,5 +1,3 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
|
|
||||||
@@ -15,10 +13,10 @@ import { FilePopoutUtilsService } from "../services/file-popout-utils.service";
|
|||||||
imports: [CommonModule, JslibModule, CalloutModule],
|
imports: [CommonModule, JslibModule, CalloutModule],
|
||||||
})
|
})
|
||||||
export class FilePopoutCalloutComponent implements OnInit {
|
export class FilePopoutCalloutComponent implements OnInit {
|
||||||
protected showFilePopoutMessage: boolean;
|
protected showFilePopoutMessage: boolean = false;
|
||||||
protected showFirefoxFileWarning: boolean;
|
protected showFirefoxFileWarning: boolean = false;
|
||||||
protected showSafariFileWarning: boolean;
|
protected showSafariFileWarning: boolean = false;
|
||||||
protected showChromiumFileWarning: boolean;
|
protected showChromiumFileWarning: boolean = false;
|
||||||
|
|
||||||
constructor(private filePopoutUtilsService: FilePopoutUtilsService) {}
|
constructor(private filePopoutUtilsService: FilePopoutUtilsService) {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, Input, OnInit } from "@angular/core";
|
import { Component, input, OnInit } from "@angular/core";
|
||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||||
@@ -18,7 +16,7 @@ import { SendFilePopoutDialogComponent } from "./send-file-popout-dialog.compone
|
|||||||
imports: [JslibModule, CommonModule],
|
imports: [JslibModule, CommonModule],
|
||||||
})
|
})
|
||||||
export class SendFilePopoutDialogContainerComponent implements OnInit {
|
export class SendFilePopoutDialogContainerComponent implements OnInit {
|
||||||
@Input() config: SendFormConfig;
|
config = input.required<SendFormConfig>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
@@ -27,8 +25,8 @@ export class SendFilePopoutDialogContainerComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (
|
if (
|
||||||
this.config?.sendType === SendType.File &&
|
this.config().sendType === SendType.File &&
|
||||||
this.config?.mode === "add" &&
|
this.config().mode === "add" &&
|
||||||
this.filePopoutUtilsService.showFilePopoutMessage(window)
|
this.filePopoutUtilsService.showFilePopoutMessage(window)
|
||||||
) {
|
) {
|
||||||
this.dialogService.open(SendFilePopoutDialogComponent);
|
this.dialogService.open(SendFilePopoutDialogComponent);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<bit-section [formGroup]="sendFileDetailsForm">
|
<bit-section [formGroup]="sendFileDetailsForm">
|
||||||
<div *ngIf="config.mode === 'edit'">
|
<div *ngIf="config().mode === 'edit'">
|
||||||
<div bitTypography="body2" class="tw-text-muted">{{ "file" | i18n }}</div>
|
<div bitTypography="body2" class="tw-text-muted">{{ "file" | i18n }}</div>
|
||||||
<div data-testid="file-name">{{ originalSendView.file.fileName }}</div>
|
<div data-testid="file-name">{{ originalSendView().file.fileName }}</div>
|
||||||
<div data-testid="file-size" class="tw-text-muted">{{ originalSendView.file.sizeName }}</div>
|
<div data-testid="file-size" class="tw-text-muted">{{ originalSendView().file.sizeName }}</div>
|
||||||
</div>
|
</div>
|
||||||
<bit-form-field *ngIf="config.mode !== 'edit'">
|
<bit-form-field *ngIf="config().mode !== 'edit'">
|
||||||
<bit-label for="file">{{ "fileToShare" | i18n }}</bit-label>
|
<bit-label for="file">{{ "fileToShare" | i18n }}</bit-label>
|
||||||
<div class="tw-flex tw-mt-2 tw-mb-1">
|
<div class="tw-flex tw-mt-2 tw-mb-1">
|
||||||
<button bitButton type="button" buttonType="secondary" (click)="fileSelector.click()">
|
<button bitButton type="button" buttonType="secondary" (click)="fileSelector.click()">
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, Input, OnInit } from "@angular/core";
|
import { Component, input, OnInit } from "@angular/core";
|
||||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||||
import { FormBuilder, Validators, ReactiveFormsModule, FormsModule } from "@angular/forms";
|
import { FormBuilder, Validators, ReactiveFormsModule, FormsModule } from "@angular/forms";
|
||||||
|
|
||||||
@@ -34,8 +32,8 @@ import { SendFormContainer } from "../../send-form-container";
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class SendFileDetailsComponent implements OnInit {
|
export class SendFileDetailsComponent implements OnInit {
|
||||||
@Input() config: SendFormConfig;
|
config = input.required<SendFormConfig>();
|
||||||
@Input() originalSendView?: SendView;
|
originalSendView = input<SendView>();
|
||||||
|
|
||||||
sendFileDetailsForm = this.formBuilder.group({
|
sendFileDetailsForm = this.formBuilder.group({
|
||||||
file: this.formBuilder.control<SendFileView | null>(null, Validators.required),
|
file: this.formBuilder.control<SendFileView | null>(null, Validators.required),
|
||||||
@@ -69,13 +67,13 @@ export class SendFileDetailsComponent implements OnInit {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.originalSendView) {
|
if (this.originalSendView()) {
|
||||||
this.sendFileDetailsForm.patchValue({
|
this.sendFileDetailsForm.patchValue({
|
||||||
file: this.originalSendView.file,
|
file: this.originalSendView()?.file,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.config.areSendsAllowed) {
|
if (!this.config().areSendsAllowed) {
|
||||||
this.sendFileDetailsForm.disable();
|
this.sendFileDetailsForm.disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
// FIXME: Update this file to be type safe and remove this and next line
|
|
||||||
// @ts-strict-ignore
|
|
||||||
import { CommonModule } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component, Input, OnInit } from "@angular/core";
|
import { Component, input, OnInit } from "@angular/core";
|
||||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||||
import { FormBuilder, FormControl, Validators, ReactiveFormsModule } from "@angular/forms";
|
import { FormBuilder, FormControl, Validators, ReactiveFormsModule } from "@angular/forms";
|
||||||
|
|
||||||
@@ -25,8 +23,8 @@ import { SendFormContainer } from "../../send-form-container";
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class SendTextDetailsComponent implements OnInit {
|
export class SendTextDetailsComponent implements OnInit {
|
||||||
@Input() config: SendFormConfig;
|
config = input.required<SendFormConfig>();
|
||||||
@Input() originalSendView?: SendView;
|
originalSendView = input<SendView>();
|
||||||
|
|
||||||
sendTextDetailsForm = this.formBuilder.group({
|
sendTextDetailsForm = this.formBuilder.group({
|
||||||
text: new FormControl("", Validators.required),
|
text: new FormControl("", Validators.required),
|
||||||
@@ -51,15 +49,13 @@ export class SendTextDetailsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
async ngOnInit(): Promise<void> {
|
||||||
if (this.originalSendView) {
|
this.sendTextDetailsForm.patchValue({
|
||||||
this.sendTextDetailsForm.patchValue({
|
text: this.originalSendView()?.text?.text || "",
|
||||||
text: this.originalSendView.text?.text || "",
|
hidden: this.originalSendView()?.text?.hidden || false,
|
||||||
hidden: this.originalSendView.text?.hidden || false,
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.config.areSendsAllowed) {
|
if (!this.config().areSendsAllowed) {
|
||||||
this.sendTextDetailsForm.disable();
|
this.sendTextDetailsForm.disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user