Skip to content

Commit

Permalink
[PM-12425] Remove FF: AC-2828_provider-portal-members-page (#11241)
Browse files Browse the repository at this point in the history
* Remove FF: AC-2828_provider-portal-members-page

* Thomas' feedback: Fix provider layout
  • Loading branch information
amorask-bitwarden authored Oct 22, 2024
1 parent 9a1879b commit 470ddf7
Show file tree
Hide file tree
Showing 18 changed files with 164 additions and 775 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { DIALOG_DATA, DialogConfig } from "@angular/cdk/dialog";
import { Component, Inject } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { firstValueFrom, map, Observable, switchMap } from "rxjs";

import {
OrganizationUserApiService,
OrganizationUserBulkConfirmRequest,
OrganizationUserBulkPublicKeyResponse,
OrganizationUserBulkResponse,
} from "@bitwarden/admin-console/common";
import { OrganizationUserStatusType } from "@bitwarden/common/admin-console/enums";
import { ProviderUserBulkPublicKeyResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk-public-key.response";
import { ProviderUserBulkResponse } from "@bitwarden/common/admin-console/models/response/provider/provider-user-bulk.response";
import { ListResponse } from "@bitwarden/common/models/response/list.response";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
import { StateProvider } from "@bitwarden/common/platform/state";
import { OrganizationId } from "@bitwarden/common/types/guid";
import { OrgKey } from "@bitwarden/common/types/key";
import { DialogService } from "@bitwarden/components";

import { BaseBulkConfirmComponent } from "./base-bulk-confirm.component";
import { BulkUserDetails } from "./bulk-status.component";

type BulkConfirmDialogParams = {
organizationId: string;
users: BulkUserDetails[];
};

@Component({
templateUrl: "bulk-confirm-dialog.component.html",
})
export class BulkConfirmDialogComponent extends BaseBulkConfirmComponent {
organizationId: string;
organizationKey$: Observable<OrgKey>;
users: BulkUserDetails[];

constructor(
protected cryptoService: CryptoService,
@Inject(DIALOG_DATA) protected dialogParams: BulkConfirmDialogParams,
protected encryptService: EncryptService,
private organizationUserApiService: OrganizationUserApiService,
protected i18nService: I18nService,
private stateProvider: StateProvider,
) {
super(cryptoService, encryptService, i18nService);

this.organizationId = dialogParams.organizationId;
this.organizationKey$ = this.stateProvider.activeUserId$.pipe(
switchMap((userId) => this.cryptoService.orgKeys$(userId)),
map((organizationKeysById) => organizationKeysById[this.organizationId as OrganizationId]),
takeUntilDestroyed(),
);
this.users = dialogParams.users;
}

protected getCryptoKey = async (): Promise<SymmetricCryptoKey> =>
await firstValueFrom(this.organizationKey$);

protected getPublicKeys = async (): Promise<
ListResponse<OrganizationUserBulkPublicKeyResponse | ProviderUserBulkPublicKeyResponse>
> =>
await this.organizationUserApiService.postOrganizationUsersPublicKey(
this.organizationId,
this.filteredUsers.map((user) => user.id),
);

protected isAccepted = (user: BulkUserDetails) =>
user.status === OrganizationUserStatusType.Accepted;

protected postConfirmRequest = async (
userIdsWithKeys: { id: string; key: string }[],
): Promise<ListResponse<OrganizationUserBulkResponse | ProviderUserBulkResponse>> => {
const request = new OrganizationUserBulkConfirmRequest(userIdsWithKeys);
return await this.organizationUserApiService.postOrganizationUserBulkConfirm(
this.organizationId,
request,
);
};

static open(dialogService: DialogService, config: DialogConfig<BulkConfirmDialogParams>) {
return dialogService.open(BulkConfirmDialogComponent, config);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { DIALOG_DATA, DialogConfig } from "@angular/cdk/dialog";
import { Component, Inject } from "@angular/core";

import {
OrganizationUserApiService,
OrganizationUserBulkResponse,
} from "@bitwarden/admin-console/common";
import { OrganizationUserStatusType } from "@bitwarden/common/admin-console/enums";
import { ListResponse } from "@bitwarden/common/models/response/list.response";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { DialogService } from "@bitwarden/components";

import { BaseBulkRemoveComponent } from "./base-bulk-remove.component";
import { BulkUserDetails } from "./bulk-status.component";

type BulkRemoveDialogParams = {
organizationId: string;
users: BulkUserDetails[];
};

@Component({
templateUrl: "bulk-remove-dialog.component.html",
})
export class BulkRemoveDialogComponent extends BaseBulkRemoveComponent {
organizationId: string;
users: BulkUserDetails[];

constructor(
@Inject(DIALOG_DATA) protected dialogParams: BulkRemoveDialogParams,
protected i18nService: I18nService,
private organizationUserApiService: OrganizationUserApiService,
) {
super(i18nService);
this.organizationId = dialogParams.organizationId;
this.users = dialogParams.users;
this.showNoMasterPasswordWarning = this.users.some(
(u) => u.status > OrganizationUserStatusType.Invited && u.hasMasterPassword === false,
);
}

protected deleteUsers = (): Promise<ListResponse<OrganizationUserBulkResponse>> =>
this.organizationUserApiService.removeManyOrganizationUsers(
this.organizationId,
this.users.map((user) => user.id),
);

protected get removeUsersWarning() {
return this.i18nService.t("removeOrgUsersConfirmation");
}

static open(dialogService: DialogService, config: DialogConfig<BulkRemoveDialogParams>) {
return dialogService.open(BulkRemoveDialogComponent, config);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ import { GroupService } from "../core";
import { OrganizationUserView } from "../core/views/organization-user.view";
import { openEntityEventsDialog } from "../manage/entity-events.component";

import { BulkConfirmComponent } from "./components/bulk/bulk-confirm.component";
import { BulkConfirmDialogComponent } from "./components/bulk/bulk-confirm-dialog.component";
import { BulkEnableSecretsManagerDialogComponent } from "./components/bulk/bulk-enable-sm-dialog.component";
import { BulkRemoveComponent } from "./components/bulk/bulk-remove.component";
import { BulkRemoveDialogComponent } from "./components/bulk/bulk-remove-dialog.component";
import { BulkRestoreRevokeComponent } from "./components/bulk/bulk-restore-revoke.component";
import { BulkStatusComponent } from "./components/bulk/bulk-status.component";
import {
Expand Down Expand Up @@ -541,7 +541,7 @@ export class MembersComponent extends BaseMembersComponent<OrganizationUserView>
return;
}

const dialogRef = BulkRemoveComponent.open(this.dialogService, {
const dialogRef = BulkRemoveDialogComponent.open(this.dialogService, {
data: {
organizationId: this.organization.id,
users: this.dataSource.getCheckedUsers(),
Expand Down Expand Up @@ -620,7 +620,7 @@ export class MembersComponent extends BaseMembersComponent<OrganizationUserView>
return;
}

const dialogRef = BulkConfirmComponent.open(this.dialogService, {
const dialogRef = BulkConfirmDialogComponent.open(this.dialogService, {
data: {
organizationId: this.organization.id,
users: this.dataSource.getCheckedUsers(),
Expand Down
Loading

0 comments on commit 470ddf7

Please sign in to comment.