mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 10:13:31 +00:00
[SM-1168] Update access policy selector to disable on submit (#8519)
* Add loading and disabled on all inputs * Add proper spinner and form disable on submit
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { ChangeDetectorRef, Component, OnDestroy, OnInit } from "@angular/core";
|
||||
import { FormControl, FormGroup } from "@angular/forms";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { combineLatest, Subject, switchMap, takeUntil, catchError, EMPTY } from "rxjs";
|
||||
import { combineLatest, Subject, switchMap, takeUntil, catchError } from "rxjs";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||
@@ -37,11 +37,9 @@ export class ProjectPeopleComponent implements OnInit, OnDestroy {
|
||||
return convertToAccessPolicyItemViews(policies);
|
||||
}),
|
||||
),
|
||||
catchError(() => {
|
||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.router.navigate(["/sm", this.organizationId, "projects"]);
|
||||
return EMPTY;
|
||||
catchError(async () => {
|
||||
await this.router.navigate(["/sm", this.organizationId, "projects"]);
|
||||
return [];
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -99,17 +97,20 @@ export class ProjectPeopleComponent implements OnInit, OnDestroy {
|
||||
if (this.formGroup.invalid) {
|
||||
return;
|
||||
}
|
||||
const formValues = this.formGroup.value.accessPolicies;
|
||||
this.formGroup.disable();
|
||||
|
||||
const showAccessRemovalWarning =
|
||||
await this.accessPolicySelectorService.showAccessRemovalWarning(
|
||||
this.organizationId,
|
||||
this.formGroup.value.accessPolicies,
|
||||
formValues,
|
||||
);
|
||||
|
||||
if (showAccessRemovalWarning) {
|
||||
const confirmed = await this.showWarning();
|
||||
if (!confirmed) {
|
||||
this.setSelected(this.currentAccessPolicies);
|
||||
this.formGroup.enable();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -117,7 +118,7 @@ export class ProjectPeopleComponent implements OnInit, OnDestroy {
|
||||
try {
|
||||
const projectPeopleView = convertToProjectPeopleAccessPoliciesView(
|
||||
this.projectId,
|
||||
this.formGroup.value.accessPolicies,
|
||||
formValues,
|
||||
);
|
||||
const peoplePoliciesViews = await this.accessPolicyService.putProjectPeopleAccessPolicies(
|
||||
this.projectId,
|
||||
@@ -126,9 +127,7 @@ export class ProjectPeopleComponent implements OnInit, OnDestroy {
|
||||
this.currentAccessPolicies = convertToAccessPolicyItemViews(peoplePoliciesViews);
|
||||
|
||||
if (showAccessRemovalWarning) {
|
||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||
this.router.navigate(["sm", this.organizationId, "projects"]);
|
||||
await this.router.navigate(["sm", this.organizationId, "projects"]);
|
||||
}
|
||||
this.platformUtilsService.showToast(
|
||||
"success",
|
||||
@@ -139,6 +138,7 @@ export class ProjectPeopleComponent implements OnInit, OnDestroy {
|
||||
this.validationService.showError(e);
|
||||
this.setSelected(this.currentAccessPolicies);
|
||||
}
|
||||
this.formGroup.enable();
|
||||
};
|
||||
|
||||
private setSelected(policiesToSelect: ApItemViewType[]) {
|
||||
|
||||
Reference in New Issue
Block a user