mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 13:53:34 +00:00
add policy component form validation to policy edit component (#12150)
This commit is contained in:
@@ -15,7 +15,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<ng-container bitDialogFooter>
|
<ng-container bitDialogFooter>
|
||||||
<button bitButton buttonType="primary" [disabled]="saveDisabled" bitFormButton type="submit">
|
<button
|
||||||
|
bitButton
|
||||||
|
buttonType="primary"
|
||||||
|
[disabled]="saveDisabled$ | async"
|
||||||
|
bitFormButton
|
||||||
|
type="submit"
|
||||||
|
>
|
||||||
{{ "save" | i18n }}
|
{{ "save" | i18n }}
|
||||||
</button>
|
</button>
|
||||||
<button bitButton buttonType="secondary" bitDialogClose type="button">
|
<button bitButton buttonType="secondary" bitDialogClose type="button">
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
ViewContainerRef,
|
ViewContainerRef,
|
||||||
} from "@angular/core";
|
} from "@angular/core";
|
||||||
import { FormBuilder } from "@angular/forms";
|
import { FormBuilder } from "@angular/forms";
|
||||||
|
import { Observable, map } from "rxjs";
|
||||||
|
|
||||||
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
|
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
|
||||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||||
@@ -42,7 +43,7 @@ export class PolicyEditComponent implements AfterViewInit {
|
|||||||
policyType = PolicyType;
|
policyType = PolicyType;
|
||||||
loading = true;
|
loading = true;
|
||||||
enabled = false;
|
enabled = false;
|
||||||
saveDisabled = false;
|
saveDisabled$: Observable<boolean>;
|
||||||
defaultTypes: any[];
|
defaultTypes: any[];
|
||||||
policyComponent: BasePolicyComponent;
|
policyComponent: BasePolicyComponent;
|
||||||
|
|
||||||
@@ -73,7 +74,9 @@ export class PolicyEditComponent implements AfterViewInit {
|
|||||||
this.policyComponent.policy = this.data.policy;
|
this.policyComponent.policy = this.data.policy;
|
||||||
this.policyComponent.policyResponse = this.policyResponse;
|
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();
|
this.cdr.detectChanges();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user