1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-01-12 19:50:46 +01:00

add policy component form validation to policy edit component (#12150)

This commit is contained in:
Brandon Treston 2024-12-03 12:55:42 -05:00 committed by GitHub
parent 60e52dd2f2
commit 694f2c7da2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 3 deletions

View File

@ -15,7 +15,13 @@
</div>
</ng-container>
<ng-container bitDialogFooter>
<button bitButton buttonType="primary" [disabled]="saveDisabled" bitFormButton type="submit">
<button
bitButton
buttonType="primary"
[disabled]="saveDisabled$ | async"
bitFormButton
type="submit"
>
{{ "save" | i18n }}
</button>
<button bitButton buttonType="secondary" bitDialogClose type="button">

View File

@ -8,6 +8,7 @@ import {
ViewContainerRef,
} from "@angular/core";
import { FormBuilder } from "@angular/forms";
import { Observable, map } from "rxjs";
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
import { PolicyType } from "@bitwarden/common/admin-console/enums";
@ -42,7 +43,7 @@ export class PolicyEditComponent implements AfterViewInit {
policyType = PolicyType;
loading = true;
enabled = false;
saveDisabled = false;
saveDisabled$: Observable<boolean>;
defaultTypes: any[];
policyComponent: BasePolicyComponent;
@ -73,7 +74,9 @@ export class PolicyEditComponent implements AfterViewInit {
this.policyComponent.policy = this.data.policy;
this.policyComponent.policyResponse = this.policyResponse;
this.saveDisabled = !this.policyResponse.canToggleState;
this.saveDisabled$ = this.policyComponent.data.statusChanges.pipe(
map((status) => status !== "VALID" || !this.policyResponse.canToggleState),
);
this.cdr.detectChanges();
}