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

[SM-1302] Initial config page #10196

Merged
merged 26 commits into from
Sep 20, 2024
Merged
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
ae81dbe
Initial config page
differsthecat Jul 19, 2024
277a6c4
Remove project actions
differsthecat Jul 22, 2024
0a1d218
Merge branch 'main' into sm-1302-config-page
differsthecat Jul 22, 2024
caa707f
Add copy projectId method to the project page
differsthecat Jul 22, 2024
b79e7c0
Update bitwarden_license/bit-web/src/app/secrets-manager/service-accoโ€ฆ
differsthecat Jul 24, 2024
8c9aa9a
Update bitwarden_license/bit-web/src/app/secrets-manager/shared/projeโ€ฆ
differsthecat Jul 24, 2024
7c72446
Update apps/web/src/locales/en/messages.json
differsthecat Jul 24, 2024
fc5cee6
Fix method and string naming
differsthecat Jul 24, 2024
a05dd4c
Ensure config component load logic happens after params observed
differsthecat Jul 24, 2024
044e4c6
Remove projectId emitted event
differsthecat Jul 24, 2024
2fe1820
Merge branch 'main' into sm-1302-config-page
differsthecat Jul 24, 2024
ffd9894
Update bitwarden_license/bit-web/src/app/secrets-manager/service-accoโ€ฆ
differsthecat Jul 29, 2024
4ed319e
Adjust load function
differsthecat Jul 29, 2024
c5500f0
Fix config translation
differsthecat Jul 29, 2024
b952c92
Remove unnecceary async from copy functions
differsthecat Jul 29, 2024
c144d80
Add project ID translation key
differsthecat Jul 29, 2024
2d24f16
Update bitwarden_license/bit-web/src/app/secrets-manager/service-accoโ€ฆ
differsthecat Jul 30, 2024
21e333c
Simplify load function
differsthecat Jul 30, 2024
5250093
Simplify variable definition
differsthecat Jul 30, 2024
18445fa
Merge branch 'main' into sm-1302-config-page
differsthecat Jul 30, 2024
c2c0317
Merge branch 'main' into sm-1302-config-page
differsthecat Sep 16, 2024
2ddba08
Add all machine account projects to the config page
differsthecat Sep 16, 2024
655f77d
Update bitwarden_license/bit-web/src/app/secrets-manager/service-accoโ€ฆ
differsthecat Sep 17, 2024
63a024b
Remove unused variable
differsthecat Sep 19, 2024
8f24b8c
Remove revision date in config project list
differsthecat Sep 19, 2024
f05e632
Merge branch 'main' into sm-1302-config-page
differsthecat Sep 20, 2024
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
@@ -1,17 +1,17 @@
import { Component, OnDestroy, OnInit } from "@angular/core";
import { ActivatedRoute, Params } from "@angular/router";
import { Subject, concatMap, takeUntil } from "rxjs";

Check warning on line 3 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L1-L3

Added lines #L1 - L3 were not covered by tests

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 { ToastService } from "@bitwarden/components";

Check warning on line 8 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L5-L8

Added lines #L5 - L8 were not covered by tests

import { ProjectListView } from "../../models/view/project-list.view";
import { ProjectService } from "../../projects/project.service";
import { AccessPolicyService } from "../../shared/access-policies/access-policy.service";

Check warning on line 12 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L11-L12

Added lines #L11 - L12 were not covered by tests

