SM-716 - Write access for service accounts (#5622)

* SM-716

* thomas suggested changes

* removing unused code

* 2
This commit is contained in:
cd-bitwarden 2023-06-30 13:17:26 -04:00 committed by GitHub
parent 05c4d172a7
commit b845eaf91f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 4 deletions

View File

@ -11,6 +11,7 @@
[emptyMessage]="'projectEmptyServiceAccountAccessPolicies' | i18n"
(onCreateAccessPolicies)="handleCreateAccessPolicies($event)"
(onDeleteAccessPolicy)="handleDeleteAccessPolicy($event)"
(onUpdateAccessPolicy)="handleUpdateAccessPolicy($event)"
>
</sm-access-selector>
</div>

View File

@ -39,11 +39,21 @@ export class ProjectServiceAccountsComponent implements OnInit, OnDestroy {
read: policy.read,
write: policy.write,
icon: AccessSelectorComponent.serviceAccountIcon,
static: true,
static: false,
}))
)
);
protected async handleUpdateAccessPolicy(policy: AccessSelectorRowView) {
try {
return await this.accessPolicyService.updateAccessPolicy(
AccessSelectorComponent.getBaseAccessPolicyView(policy)
);
} catch (e) {
this.validationService.showError(e);
}
}
protected handleCreateAccessPolicies(selected: SelectItemView[]) {
const projectAccessPoliciesView = new ProjectAccessPoliciesView();
projectAccessPoliciesView.serviceAccountAccessPolicies = selected

View File

@ -11,6 +11,7 @@
[emptyMessage]="'serviceAccountEmptyProjectAccesspolicies' | i18n"
(onCreateAccessPolicies)="handleCreateAccessPolicies($event)"
(onDeleteAccessPolicy)="handleDeleteAccessPolicy($event)"
(onUpdateAccessPolicy)="handleUpdateAccessPolicy($event)"
>
</sm-access-selector>
</div>

View File

@ -1,4 +1,4 @@
import { Component } from "@angular/core";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { combineLatestWith, map, Observable, startWith, Subject, switchMap, takeUntil } from "rxjs";
@ -16,7 +16,7 @@ import {
selector: "sm-service-account-projects",
templateUrl: "./service-account-projects.component.html",
})
export class ServiceAccountProjectsComponent {
export class ServiceAccountProjectsComponent implements OnInit, OnDestroy {
private destroy$ = new Subject<void>();
private serviceAccountId: string;
private organizationId: string;
@ -38,7 +38,7 @@ export class ServiceAccountProjectsComponent {
read: policy.read,
write: policy.write,
icon: AccessSelectorComponent.projectIcon,
static: true,
static: false,
} as AccessSelectorRowView;
});
})
@ -63,6 +63,16 @@ export class ServiceAccountProjectsComponent {
);
}
protected async handleUpdateAccessPolicy(policy: AccessSelectorRowView) {
try {
return await this.accessPolicyService.updateAccessPolicy(
AccessSelectorComponent.getBaseAccessPolicyView(policy)
);
} catch (e) {
this.validationService.showError(e);
}
}
protected async handleDeleteAccessPolicy(policy: AccessSelectorRowView) {
try {
await this.accessPolicyService.deleteAccessPolicy(policy.accessPolicyId);