From ae81dbef3bc74519b01176f846b06d886f9be393 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Fri, 19 Jul 2024 18:16:15 -0400 Subject: [PATCH 01/21] Initial config page --- apps/web/src/locales/en/messages.json | 12 ++ .../overview/overview.component.html | 1 + .../overview/overview.component.ts | 5 + .../config/config.component.html | 50 ++++++ .../config/config.component.ts | 156 ++++++++++++++++++ .../service-account.component.html | 1 + .../service-accounts-routing.module.ts | 5 + .../service-accounts.module.ts | 2 + .../shared/projects-list.component.html | 27 ++- .../shared/projects-list.component.ts | 16 ++ .../shared/sm-shared.module.ts | 6 + 11 files changed, 277 insertions(+), 4 deletions(-) create mode 100644 bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html create mode 100644 bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 26a7426837ec..edc9a521ca3e 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -8594,5 +8594,17 @@ }, "purchasedSeatsRemoved": { "message": "purchased seats removed" + }, + "environmentVariables": { + "message": "Environment variables" + }, + "organizationId": { + "message": "Organization ID" + }, + "projectIds": { + "message": "Project IDs" + }, + "machineAccountProjects": { + "message": "The following projects can be accessed by this machine account." } } diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html index 29cbf78464ba..2af056ad5901 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html @@ -51,6 +51,7 @@

{{ "projects" | i (newProjectEvent)="openNewProjectDialog()" (editProjectEvent)="openEditProject($event)" (deleteProjectEvent)="openDeleteProjectDialog($event)" + (copiedProjectUUIdEvent)="copyProjectUuid($event)" [projects]="view.latestProjects" >
diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts index 4c057e56988b..e0aad6e43d6b 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts @@ -51,6 +51,7 @@ import { ServiceAccountOperation, } from "../service-accounts/dialog/service-account-dialog.component"; import { ServiceAccountService } from "../service-accounts/service-account.service"; +import { ProjectsListComponent } from "../shared/projects-list.component"; import { SecretsListComponent } from "../shared/secrets-list.component"; import { SMOnboardingTasks, SMOnboardingTasksService } from "./sm-onboarding-tasks.service"; @@ -258,6 +259,10 @@ export class OverviewComponent implements OnInit, OnDestroy { }); } + copyProjectUuid(id: string) { + ProjectsListComponent.copyProjectUuid(id, this.platformUtilsService, this.i18nService); + } + // Secrets --- openSecretDialog() { diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html new file mode 100644 index 000000000000..f7bb1a02d372 --- /dev/null +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html @@ -0,0 +1,50 @@ +
+
+

{{ "environmentVariables" | i18n }}

+
+ + {{ "identityUrl" | i18n }} + + + + + {{ "apiUrl" | i18n }} + + + +
+ + {{ "organizationId" | i18n }} + + + +
+
+

{{ "projects" | i18n }}

+

{{ "projectsNoItemsTitle" | i18n }}

+

{{ "machineAccountProjects" | i18n }}