class serviceAccountConfig {
class ServiceAccountConfig {
organizationId: string;
serviceAccountId: string;
identityUrl: string;
Expand All @@ -23,16 +23,16 @@
selector: "sm-service-account-config",
templateUrl: "./config.component.html",
})
export class ServiceAccountConfigComponent implements OnInit, OnDestroy {

Check warning on line 26 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L26

Added line #L26 was not covered by tests
identityUrl: string;
apiUrl: string;
organizationId: string;
serviceAccountId: string;
projects: ProjectListView[];
hasProjects = false;

Check warning on line 32 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L32

Added line #L32 was not covered by tests

private destroy$ = new Subject<void>();
loading = true;

Check warning on line 35 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L34-L35

Added lines #L34 - L35 were not covered by tests

constructor(
private environmentService: EnvironmentService,
Expand All @@ -41,78 +41,76 @@
private toastService: ToastService,
private i18nService: I18nService,
private projectService: ProjectService,
private accessPolicyService: AccessPolicyService,

Check warning on line 44 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L44

Added line #L44 was not covered by tests
) {}

async ngOnInit() {
this.route.params

Check warning on line 48 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L48

Added line #L48 was not covered by tests
.pipe(
concatMap(async (params: Params) => {
return await this.load(params.organizationId, params.serviceAccountId);

Check warning on line 51 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L50-L51

Added lines #L50 - L51 were not covered by tests
}),
takeUntil(this.destroy$),
)
.subscribe((smConfig) => {
this.identityUrl = smConfig.identityUrl;
this.apiUrl = smConfig.apiUrl;
this.organizationId = smConfig.organizationId;
this.serviceAccountId = smConfig.serviceAccountId;
this.projects = smConfig.projects;

Check warning on line 60 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L56-L60

Added lines #L56 - L60 were not covered by tests

this.hasProjects = smConfig.projects.length > 0;
this.loading = false;

Check warning on line 63 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L62-L63

Added lines #L62 - L63 were not covered by tests
});
}

async load(organizationId: string, serviceAccountId: string): Promise<serviceAccountConfig> {
const smConfig: serviceAccountConfig = {
organizationId: organizationId,
serviceAccountId: serviceAccountId,
identityUrl: "",
apiUrl: "",
projects: [],
};

async load(organizationId: string, serviceAccountId: string): Promise<ServiceAccountConfig> {
const environment = await this.environmentService.getEnvironment();

Check warning on line 68 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L68

Added line #L68 was not covered by tests

smConfig.identityUrl = environment.getIdentityUrl();
smConfig.apiUrl = environment.getApiUrl();
let projects: ProjectListView[] = [];

Check warning on line 70 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L70

Added line #L70 was not covered by tests

const allProjects = await this.projectService.getProjects(organizationId);
await this.accessPolicyService
.getServiceAccountGrantedPolicies(organizationId, serviceAccountId)
.then((policies) => {
const ids = policies.grantedProjectPolicies.map(
(policy) => policy.accessPolicy.grantedProjectId,
);
smConfig.projects = allProjects.filter((project) =>
ids.some((projectId) => projectId === project.id),
);
});
return smConfig;
const policies = await this.accessPolicyService.getServiceAccountGrantedPolicies(

Check warning on line 73 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L72-L73

Added lines #L72 - L73 were not covered by tests
organizationId,
serviceAccountId,
);

const ids = policies.grantedProjectPolicies.map(
(policy) => policy.accessPolicy.grantedProjectId,

Check warning on line 79 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L78-L79

Added lines #L78 - L79 were not covered by tests
);

projects = allProjects.filter((project) => ids.some((projectId) => projectId === project.id));

Check warning on line 82 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L82

Added line #L82 was not covered by tests
differsthecat marked this conversation as resolved.
Show resolved Hide resolved

return {

Check warning on line 84 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L84

Added line #L84 was not covered by tests
organizationId: organizationId,
serviceAccountId: serviceAccountId,
identityUrl: environment.getIdentityUrl(),
apiUrl: environment.getApiUrl(),
projects: projects,
} as ServiceAccountConfig;
}

copyIdentityUrl = () => {
this.platformUtilsService.copyToClipboard(this.identityUrl);
this.toastService.showToast({

Check warning on line 95 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L93-L95

Added lines #L93 - L95 were not covered by tests
variant: "success",
title: null,
message: this.i18nService.t("valueCopied", this.i18nService.t("identityUrl")),
});
};

copyApiUrl = () => {
this.platformUtilsService.copyToClipboard(this.apiUrl);
this.toastService.showToast({

Check warning on line 104 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L102-L104

Added lines #L102 - L104 were not covered by tests
variant: "success",
title: null,
message: this.i18nService.t("valueCopied", this.i18nService.t("apiUrl")),
});
};

copyOrganizationId = () => {
this.platformUtilsService.copyToClipboard(this.organizationId);
this.toastService.showToast({

Check warning on line 113 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L111-L113

Added lines #L111 - L113 were not covered by tests
variant: "success",
title: null,
message: this.i18nService.t("valueCopied", this.i18nService.t("organizationId")),
Expand All @@ -120,7 +118,7 @@
};

ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();

Check warning on line 122 in bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts

View check run for this annotation

Codecov / codecov/patch

bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/config/config.component.ts#L121-L122

Added lines #L121 - L122 were not covered by tests
}
}
Loading