1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-22 16:29:09 +01:00

[AC-1921] Fix undefined property errors when bulk deleting collections (#7336)

* Fix bulk delete collections in individual vault

* Fix deleting collections in org vault
This commit is contained in:
Thomas Rittson 2024-01-03 07:00:37 +10:00 committed by GitHub
parent 4acd951114
commit fb0e8fc2ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 12 deletions

View File

@ -7,8 +7,8 @@
<span *ngIf="cipherIds?.length"> <span *ngIf="cipherIds?.length">
{{ "deleteSelectedItemsDesc" | i18n: cipherIds.length }} {{ "deleteSelectedItemsDesc" | i18n: cipherIds.length }}
</span> </span>
<span *ngIf="collectionIds?.length"> <span *ngIf="collections?.length">
{{ "deleteSelectedCollectionsDesc" | i18n: collectionIds.length }} {{ "deleteSelectedCollectionsDesc" | i18n: collections.length }}
</span> </span>
{{ "deleteSelectedConfirmation" | i18n }} {{ "deleteSelectedConfirmation" | i18n }}
</ng-container> </ng-container>

View File

@ -15,7 +15,6 @@ import { DialogService } from "@bitwarden/components";
export interface BulkDeleteDialogParams { export interface BulkDeleteDialogParams {
cipherIds?: string[]; cipherIds?: string[];
collectionIds?: string[];
permanent?: boolean; permanent?: boolean;
organization?: Organization; organization?: Organization;
organizations?: Organization[]; organizations?: Organization[];
@ -47,7 +46,6 @@ export const openBulkDeleteDialog = (
}) })
export class BulkDeleteDialogComponent { export class BulkDeleteDialogComponent {
cipherIds: string[]; cipherIds: string[];
collectionIds: string[];
permanent = false; permanent = false;
organization: Organization; organization: Organization;
organizations: Organization[]; organizations: Organization[];
@ -64,7 +62,6 @@ export class BulkDeleteDialogComponent {
private configService: ConfigServiceAbstraction, private configService: ConfigServiceAbstraction,
) { ) {
this.cipherIds = params.cipherIds ?? []; this.cipherIds = params.cipherIds ?? [];
this.collectionIds = params.collectionIds ?? [];
this.permanent = params.permanent; this.permanent = params.permanent;
this.organization = params.organization; this.organization = params.organization;
this.organizations = params.organizations; this.organizations = params.organizations;
@ -85,7 +82,7 @@ export class BulkDeleteDialogComponent {
} }
} }
if (this.collectionIds.length) { if (this.collections.length) {
deletePromises.push(this.deleteCollections()); deletePromises.push(this.deleteCollections());
} }
@ -98,8 +95,8 @@ export class BulkDeleteDialogComponent {
this.i18nService.t(this.permanent ? "permanentlyDeletedItems" : "deletedItems"), this.i18nService.t(this.permanent ? "permanentlyDeletedItems" : "deletedItems"),
); );
} }
if (this.collectionIds.length) { if (this.collections.length) {
await this.collectionService.delete(this.collectionIds); await this.collectionService.delete(this.collections.map((c) => c.id));
this.platformUtilsService.showToast( this.platformUtilsService.showToast(
"success", "success",
null, null,
@ -144,7 +141,10 @@ export class BulkDeleteDialogComponent {
); );
return; return;
} }
return await this.apiService.deleteManyCollections(this.organization.id, this.collectionIds); return await this.apiService.deleteManyCollections(
this.organization.id,
this.collections.map((c) => c.id),
);
// From individual vault, so there can be multiple organizations // From individual vault, so there can be multiple organizations
} else if (this.organizations && this.collections) { } else if (this.organizations && this.collections) {
const deletePromises: Promise<any>[] = []; const deletePromises: Promise<any>[] = [];
@ -160,7 +160,7 @@ export class BulkDeleteDialogComponent {
} }
const orgCollectionIds = orgCollections.map((c) => c.id); const orgCollectionIds = orgCollections.map((c) => c.id);
deletePromises.push( deletePromises.push(
this.apiService.deleteManyCollections(this.organization.id, orgCollectionIds), this.apiService.deleteManyCollections(organization.id, orgCollectionIds),
); );
} }
return await Promise.all(deletePromises); return await Promise.all(deletePromises);

View File

@ -856,7 +856,6 @@ export class VaultComponent implements OnInit, OnDestroy {
data: { data: {
permanent: this.filter.type === "trash", permanent: this.filter.type === "trash",
cipherIds: ciphers.map((c) => c.id), cipherIds: ciphers.map((c) => c.id),
collectionIds: collections.map((c) => c.id),
organizations: organizations, organizations: organizations,
collections: collections, collections: collections,
}, },

View File

@ -816,7 +816,7 @@ export class VaultComponent implements OnInit, OnDestroy {
data: { data: {
permanent: this.filter.type === "trash", permanent: this.filter.type === "trash",
cipherIds: ciphers.map((c) => c.id), cipherIds: ciphers.map((c) => c.id),
collectionIds: collections.map((c) => c.id), collections: collections,
organization, organization,
}, },
}); });