From 8b64f0de9cb7640d3d790f16e97e0785249fb32f Mon Sep 17 00:00:00 2001
From: cd-bitwarden <106776772+cd-bitwarden@users.noreply.github.com>
Date: Fri, 25 Oct 2024 14:19:56 -0400
Subject: [PATCH] [PM-1992] in ac add current collection actions in menu and
deprecate collections component (#11364)
* Removing feature flag
* Removing flag from feature-flag.enum.ts
* suggested changes
* prettier
* fixing merge conflict issue
* Removing unused code
* suggested change from Gbubemi
* Adding back merge conflict code
* fixing prettier styling
* Deprecating collections component, removing unused code now that we dont use collections component in AC
* Removing all Collections component logic from loos-components module and removing the files themselves as they are no longer needed.
---
.../src/app/shared/loose-components.module.ts | 6 -
.../collections.component.html | 52 --------
.../individual-vault/collections.component.ts | 90 --------------
.../vault/org-vault/collections.component.ts | 115 ------------------
.../app/vault/org-vault/vault.component.ts | 35 ------
5 files changed, 298 deletions(-)
delete mode 100644 apps/web/src/app/vault/individual-vault/collections.component.html
delete mode 100644 apps/web/src/app/vault/individual-vault/collections.component.ts
delete mode 100644 apps/web/src/app/vault/org-vault/collections.component.ts
diff --git a/apps/web/src/app/shared/loose-components.module.ts b/apps/web/src/app/shared/loose-components.module.ts
index 29b4f2308c..638a523cd4 100644
--- a/apps/web/src/app/shared/loose-components.module.ts
+++ b/apps/web/src/app/shared/loose-components.module.ts
@@ -76,13 +76,11 @@ import { PremiumBadgeComponent } from "../vault/components/premium-badge.compone
import { AddEditCustomFieldsComponent } from "../vault/individual-vault/add-edit-custom-fields.component";
import { AddEditComponent } from "../vault/individual-vault/add-edit.component";
import { AttachmentsComponent } from "../vault/individual-vault/attachments.component";
-import { CollectionsComponent } from "../vault/individual-vault/collections.component";
import { FolderAddEditComponent } from "../vault/individual-vault/folder-add-edit.component";
import { OrganizationBadgeModule } from "../vault/individual-vault/organization-badge/organization-badge.module";
import { PipesModule } from "../vault/individual-vault/pipes/pipes.module";
import { AddEditComponent as OrgAddEditComponent } from "../vault/org-vault/add-edit.component";
import { AttachmentsComponent as OrgAttachmentsComponent } from "../vault/org-vault/attachments.component";
-import { CollectionsComponent as OrgCollectionsComponent } from "../vault/org-vault/collections.component";
import { PurgeVaultComponent } from "../vault/settings/purge-vault.component";
import { EnvironmentSelectorModule } from "./../components/environment-selector/environment-selector.module";
@@ -123,7 +121,6 @@ import { SharedModule } from "./shared.module";
ApiKeyComponent,
AttachmentsComponent,
ChangeEmailComponent,
- CollectionsComponent,
DeauthorizeSessionsComponent,
DeleteAccountDialogComponent,
DomainRulesComponent,
@@ -139,7 +136,6 @@ import { SharedModule } from "./shared.module";
HintComponent,
OrgAddEditComponent,
OrgAttachmentsComponent,
- OrgCollectionsComponent,
OrgEventsComponent,
OrgExposedPasswordsReportComponent,
OrgInactiveTwoFactorReportComponent,
@@ -192,7 +188,6 @@ import { SharedModule } from "./shared.module";
ApiKeyComponent,
AttachmentsComponent,
ChangeEmailComponent,
- CollectionsComponent,
DeauthorizeSessionsComponent,
DeleteAccountDialogComponent,
DomainRulesComponent,
@@ -210,7 +205,6 @@ import { SharedModule } from "./shared.module";
OrgAddEditComponent,
OrganizationLayoutComponent,
OrgAttachmentsComponent,
- OrgCollectionsComponent,
OrgEventsComponent,
OrgExposedPasswordsReportComponent,
OrgInactiveTwoFactorReportComponent,
diff --git a/apps/web/src/app/vault/individual-vault/collections.component.html b/apps/web/src/app/vault/individual-vault/collections.component.html
deleted file mode 100644
index 028d91ad34..0000000000
--- a/apps/web/src/app/vault/individual-vault/collections.component.html
+++ /dev/null
@@ -1,52 +0,0 @@
-
diff --git a/apps/web/src/app/vault/individual-vault/collections.component.ts b/apps/web/src/app/vault/individual-vault/collections.component.ts
deleted file mode 100644
index f527a74e36..0000000000
--- a/apps/web/src/app/vault/individual-vault/collections.component.ts
+++ /dev/null
@@ -1,90 +0,0 @@
-import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog";
-import { Component, Inject, OnDestroy } from "@angular/core";
-
-import { CollectionService, CollectionView } from "@bitwarden/admin-console/common";
-import { CollectionsComponent as BaseCollectionsComponent } from "@bitwarden/angular/admin-console/components/collections.component";
-import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
-import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
-import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
-import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
-import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
-import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
-import { DialogService, ToastService } from "@bitwarden/components";
-
-@Component({
- selector: "app-vault-collections",
- templateUrl: "collections.component.html",
-})
-export class CollectionsComponent extends BaseCollectionsComponent implements OnDestroy {
- constructor(
- collectionService: CollectionService,
- platformUtilsService: PlatformUtilsService,
- i18nService: I18nService,
- cipherService: CipherService,
- organizationSerivce: OrganizationService,
- logService: LogService,
- accountService: AccountService,
- protected dialogRef: DialogRef,
- @Inject(DIALOG_DATA) params: CollectionsDialogParams,
- toastService: ToastService,
- ) {
- super(
- collectionService,
- platformUtilsService,
- i18nService,
- cipherService,
- organizationSerivce,
- logService,
- accountService,
- toastService,
- );
- this.cipherId = params?.cipherId;
- }
-
- override async submit(): Promise {
- const success = await super.submit();
- if (success) {
- this.dialogRef.close(CollectionsDialogResult.Saved);
- return true;
- }
- return false;
- }
-
- check(c: CollectionView, select?: boolean) {
- if (!c.canEditItems(this.organization)) {
- return;
- }
- (c as any).checked = select == null ? !(c as any).checked : select;
- }
-
- selectAll(select: boolean) {
- this.collections.forEach((c) => this.check(c, select));
- }
-
- ngOnDestroy() {
- this.selectAll(false);
- }
-}
-
-export interface CollectionsDialogParams {
- cipherId: string;
-}
-
-export enum CollectionsDialogResult {
- Saved = "saved",
-}
-
-/**
- * Strongly typed helper to open a Collections dialog
- * @param dialogService Instance of the dialog service that will be used to open the dialog
- * @param config Optional configuration for the dialog
- */
-export function openIndividualVaultCollectionsDialog(
- dialogService: DialogService,
- config?: DialogConfig,
-) {
- return dialogService.open(
- CollectionsComponent,
- config,
- );
-}
diff --git a/apps/web/src/app/vault/org-vault/collections.component.ts b/apps/web/src/app/vault/org-vault/collections.component.ts
deleted file mode 100644
index 47f5325c75..0000000000
--- a/apps/web/src/app/vault/org-vault/collections.component.ts
+++ /dev/null
@@ -1,115 +0,0 @@
-import { DIALOG_DATA, DialogConfig, DialogRef } from "@angular/cdk/dialog";
-import { Component, Inject } from "@angular/core";
-
-import { CollectionService, CollectionView } from "@bitwarden/admin-console/common";
-import { ApiService } from "@bitwarden/common/abstractions/api.service";
-import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
-import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
-import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
-import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
-import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
-import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
-import { CipherService } from "@bitwarden/common/vault/abstractions/cipher.service";
-import { CipherData } from "@bitwarden/common/vault/models/data/cipher.data";
-import { Cipher } from "@bitwarden/common/vault/models/domain/cipher";
-import { CipherCollectionsRequest } from "@bitwarden/common/vault/models/request/cipher-collections.request";
-import { DialogService, ToastService } from "@bitwarden/components";
-
-import {
- CollectionsComponent as BaseCollectionsComponent,
- CollectionsDialogResult,
-} from "../individual-vault/collections.component";
-
-@Component({
- selector: "app-org-vault-collections",
- templateUrl: "../../vault/individual-vault/collections.component.html",
-})
-export class CollectionsComponent extends BaseCollectionsComponent {
- organization: Organization;
-
- constructor(
- collectionService: CollectionService,
- platformUtilsService: PlatformUtilsService,
- i18nService: I18nService,
- cipherService: CipherService,
- organizationService: OrganizationService,
- private apiService: ApiService,
- logService: LogService,
- accountService: AccountService,
- protected dialogRef: DialogRef,
- @Inject(DIALOG_DATA) params: OrgVaultCollectionsDialogParams,
- toastService: ToastService,
- ) {
- super(
- collectionService,
- platformUtilsService,
- i18nService,
- cipherService,
- organizationService,
- logService,
- accountService,
- dialogRef,
- params,
- toastService,
- );
- this.allowSelectNone = true;
- this.collectionIds = params?.collectionIds;
- this.collections = params?.collections;
- this.organization = params?.organization;
- this.cipherId = params?.cipherId;
- }
-
- protected async loadCipher() {
- // if cipher is unassigned use apiService. We can see this by looking at this.collectionIds
- if (!this.organization.canEditAllCiphers && this.collectionIds.length !== 0) {
- return await super.loadCipher();
- }
- const response = await this.apiService.getCipherAdmin(this.cipherId);
- return new Cipher(new CipherData(response));
- }
-
- protected loadCipherCollections() {
- if (!this.organization.canViewAllCollections) {
- return super.loadCipherCollections();
- }
- return this.collectionIds;
- }
-
- protected loadCollections() {
- if (!this.organization.canViewAllCollections) {
- return super.loadCollections();
- }
- return Promise.resolve(this.collections);
- }
-
- protected saveCollections() {
- if (this.organization.canEditAllCiphers || this.collectionIds.length === 0) {
- const request = new CipherCollectionsRequest(this.cipherDomain.collectionIds);
- return this.apiService.putCipherCollectionsAdmin(this.cipherId, request);
- } else {
- return super.saveCollections();
- }
- }
-}
-
-export interface OrgVaultCollectionsDialogParams {
- collectionIds: string[];
- collections: CollectionView[];
- organization: Organization;
- cipherId: string;
-}
-
-/**
- * Strongly typed helper to open a Collections dialog
- * @param dialogService Instance of the dialog service that will be used to open the dialog
- * @param config Optional configuration for the dialog
- */
-export function openOrgVaultCollectionsDialog(
- dialogService: DialogService,
- config?: DialogConfig,
-) {
- return dialogService.open(
- CollectionsComponent,
- config,
- );
-}
diff --git a/apps/web/src/app/vault/org-vault/vault.component.ts b/apps/web/src/app/vault/org-vault/vault.component.ts
index 87e40036d5..4c7e35ef6f 100644
--- a/apps/web/src/app/vault/org-vault/vault.component.ts
+++ b/apps/web/src/app/vault/org-vault/vault.component.ts
@@ -93,7 +93,6 @@ import {
BulkDeleteDialogResult,
openBulkDeleteDialog,
} from "../individual-vault/bulk-action-dialogs/bulk-delete-dialog/bulk-delete-dialog.component";
-import { CollectionsDialogResult } from "../individual-vault/collections.component";
import { RoutedVaultFilterBridgeService } from "../individual-vault/vault-filter/services/routed-vault-filter-bridge.service";
import { RoutedVaultFilterService } from "../individual-vault/vault-filter/services/routed-vault-filter.service";
import { createFilterFunction } from "../individual-vault/vault-filter/shared/models/filter-function";
@@ -111,7 +110,6 @@ import {
BulkCollectionsDialogResult,
} from "./bulk-collections-dialog";
import { CollectionAccessRestrictedComponent } from "./collection-access-restricted.component";
-import { openOrgVaultCollectionsDialog } from "./collections.component";
import { AdminConsoleCipherFormConfigService } from "./services/admin-console-cipher-form-config.service";
import { VaultFilterModule } from "./vault-filter/vault-filter.module";
const BroadcasterSubscriptionId = "OrgVaultComponent";
@@ -718,39 +716,6 @@ export class VaultComponent implements OnInit, OnDestroy {
});
}
- async editCipherCollections(cipher: CipherView) {
- let collections: CollectionAdminView[] = [];
-
- // Admins limited to only adding items to collections they have access to.
- collections = await firstValueFrom(
- this.allCollectionsWithoutUnassigned$.pipe(
- map((c) => {
- return c.sort((a, b) => {
- if (a.canEditItems(this.organization) && !b.canEditItems(this.organization)) {
- return -1;
- } else if (!a.canEditItems(this.organization) && b.canEditItems(this.organization)) {
- return 1;
- } else {
- return a.name.localeCompare(b.name);
- }
- });
- }),
- ),
- );
- const dialog = openOrgVaultCollectionsDialog(this.dialogService, {
- data: {
- collectionIds: cipher.collectionIds,
- collections: collections,
- organization: this.organization,
- cipherId: cipher.id,
- },
- });
-
- if ((await lastValueFrom(dialog.closed)) == CollectionsDialogResult.Saved) {
- this.refresh();
- }
- }
-
async addCipher(cipherType?: CipherType) {
if (this.extensionRefreshEnabled) {
return this.addCipherV2(cipherType);