mirror of
https://github.com/bitwarden/browser
synced 2025-12-19 09:43:23 +00:00
[PM-24232] - [Defect][Web] Admin Console - SSH key and Folder should not show as options from New button (#15834)
* properly call input functions * don't enable sshkey form * fix logic for disabling cipher form * prefer use of observable * use destroyRef. change to enabled status only
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { Observable } from "rxjs";
|
||||
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { CipherFormConfig } from "@bitwarden/vault";
|
||||
|
||||
@@ -74,4 +76,10 @@ export abstract class CipherFormContainer {
|
||||
abstract disableFormFields(): void;
|
||||
|
||||
abstract enableFormFields(): void;
|
||||
|
||||
/**
|
||||
* An observable that emits when the form status changes to enabled.
|
||||
* This can be used to disable child forms when the parent form is enabled.
|
||||
*/
|
||||
formEnabled$: Observable<void>;
|
||||
}
|
||||
|
||||
@@ -112,6 +112,12 @@ export class CipherFormComponent implements AfterViewInit, OnInit, OnChanges, Ci
|
||||
|
||||
@Output() formReady = this.formReadySubject.asObservable();
|
||||
|
||||
/**
|
||||
* Emitted when the form is enabled
|
||||
*/
|
||||
private formEnabledSubject = new Subject<void>();
|
||||
formEnabled$ = this.formEnabledSubject.asObservable();
|
||||
|
||||
/**
|
||||
* The original cipher being edited or cloned. Null for add mode.
|
||||
*/
|
||||
@@ -156,6 +162,7 @@ export class CipherFormComponent implements AfterViewInit, OnInit, OnChanges, Ci
|
||||
|
||||
enableFormFields(): void {
|
||||
this.cipherForm.enable({ emitEvent: false });
|
||||
this.formEnabledSubject.next();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// FIXME: Update this file to be type safe and remove this and next line
|
||||
// @ts-strict-ignore
|
||||
import { CommonModule } from "@angular/common";
|
||||
import { Component, Input, OnInit } from "@angular/core";
|
||||
import { Component, DestroyRef, inject, Input, OnInit } from "@angular/core";
|
||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
||||
import { firstValueFrom } from "rxjs";
|
||||
@@ -60,6 +60,7 @@ export class SshKeySectionComponent implements OnInit {
|
||||
});
|
||||
|
||||
showImport = false;
|
||||
private destroyRef = inject(DestroyRef);
|
||||
|
||||
constructor(
|
||||
private cipherFormContainer: CipherFormContainer,
|
||||
@@ -94,6 +95,12 @@ export class SshKeySectionComponent implements OnInit {
|
||||
if (this.platformUtilsService.getClientType() !== ClientType.Web) {
|
||||
this.showImport = true;
|
||||
}
|
||||
|
||||
// Disable the form if the cipher form container is enabled
|
||||
// to prevent user interaction
|
||||
this.cipherFormContainer.formEnabled$
|
||||
.pipe(takeUntilDestroyed(this.destroyRef))
|
||||
.subscribe(() => this.sshKeyForm.disable());
|
||||
}
|
||||
|
||||
/** Set form initial form values from the current cipher */
|
||||
|
||||
Reference in New Issue
Block a user