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:
parent
60e52dd2f2
commit
694f2c7da2
@ -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">
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user