Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-13757] Add policy component form validation to policy edit component #12150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ViewContainerRef,
} from "@angular/core";
import { FormBuilder } from "@angular/forms";
import { Observable, map } from "rxjs";

Check warning on line 11 in apps/web/src/app/admin-console/organizations/policies/policy-edit.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/admin-console/organizations/policies/policy-edit.component.ts#L11

Added line #L11 was not covered by tests

import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
import { PolicyType } from "@bitwarden/common/admin-console/enums";
Expand Down Expand Up @@ -42,7 +43,7 @@
policyType = PolicyType;
loading = true;
enabled = false;
saveDisabled = false;
saveDisabled$: Observable<boolean>;
defaultTypes: any[];
policyComponent: BasePolicyComponent;

Expand Down Expand Up @@ -73,7 +74,9 @@
this.policyComponent.policy = this.data.policy;
this.policyComponent.policyResponse = this.policyResponse;

this.saveDisabled = !this.policyResponse.canToggleState;
this.saveDisabled$ = this.policyComponent.data.statusChanges.pipe(

Check warning on line 77 in apps/web/src/app/admin-console/organizations/policies/policy-edit.component.ts

View check run for this annotation

Codecov / codecov/patch

apps/web/src/app/admin-console/organizations/policies/policy-edit.component.ts#L77

Added line #L77 was not covered by tests
map((status) => status !== "VALID" || !this.policyResponse.canToggleState),
);

this.cdr.detectChanges();
}
Expand Down
Loading