1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00
Files
browser/bitwarden_license/bit-web/src/app/secrets-manager/service-accounts/service-accounts.component.ts
cd-bitwarden c3856ce821 [SM-896] When org is disabled disable the logic and show warning symbols (#6225)
* When org is disabled disable the logic and show warning symbols

* fixing org enabled logic

* removing unused code

* Adding route gaurd logic and new org suspended page

* fixing lint issue

* fixing issues

* Requested changes

* adding back code that was accidentally removed from organization-switcher

* Update bitwarden_license/bit-web/src/app/secrets-manager/shared/org-suspended.component.ts

Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>

* Removing unused code and updating storybook to set enabled:true

* removing onDestroy

* Will's suggestions

* will's suggested change

* fix nav-item color in story

* Thomas Rittson's suggested changes

* adding back removed spaces

* Adding back white space

* updating guard

* Update bitwarden_license/bit-web/src/app/secrets-manager/guards/sm-org-enabled.guard.ts

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>

* removing ununsed data

* Updating incorrect messages

---------

Co-authored-by: Thomas Avery <43214426+Thomas-Avery@users.noreply.github.com>
Co-authored-by: William Martin <contact@willmartian.com>
Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
2023-10-16 14:29:03 +00:00

95 lines
3.1 KiB
TypeScript

import { Component, OnInit } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { combineLatest, Observable, startWith, switchMap } from "rxjs";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { DialogService } from "@bitwarden/components";
import {
ServiceAccountSecretsDetailsView,
ServiceAccountView,
} from "../models/view/service-account.view";
import { AccessPolicyService } from "../shared/access-policies/access-policy.service";
import {
ServiceAccountDeleteDialogComponent,
ServiceAccountDeleteOperation,
} from "./dialog/service-account-delete-dialog.component";
import {
OperationType,
ServiceAccountDialogComponent,
ServiceAccountOperation,
} from "./dialog/service-account-dialog.component";
import { ServiceAccountService } from "./service-account.service";
@Component({
selector: "sm-service-accounts",
templateUrl: "./service-accounts.component.html",
})
export class ServiceAccountsComponent implements OnInit {
protected serviceAccounts$: Observable<ServiceAccountSecretsDetailsView[]>;
protected search: string;
private organizationId: string;
private organizationEnabled: boolean;
constructor(
private route: ActivatedRoute,
private dialogService: DialogService,
private accessPolicyService: AccessPolicyService,
private serviceAccountService: ServiceAccountService,
private organizationService: OrganizationService
) {}
ngOnInit() {
this.serviceAccounts$ = combineLatest([
this.route.params,
this.serviceAccountService.serviceAccount$.pipe(startWith(null)),
this.accessPolicyService.serviceAccountAccessPolicyChanges$.pipe(startWith(null)),
]).pipe(
switchMap(async ([params]) => {
this.organizationId = params.organizationId;
this.organizationEnabled = this.organizationService.get(params.organizationId)?.enabled;
return await this.getServiceAccounts();
})
);
}
openNewServiceAccountDialog() {
this.dialogService.open<unknown, ServiceAccountOperation>(ServiceAccountDialogComponent, {
data: {
organizationId: this.organizationId,
operation: OperationType.Add,
organizationEnabled: this.organizationEnabled,
},
});
}
openEditServiceAccountDialog(serviceAccountId: string) {
this.dialogService.open<unknown, ServiceAccountOperation>(ServiceAccountDialogComponent, {
data: {
organizationId: this.organizationId,
serviceAccountId: serviceAccountId,
operation: OperationType.Edit,
organizationEnabled: this.organizationEnabled,
},
});
}
openDeleteDialog(event: ServiceAccountView[]) {
this.dialogService.open<unknown, ServiceAccountDeleteOperation>(
ServiceAccountDeleteDialogComponent,
{
data: {
serviceAccounts: event,
},
}
);
}
private async getServiceAccounts(): Promise<ServiceAccountSecretsDetailsView[]> {
return await this.serviceAccountService.getServiceAccounts(this.organizationId, true);
}
}