From 3b1860b9eeff811a1c417f134dbd3ea64aa75d40 Mon Sep 17 00:00:00 2001 From: Will Martin Date: Thu, 29 Jun 2023 12:42:27 -0400 Subject: [PATCH] [SM-771] bulk add SM dialog (#5669) * add dialog; add service method; add menu button * update service layer * update service method; add i18n; add success and error logic * remove comment * remove SM Beta copy in member dialog * refactor error logic to utilize bitAction * update i18n key * use i18n in menu option * use i18n in footer * rename component file * rename enableAccess method; remove button; use userName pipe * only show if SM flag is enabled * [SM-830] fix: close checkboxes on dialog close --- .../bulk/bulk-enable-sm-dialog.component.html | 46 ++++++++++++++++ .../bulk/bulk-enable-sm-dialog.component.ts | 53 +++++++++++++++++++ .../member-dialog.component.html | 6 +-- .../organizations/members/members.module.ts | 2 + .../members/people.component.html | 6 +++ .../organizations/members/people.component.ts | 28 ++++++++++ apps/web/src/locales/en/messages.json | 25 +++++++-- .../organization-user.service.ts | 11 ++++ ...rganization-user.service.implementation.ts | 14 +++++ 9 files changed, 184 insertions(+), 7 deletions(-) create mode 100644 apps/web/src/app/admin-console/organizations/members/components/bulk/bulk-enable-sm-dialog.component.html create mode 100644 apps/web/src/app/admin-console/organizations/members/components/bulk/bulk-enable-sm-dialog.component.ts diff --git a/apps/web/src/app/admin-console/organizations/members/components/bulk/bulk-enable-sm-dialog.component.html b/apps/web/src/app/admin-console/organizations/members/components/bulk/bulk-enable-sm-dialog.component.html new file mode 100644 index 0000000000..ea76b5e0a8 --- /dev/null +++ b/apps/web/src/app/admin-console/organizations/members/components/bulk/bulk-enable-sm-dialog.component.html @@ -0,0 +1,46 @@ + + {{ "enableSecretsManager" | i18n }} + +

{{ "bulkEnableSecretsManagerDescription" | i18n }}

+ + + + {{ "member" | i18n }} + {{ "role" | i18n }} + + + + + +
+ +
+
+ {{ u | userName }} +
+
+ {{ u.email }} +
+
+
+ + {{ u.type | userType }} + +
+
+
+ + + + +
diff --git a/apps/web/src/app/admin-console/organizations/members/components/bulk/bulk-enable-sm-dialog.component.ts b/apps/web/src/app/admin-console/organizations/members/components/bulk/bulk-enable-sm-dialog.component.ts new file mode 100644 index 0000000000..3a0caec17c --- /dev/null +++ b/apps/web/src/app/admin-console/organizations/members/components/bulk/bulk-enable-sm-dialog.component.ts @@ -0,0 +1,53 @@ +import { DialogRef, DIALOG_DATA } from "@angular/cdk/dialog"; +import { Component, Inject, OnInit } from "@angular/core"; + +import { DialogServiceAbstraction } from "@bitwarden/angular/services/dialog"; +import { OrganizationUserService } from "@bitwarden/common/abstractions/organization-user/organization-user.service"; +import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; +import { TableDataSource } from "@bitwarden/components"; + +import { OrganizationUserView } from "../../../core"; + +export type BulkEnableSecretsManagerDialogData = { + orgId: string; + users: OrganizationUserView[]; +}; + +@Component({ + templateUrl: `bulk-enable-sm-dialog.component.html`, +}) +export class BulkEnableSecretsManagerDialogComponent implements OnInit { + protected dataSource = new TableDataSource(); + constructor( + public dialogRef: DialogRef, + @Inject(DIALOG_DATA) private data: BulkEnableSecretsManagerDialogData, + private organizationUserService: OrganizationUserService, + private platformUtilsService: PlatformUtilsService, + private i18nService: I18nService + ) {} + + ngOnInit(): void { + this.dataSource.data = this.data.users; + } + + submit = async () => { + await this.organizationUserService.putOrganizationUserBulkEnableSecretsManager( + this.data.orgId, + this.dataSource.data.map((u) => u.id) + ); + this.platformUtilsService.showToast( + "success", + null, + this.i18nService.t("enabledAccessToSecretsManager") + ); + this.dialogRef.close(); + }; + + static open(dialogService: DialogServiceAbstraction, data: BulkEnableSecretsManagerDialogData) { + return dialogService.open( + BulkEnableSecretsManagerDialogComponent, + { data } + ); + } +} diff --git a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html index 62bcb04bb7..633bf30259 100644 --- a/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html +++ b/apps/web/src/app/admin-console/organizations/members/components/member-dialog/member-dialog.component.html @@ -255,7 +255,7 @@

- {{ "secretsManagerBeta" | i18n }} + {{ "secretsManager" | i18n }}

-

{{ "secretsManagerBetaDesc" | i18n }}

+

{{ "secretsManagerAccessDesc" | i18n }}

- {{ "userAccessSecretsManager" | i18n }} + {{ "userAccessSecretsManagerGA" | i18n }}
diff --git a/apps/web/src/app/admin-console/organizations/members/members.module.ts b/apps/web/src/app/admin-console/organizations/members/members.module.ts index 1efb10aace..71f5692a11 100644 --- a/apps/web/src/app/admin-console/organizations/members/members.module.ts +++ b/apps/web/src/app/admin-console/organizations/members/members.module.ts @@ -4,6 +4,7 @@ import { LooseComponentsModule } from "../../../shared"; import { SharedOrganizationModule } from "../shared"; import { BulkConfirmComponent } from "./components/bulk/bulk-confirm.component"; +import { BulkEnableSecretsManagerDialogComponent } from "./components/bulk/bulk-enable-sm-dialog.component"; import { BulkRemoveComponent } from "./components/bulk/bulk-remove.component"; import { BulkRestoreRevokeComponent } from "./components/bulk/bulk-restore-revoke.component"; import { BulkStatusComponent } from "./components/bulk/bulk-status.component"; @@ -21,6 +22,7 @@ import { PeopleComponent } from "./people.component"; ], declarations: [ BulkConfirmComponent, + BulkEnableSecretsManagerDialogComponent, BulkRemoveComponent, BulkRestoreRevokeComponent, BulkStatusComponent, diff --git a/apps/web/src/app/admin-console/organizations/members/people.component.html b/apps/web/src/app/admin-console/organizations/members/people.component.html index c93380b466..52ae5e96c5 100644 --- a/apps/web/src/app/admin-console/organizations/members/people.component.html +++ b/apps/web/src/app/admin-console/organizations/members/people.component.html @@ -99,6 +99,12 @@ > + + + +