Browse Source
* 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 closepull/5269/merge
9 changed files with 184 additions and 7 deletions
@ -0,0 +1,46 @@
@@ -0,0 +1,46 @@
|
||||
<bit-dialog dialogSize="large"> |
||||
<span bitDialogTitle>{{ "enableSecretsManager" | i18n }}</span> |
||||
<span bitDialogContent> |
||||
<p>{{ "bulkEnableSecretsManagerDescription" | i18n }}</p> |
||||
<bit-table [dataSource]="dataSource"> |
||||
<ng-container header> |
||||
<tr> |
||||
<th bitCell>{{ "member" | i18n }}</th> |
||||
<th bitCell>{{ "role" | i18n }}</th> |
||||
</tr> |
||||
</ng-container> |
||||
<ng-template body let-rows$> |
||||
<tr bitRow *ngFor="let u of rows$ | async"> |
||||
<td bitCell> |
||||
<div class="tw-flex tw-items-center"> |
||||
<bit-avatar |
||||
size="small" |
||||
[text]="u | userName" |
||||
[id]="u.userId" |
||||
[color]="u.avatarColor" |
||||
class="tw-mr-3" |
||||
></bit-avatar> |
||||
<div class="tw-flex tw-flex-col"> |
||||
<div> |
||||
{{ u | userName }} |
||||
</div> |
||||
<div class="tw-text-sm tw-text-muted" *ngIf="u.name"> |
||||
{{ u.email }} |
||||
</div> |
||||
</div> |
||||
</div> |
||||
</td> |
||||
<td bitCell>{{ u.type | userType }}</td> |
||||
</tr> |
||||
</ng-template> |
||||
</bit-table> |
||||
</span> |
||||
<ng-container bitDialogFooter> |
||||
<button type="button" bitButton buttonType="primary" [bitAction]="submit"> |
||||
{{ "enableAccess" | i18n }} |
||||
</button> |
||||
<button type="button" bitButton buttonType="secondary" bitDialogClose> |
||||
{{ "close" | i18n }} |
||||
</button> |
||||
</ng-container> |
||||
</bit-dialog> |
||||
@ -0,0 +1,53 @@
@@ -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<OrganizationUserView>(); |
||||
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<unknown, BulkEnableSecretsManagerDialogData>( |
||||
BulkEnableSecretsManagerDialogComponent, |
||||
{ data } |
||||
); |
||||
} |
||||
} |
||||
Loading…
Reference in new issue