+ +
+
+
+ +
diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts new file mode 100644 index 000000000000..9ac47a6441e0 --- /dev/null +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts @@ -0,0 +1,156 @@ +import { Component, OnDestroy, OnInit } from "@angular/core"; +import { ActivatedRoute } from "@angular/router"; +import { Subject, takeUntil } from "rxjs"; + +import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; +import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; +import { DialogService, ToastService } from "@bitwarden/components"; + +import { ProjectListView } from "../../models/view/project-list.view"; +import { + ProjectDeleteOperation, + ProjectDeleteDialogComponent, +} from "../../projects/dialog/project-delete-dialog.component"; +import { + ProjectOperation, + ProjectDialogComponent, +} from "../../projects/dialog/project-dialog.component"; +import { ProjectService } from "../../projects/project.service"; +import { AccessPolicyService } from "../../shared/access-policies/access-policy.service"; +import { ProjectsListComponent } from "../../shared/projects-list.component"; +import { + OperationType, + ServiceAccountOperation, + ServiceAccountDialogComponent, +} from "../dialog/service-account-dialog.component"; + +@Component({ + selector: "sm-config", + templateUrl: "./config.component.html", +}) +export class ServiceAccountConfigComponent implements OnInit, OnDestroy { + identityUrl: string; + apiUrl: string; + organizationId: string; + serviceAccountId: string; + projects: ProjectListView[]; + hasProjects = false; + + private destroy$ = new Subject(); + loading = true; + + constructor( + private environmentService: EnvironmentService, + private route: ActivatedRoute, + private platformUtilsService: PlatformUtilsService, + private toastService: ToastService, + private i18nService: I18nService, + private dialogService: DialogService, + private projectService: ProjectService, + private accessPolicyService: AccessPolicyService, + ) {} + + async ngOnInit() { + this.route.params.pipe(takeUntil(this.destroy$)).subscribe((params) => { + this.organizationId = params.organizationId; + this.serviceAccountId = params.serviceAccountId; + }); + + const environment = await this.environmentService.getEnvironment(); + this.identityUrl = environment.getIdentityUrl(); + this.apiUrl = environment.getApiUrl(); + + const allProjects = await this.projectService.getProjects(this.organizationId); + await this.accessPolicyService + .getServiceAccountGrantedPolicies(this.organizationId, this.serviceAccountId) + .then((policies) => { + const ids = policies.grantedProjectPolicies.map( + (policy) => policy.accessPolicy.grantedProjectId, + ); + this.projects = allProjects.filter((project) => + ids.some((projectId) => projectId === project.id), + ); + }); + + this.hasProjects = this.projects.length > 0; + this.loading = false; + } + + copyIdentityUrl = async () => { + this.platformUtilsService.copyToClipboard(this.identityUrl); + this.toastService.showToast({ + variant: "success", + title: null, + message: this.i18nService.t("valueCopied", this.i18nService.t("identityUrl")), + }); + }; + + copyApiUrl = async () => { + this.platformUtilsService.copyToClipboard(this.apiUrl); + this.toastService.showToast({ + variant: "success", + title: null, + message: this.i18nService.t("valueCopied", this.i18nService.t("apiUrl")), + }); + }; + + copyOrganizationId = async () => { + this.platformUtilsService.copyToClipboard(this.organizationId); + this.toastService.showToast({ + variant: "success", + title: null, + message: this.i18nService.t("valueCopied", this.i18nService.t("organizationId")), + }); + }; + + // Projects --- + + openEditProject(projectId: string) { + this.dialogService.open(ProjectDialogComponent, { + data: { + organizationId: this.organizationId, + operation: OperationType.Edit, + organizationEnabled: true, //this.organizationEnabled, + projectId: projectId, + }, + }); + } + + openNewProjectDialog() { + this.dialogService.open(ProjectDialogComponent, { + data: { + organizationId: this.organizationId, + operation: OperationType.Add, + organizationEnabled: true, //this.organizationEnabled, + }, + }); + } + + openServiceAccountDialog() { + this.dialogService.open(ServiceAccountDialogComponent, { + data: { + organizationId: this.organizationId, + operation: OperationType.Add, + organizationEnabled: true, //this.organizationEnabled, + }, + }); + } + + openDeleteProjectDialog(event: ProjectListView[]) { + this.dialogService.open(ProjectDeleteDialogComponent, { + data: { + projects: event, + }, + }); + } + + copyProjectUuid(id: string) { + ProjectsListComponent.copyProjectUuid(id, this.platformUtilsService, this.i18nService); + } + + ngOnDestroy(): void { + this.destroy$.next(); + this.destroy$.complete(); + } +} diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/service-account.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/service-account.component.html index 00b5201a657b..577ea8c01fe9 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/service-account.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/service-account.component.html @@ -14,6 +14,7 @@ {{ "people" | i18n }} {{ "accessTokens" | i18n }} {{ "eventLogs" | i18n }} + Config +
+ {{ project.revisionDate | date: "medium" }} @@ -91,7 +105,12 @@ {{ "editProject" | i18n }} - diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts index 7039b0a99202..e1d7b44a23d4 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts @@ -24,6 +24,8 @@ export class ProjectsListComponent { } private _projects: ProjectListView[]; + @Input() showDelete?: boolean = true; + @Input() set search(search: string) { this.selection.clear(); @@ -33,6 +35,7 @@ export class ProjectsListComponent { @Output() editProjectEvent = new EventEmitter(); @Output() deleteProjectEvent = new EventEmitter(); @Output() newProjectEvent = new EventEmitter(); + @Output() copiedProjectUUIdEvent = new EventEmitter(); selection = new SelectionModel(true, []); protected dataSource = new TableDataSource(); @@ -89,4 +92,17 @@ export class ProjectsListComponent { } return false; } + + static copyProjectUuid( + id: string, + platformUtilsService: PlatformUtilsService, + i18nService: I18nService, + ) { + platformUtilsService.copyToClipboard(id); + platformUtilsService.showToast( + "success", + null, + i18nService.t("valueCopied", i18nService.t("uuid")), + ); + } } diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/shared/sm-shared.module.ts b/bitwarden_license/bit-web/src/app/secrets-manager/shared/sm-shared.module.ts index cb723af6d7d3..d778db9814c8 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/shared/sm-shared.module.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/shared/sm-shared.module.ts @@ -1,10 +1,12 @@ import { NgModule } from "@angular/core"; import { + CardComponent, MultiSelectModule, SearchModule, SelectModule, NoItemsModule, + FormFieldModule, } from "@bitwarden/components"; import { CoreOrganizationModule } from "@bitwarden/web-vault/app/admin-console/organizations/core"; import { DynamicAvatarComponent } from "@bitwarden/web-vault/app/components/dynamic-avatar.component"; @@ -31,17 +33,21 @@ import { SecretsListComponent } from "./secrets-list.component"; DynamicAvatarComponent, SearchModule, HeaderModule, + CardComponent, + FormFieldModule, ], exports: [ AccessPolicySelectorComponent, BulkConfirmationDialogComponent, BulkStatusDialogComponent, + FormFieldModule, HeaderModule, NewMenuComponent, NoItemsModule, ProjectsListComponent, SearchModule, SecretsListComponent, + CardComponent, SelectModule, SharedModule, ], From 277a6c48daf72e677e26c7073e5e8e70c56bfaa7 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Mon, 22 Jul 2024 09:39:43 -0400 Subject: [PATCH 02/21] Remove project actions --- .../config/config.component.html | 13 ++--- .../config/config.component.ts | 54 ------------------- .../shared/projects-list.component.html | 13 ++--- .../shared/projects-list.component.ts | 2 +- 4 files changed, 11 insertions(+), 71 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html index f7bb1a02d372..c9a1d68742d6 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html @@ -31,16 +31,13 @@

{{ "environmentVariables" | i18n }}

-

{{ "projects" | i18n }}

-

{{ "projectsNoItemsTitle" | i18n }}

-

{{ "machineAccountProjects" | i18n }}

+

{{ "projectIds" | i18n }}

+

{{ "projectsNoItemsTitle" | i18n }}

+

{{ "machineAccountProjects" | i18n }}

diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts index 9ac47a6441e0..d4fc8851715d 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts @@ -8,22 +8,9 @@ import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/pl import { DialogService, ToastService } from "@bitwarden/components"; import { ProjectListView } from "../../models/view/project-list.view"; -import { - ProjectDeleteOperation, - ProjectDeleteDialogComponent, -} from "../../projects/dialog/project-delete-dialog.component"; -import { - ProjectOperation, - ProjectDialogComponent, -} from "../../projects/dialog/project-dialog.component"; import { ProjectService } from "../../projects/project.service"; import { AccessPolicyService } from "../../shared/access-policies/access-policy.service"; import { ProjectsListComponent } from "../../shared/projects-list.component"; -import { - OperationType, - ServiceAccountOperation, - ServiceAccountDialogComponent, -} from "../dialog/service-account-dialog.component"; @Component({ selector: "sm-config", @@ -104,47 +91,6 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy { }); }; - // Projects --- - - openEditProject(projectId: string) { - this.dialogService.open(ProjectDialogComponent, { - data: { - organizationId: this.organizationId, - operation: OperationType.Edit, - organizationEnabled: true, //this.organizationEnabled, - projectId: projectId, - }, - }); - } - - openNewProjectDialog() { - this.dialogService.open(ProjectDialogComponent, { - data: { - organizationId: this.organizationId, - operation: OperationType.Add, - organizationEnabled: true, //this.organizationEnabled, - }, - }); - } - - openServiceAccountDialog() { - this.dialogService.open(ServiceAccountDialogComponent, { - data: { - organizationId: this.organizationId, - operation: OperationType.Add, - organizationEnabled: true, //this.organizationEnabled, - }, - }); - } - - openDeleteProjectDialog(event: ProjectListView[]) { - this.dialogService.open(ProjectDeleteDialogComponent, { - data: { - projects: event, - }, - }); - } - copyProjectUuid(id: string) { ProjectsListComponent.copyProjectUuid(id, this.platformUtilsService, this.i18nService); } diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html index 3e98ae36dceb..9f434fea657b 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html @@ -20,7 +20,7 @@ - + - + @@ -105,12 +107,7 @@ {{ "editProject" | i18n }} - diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts index e1d7b44a23d4..377868e530b7 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts @@ -24,7 +24,7 @@ export class ProjectsListComponent { } private _projects: ProjectListView[]; - @Input() showDelete?: boolean = true; + @Input() showMenus?: boolean = true; @Input() set search(search: string) { From caa707f3d0695312d8eb1fe6f177f1fe2eb3cb48 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Mon, 22 Jul 2024 10:58:50 -0400 Subject: [PATCH 03/21] Add copy projectId method to the project page --- .../projects/projects/projects.component.html | 1 + .../projects/projects/projects.component.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.html index b3d4aea5ccc1..99dc18aa5fda 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.html @@ -10,6 +10,7 @@ (newProjectEvent)="openNewProjectDialog()" (editProjectEvent)="openEditProject($event)" (deleteProjectEvent)="openDeleteProjectDialog($event)" + (copiedProjectUUIdEvent)="copyProjectUuid($event)" [projects]="projects$ | async" [search]="search" > diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts index fd59014642a4..7b579a1077be 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts @@ -3,6 +3,8 @@ import { ActivatedRoute } from "@angular/router"; import { combineLatest, lastValueFrom, Observable, startWith, switchMap } from "rxjs"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; +import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; +import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { DialogService } from "@bitwarden/components"; import { ProjectListView } from "../../models/view/project-list.view"; @@ -12,6 +14,7 @@ import { BulkConfirmationResult, BulkConfirmationStatus, } from "../../shared/dialogs/bulk-confirmation-dialog.component"; +import { ProjectsListComponent } from "../../shared/projects-list.component"; import { ProjectDeleteDialogComponent, ProjectDeleteOperation, @@ -39,6 +42,8 @@ export class ProjectsComponent implements OnInit { private projectService: ProjectService, private dialogService: DialogService, private organizationService: OrganizationService, + private platformUtilsService: PlatformUtilsService, + private i18nService: I18nService, ) {} ngOnInit() { @@ -122,4 +127,8 @@ export class ProjectsComponent implements OnInit { }; }); } + + copyProjectUuid(id: string) { + ProjectsListComponent.copyProjectUuid(id, this.platformUtilsService, this.i18nService); + } } From b79e7c03134fb8b2870ab328ec707f37d43981a0 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Wed, 24 Jul 2024 11:43:31 -0400 Subject: [PATCH 04/21] Update bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com> --- .../secrets-manager/service-accounts/config/config.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts index d4fc8851715d..34470d99f2fa 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts @@ -13,7 +13,7 @@ import { AccessPolicyService } from "../../shared/access-policies/access-policy. import { ProjectsListComponent } from "../../shared/projects-list.component"; @Component({ - selector: "sm-config", + selector: "sm-service-account-config", templateUrl: "./config.component.html", }) export class ServiceAccountConfigComponent implements OnInit, OnDestroy { From 8c9aa9abdbdd92e86ca558fb2c3ad01bbeeb11f4 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Wed, 24 Jul 2024 11:44:18 -0400 Subject: [PATCH 05/21] Update bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com> --- .../src/app/secrets-manager/shared/projects-list.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts index 377868e530b7..123c44ed3974 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts @@ -93,7 +93,7 @@ export class ProjectsListComponent { return false; } - static copyProjectUuid( + static copyProjectUuidToClipboard( id: string, platformUtilsService: PlatformUtilsService, i18nService: I18nService, From 7c72446a64729011d82d1aa6ff8914c82089b48a Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Wed, 24 Jul 2024 11:44:31 -0400 Subject: [PATCH 06/21] Update apps/web/src/locales/en/messages.json Co-authored-by: Maciej Zieniuk <167752252+mzieniukbw@users.noreply.github.com> --- apps/web/src/locales/en/messages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index edc9a521ca3e..2c809a1482e3 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -8604,7 +8604,7 @@ "projectIds": { "message": "Project IDs" }, - "machineAccountProjects": { + "projectsAccessedByMachineAccount": { "message": "The following projects can be accessed by this machine account." } } From fc5cee651a8731fab075321b19431c3fba20a3b8 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Wed, 24 Jul 2024 11:48:22 -0400 Subject: [PATCH 07/21] Fix method and string naming --- .../src/app/secrets-manager/overview/overview.component.ts | 6 +++++- .../secrets-manager/projects/projects/projects.component.ts | 6 +++++- .../service-accounts/config/config.component.html | 2 +- .../service-accounts/config/config.component.ts | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts index e0aad6e43d6b..d3ae21e71c86 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts @@ -260,7 +260,11 @@ export class OverviewComponent implements OnInit, OnDestroy { } copyProjectUuid(id: string) { - ProjectsListComponent.copyProjectUuid(id, this.platformUtilsService, this.i18nService); + ProjectsListComponent.copyProjectUuidToClipboard( + id, + this.platformUtilsService, + this.i18nService, + ); } // Secrets --- diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts index 7b579a1077be..185cbc530e56 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts @@ -129,6 +129,10 @@ export class ProjectsComponent implements OnInit { } copyProjectUuid(id: string) { - ProjectsListComponent.copyProjectUuid(id, this.platformUtilsService, this.i18nService); + ProjectsListComponent.copyProjectUuidToClipboard( + id, + this.platformUtilsService, + this.i18nService, + ); } } diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html index c9a1d68742d6..b17e47a39ec8 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.html @@ -33,7 +33,7 @@

{{ "environmentVariables" | i18n }}

{{ "projectIds" | i18n }}

{{ "projectsNoItemsTitle" | i18n }}

-

{{ "machineAccountProjects" | i18n }}

+

{{ "projectsAccessedByMachineAccount" | i18n }}

Date: Wed, 24 Jul 2024 13:45:33 -0400 Subject: [PATCH 08/21] Ensure config component load logic happens after params observed --- .../config/config.component.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts index 7e1123c904ce..ee3aa1230d9d 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts @@ -1,11 +1,11 @@ import { Component, OnDestroy, OnInit } from "@angular/core"; -import { ActivatedRoute } from "@angular/router"; -import { Subject, takeUntil } from "rxjs"; +import { ActivatedRoute, Params } from "@angular/router"; +import { Subject, concatMap, takeUntil } from "rxjs"; import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; -import { DialogService, ToastService } from "@bitwarden/components"; +import { ToastService } from "@bitwarden/components"; import { ProjectListView } from "../../models/view/project-list.view"; import { ProjectService } from "../../projects/project.service"; @@ -33,17 +33,24 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy { private platformUtilsService: PlatformUtilsService, private toastService: ToastService, private i18nService: I18nService, - private dialogService: DialogService, private projectService: ProjectService, private accessPolicyService: AccessPolicyService, ) {} async ngOnInit() { - this.route.params.pipe(takeUntil(this.destroy$)).subscribe((params) => { - this.organizationId = params.organizationId; - this.serviceAccountId = params.serviceAccountId; - }); + this.route.params + .pipe( + concatMap(async (params: Params) => { + this.organizationId = params.organizationId; + this.serviceAccountId = params.serviceAccountId; + await this.load(); + }), + takeUntil(this.destroy$), + ) + .subscribe(); + } + async load() { const environment = await this.environmentService.getEnvironment(); this.identityUrl = environment.getIdentityUrl(); this.apiUrl = environment.getApiUrl(); From 044e4c6621291dab1aa88b16514eb842427c0f96 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Wed, 24 Jul 2024 13:56:56 -0400 Subject: [PATCH 09/21] Remove projectId emitted event --- .../overview/overview.component.html | 1 - .../secrets-manager/overview/overview.component.ts | 9 --------- .../projects/projects/projects.component.html | 1 - .../projects/projects/projects.component.ts | 13 ------------- .../service-accounts/config/config.component.ts | 9 --------- .../shared/projects-list.component.html | 2 +- .../shared/projects-list.component.ts | 12 ++++-------- 7 files changed, 5 insertions(+), 42 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html index 2af056ad5901..29cbf78464ba 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.html @@ -51,7 +51,6 @@

{{ "projects" | i (newProjectEvent)="openNewProjectDialog()" (editProjectEvent)="openEditProject($event)" (deleteProjectEvent)="openDeleteProjectDialog($event)" - (copiedProjectUUIdEvent)="copyProjectUuid($event)" [projects]="view.latestProjects" >
diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts index d3ae21e71c86..4c057e56988b 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/overview/overview.component.ts @@ -51,7 +51,6 @@ import { ServiceAccountOperation, } from "../service-accounts/dialog/service-account-dialog.component"; import { ServiceAccountService } from "../service-accounts/service-account.service"; -import { ProjectsListComponent } from "../shared/projects-list.component"; import { SecretsListComponent } from "../shared/secrets-list.component"; import { SMOnboardingTasks, SMOnboardingTasksService } from "./sm-onboarding-tasks.service"; @@ -259,14 +258,6 @@ export class OverviewComponent implements OnInit, OnDestroy { }); } - copyProjectUuid(id: string) { - ProjectsListComponent.copyProjectUuidToClipboard( - id, - this.platformUtilsService, - this.i18nService, - ); - } - // Secrets --- openSecretDialog() { diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.html index 99dc18aa5fda..b3d4aea5ccc1 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.html @@ -10,7 +10,6 @@ (newProjectEvent)="openNewProjectDialog()" (editProjectEvent)="openEditProject($event)" (deleteProjectEvent)="openDeleteProjectDialog($event)" - (copiedProjectUUIdEvent)="copyProjectUuid($event)" [projects]="projects$ | async" [search]="search" > diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts index 185cbc530e56..fd59014642a4 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/projects/projects/projects.component.ts @@ -3,8 +3,6 @@ import { ActivatedRoute } from "@angular/router"; import { combineLatest, lastValueFrom, Observable, startWith, switchMap } from "rxjs"; import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction"; -import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; -import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { DialogService } from "@bitwarden/components"; import { ProjectListView } from "../../models/view/project-list.view"; @@ -14,7 +12,6 @@ import { BulkConfirmationResult, BulkConfirmationStatus, } from "../../shared/dialogs/bulk-confirmation-dialog.component"; -import { ProjectsListComponent } from "../../shared/projects-list.component"; import { ProjectDeleteDialogComponent, ProjectDeleteOperation, @@ -42,8 +39,6 @@ export class ProjectsComponent implements OnInit { private projectService: ProjectService, private dialogService: DialogService, private organizationService: OrganizationService, - private platformUtilsService: PlatformUtilsService, - private i18nService: I18nService, ) {} ngOnInit() { @@ -127,12 +122,4 @@ export class ProjectsComponent implements OnInit { }; }); } - - copyProjectUuid(id: string) { - ProjectsListComponent.copyProjectUuidToClipboard( - id, - this.platformUtilsService, - this.i18nService, - ); - } } diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts index ee3aa1230d9d..74d598f92092 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts @@ -10,7 +10,6 @@ import { ToastService } from "@bitwarden/components"; import { ProjectListView } from "../../models/view/project-list.view"; import { ProjectService } from "../../projects/project.service"; import { AccessPolicyService } from "../../shared/access-policies/access-policy.service"; -import { ProjectsListComponent } from "../../shared/projects-list.component"; @Component({ selector: "sm-service-account-config", @@ -98,14 +97,6 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy { }); }; - copyProjectUuid(id: string) { - ProjectsListComponent.copyProjectUuidToClipboard( - id, - this.platformUtilsService, - this.i18nService, - ); - } - ngOnDestroy(): void { this.destroy$.next(); this.destroy$.complete(); diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html index 9f434fea657b..846bb62bc527 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.html @@ -75,7 +75,7 @@ size="small" [title]="'copyUuid' | i18n" [attr.aria-label]="'copyUuid' | i18n" - (click)="copiedProjectUUIdEvent.emit(project.id)" + (click)="copyProjectUuidToClipboard(project.id)" >

diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts index 123c44ed3974..3468fceed63f 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/shared/projects-list.component.ts @@ -93,16 +93,12 @@ export class ProjectsListComponent { return false; } - static copyProjectUuidToClipboard( - id: string, - platformUtilsService: PlatformUtilsService, - i18nService: I18nService, - ) { - platformUtilsService.copyToClipboard(id); - platformUtilsService.showToast( + copyProjectUuidToClipboard(id: string) { + this.platformUtilsService.copyToClipboard(id); + this.platformUtilsService.showToast( "success", null, - i18nService.t("valueCopied", i18nService.t("uuid")), + this.i18nService.t("valueCopied", this.i18nService.t("uuid")), ); } } From ffd9894561bc47970296d7d4aa82043f620ead04 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Mon, 29 Jul 2024 14:11:20 -0400 Subject: [PATCH 10/21] Update bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com> --- .../service-accounts/config/config.component.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts index 74d598f92092..d45be08faa41 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts @@ -40,13 +40,18 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy { this.route.params .pipe( concatMap(async (params: Params) => { - this.organizationId = params.organizationId; - this.serviceAccountId = params.serviceAccountId; - await this.load(); + return await this.load(params.organizationId, params.serviceAccountId); }), takeUntil(this.destroy$), ) - .subscribe(); + .subscribe((smConfig) => { + this.identityUrl = smConfig.identityUrl; + this.apiUrl = smConfig.apiUrl; + this.organizationId = smConfig.organizationId; + this.serviceAccountId = smConfig.serviceAccountId; + this.projects = smConfig.projects; + this.hasProjects = smConfig.hasProjects; + }); } async load() { From 4ed319e986c33a9c1d660310dcd9602f99df2a03 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Mon, 29 Jul 2024 14:30:44 -0400 Subject: [PATCH 11/21] Adjust load function --- .../config/config.component.ts | 37 ++++++++++++++----- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts index d45be08faa41..0c4ff53be39e 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts @@ -11,6 +11,14 @@ import { ProjectListView } from "../../models/view/project-list.view"; import { ProjectService } from "../../projects/project.service"; import { AccessPolicyService } from "../../shared/access-policies/access-policy.service"; +class serviceAccountConfig { + organizationId: string; + serviceAccountId: string; + identityUrl: string; + apiUrl: string; + projects: ProjectListView[]; +} + @Component({ selector: "sm-service-account-config", templateUrl: "./config.component.html", @@ -50,29 +58,38 @@ export class ServiceAccountConfigComponent implements OnInit, OnDestroy { this.organizationId = smConfig.organizationId; this.serviceAccountId = smConfig.serviceAccountId; this.projects = smConfig.projects; - this.hasProjects = smConfig.hasProjects; + + this.hasProjects = smConfig.projects.length > 0; + this.loading = false; }); } - async load() { + async load(organizationId: string, serviceAccountId: string): Promise { + const smConfig: serviceAccountConfig = { + organizationId: organizationId, + serviceAccountId: serviceAccountId, + identityUrl: "", + apiUrl: "", + projects: [], + }; + const environment = await this.environmentService.getEnvironment(); - this.identityUrl = environment.getIdentityUrl(); - this.apiUrl = environment.getApiUrl(); - const allProjects = await this.projectService.getProjects(this.organizationId); + smConfig.identityUrl = environment.getIdentityUrl(); + smConfig.apiUrl = environment.getApiUrl(); + + const allProjects = await this.projectService.getProjects(organizationId); await this.accessPolicyService - .getServiceAccountGrantedPolicies(this.organizationId, this.serviceAccountId) + .getServiceAccountGrantedPolicies(organizationId, serviceAccountId) .then((policies) => { const ids = policies.grantedProjectPolicies.map( (policy) => policy.accessPolicy.grantedProjectId, ); - this.projects = allProjects.filter((project) => + smConfig.projects = allProjects.filter((project) => ids.some((projectId) => projectId === project.id), ); }); - - this.hasProjects = this.projects.length > 0; - this.loading = false; + return smConfig; } copyIdentityUrl = async () => { From c5500f04c478cc3ba42b4686bc5635309777d2d0 Mon Sep 17 00:00:00 2001 From: Robyn MacCallum Date: Mon, 29 Jul 2024 14:36:54 -0400 Subject: [PATCH 12/21] Fix config translation --- apps/web/src/locales/en/messages.json | 3 +++ .../service-accounts/service-account.component.html | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/web/src/locales/en/messages.json b/apps/web/src/locales/en/messages.json index 1ae15f20e250..c4a670c27123 100644 --- a/apps/web/src/locales/en/messages.json +++ b/apps/web/src/locales/en/messages.json @@ -8639,5 +8639,8 @@ }, "projectsAccessedByMachineAccount": { "message": "The following projects can be accessed by this machine account." + }, + "config": { + "message": "Config" } } diff --git a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/service-account.component.html b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/service-account.component.html index 577ea8c01fe9..23a8ab133d3e 100644 --- a/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/service-account.component.html +++ b/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/service-account.component.html @@ -14,7 +14,7 @@ {{ "people" | i18n }} {{ "accessTokens" | i18n }} {{ "eventLogs" | i18n }} - Config + {{ "config" | i18n }}