mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-21 16:18:28 +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:
parent
4acd951114
commit
fb0e8fc2ff
@ -7,8 +7,8 @@
|
||||
<span *ngIf="cipherIds?.length">
|
||||
{{ "deleteSelectedItemsDesc" | i18n: cipherIds.length }}
|
||||
</span>
|
||||
<span *ngIf="collectionIds?.length">
|
||||
{{ "deleteSelectedCollectionsDesc" | i18n: collectionIds.length }}
|
||||
<span *ngIf="collections?.length">
|
||||
{{ "deleteSelectedCollectionsDesc" | i18n: collections.length }}
|
||||
</span>
|
||||
{{ "deleteSelectedConfirmation" | i18n }}
|
||||
</ng-container>
|
||||
|
@ -15,7 +15,6 @@ import { DialogService } from "@bitwarden/components";
|
||||
|
||||
export interface BulkDeleteDialogParams {
|
||||
cipherIds?: string[];
|
||||
collectionIds?: string[];
|
||||
permanent?: boolean;
|
||||
organization?: Organization;
|
||||
organizations?: Organization[];
|
||||
@ -47,7 +46,6 @@ export const openBulkDeleteDialog = (
|
||||
})
|
||||
export class BulkDeleteDialogComponent {
|
||||
cipherIds: string[];
|
||||
collectionIds: string[];
|
||||
permanent = false;
|
||||
organization: Organization;
|
||||
organizations: Organization[];
|
||||
@ -64,7 +62,6 @@ export class BulkDeleteDialogComponent {
|
||||
private configService: ConfigServiceAbstraction,
|
||||
) {
|
||||
this.cipherIds = params.cipherIds ?? [];
|
||||
this.collectionIds = params.collectionIds ?? [];
|
||||
this.permanent = params.permanent;
|
||||
this.organization = params.organization;
|
||||
this.organizations = params.organizations;
|
||||
@ -85,7 +82,7 @@ export class BulkDeleteDialogComponent {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.collectionIds.length) {
|
||||
if (this.collections.length) {
|
||||
deletePromises.push(this.deleteCollections());
|
||||
}
|
||||
|
||||
@ -98,8 +95,8 @@ export class BulkDeleteDialogComponent {
|
||||
this.i18nService.t(this.permanent ? "permanentlyDeletedItems" : "deletedItems"),
|
||||
);
|
||||
}
|
||||
if (this.collectionIds.length) {
|
||||
await this.collectionService.delete(this.collectionIds);
|
||||
if (this.collections.length) {
|
||||
await this.collectionService.delete(this.collections.map((c) => c.id));
|
||||
this.platformUtilsService.showToast(
|
||||
"success",
|
||||
null,
|
||||
@ -144,7 +141,10 @@ export class BulkDeleteDialogComponent {
|
||||
);
|
||||
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
|
||||
} else if (this.organizations && this.collections) {
|
||||
const deletePromises: Promise<any>[] = [];
|
||||
@ -160,7 +160,7 @@ export class BulkDeleteDialogComponent {
|
||||
}
|
||||
const orgCollectionIds = orgCollections.map((c) => c.id);
|
||||
deletePromises.push(
|
||||
this.apiService.deleteManyCollections(this.organization.id, orgCollectionIds),
|
||||
this.apiService.deleteManyCollections(organization.id, orgCollectionIds),
|
||||
);
|
||||
}
|
||||
return await Promise.all(deletePromises);
|
||||
|
@ -856,7 +856,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
data: {
|
||||
permanent: this.filter.type === "trash",
|
||||
cipherIds: ciphers.map((c) => c.id),
|
||||
collectionIds: collections.map((c) => c.id),
|
||||
organizations: organizations,
|
||||
collections: collections,
|
||||
},
|
||||
|
@ -816,7 +816,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
data: {
|
||||
permanent: this.filter.type === "trash",
|
||||
cipherIds: ciphers.map((c) => c.id),
|
||||
collectionIds: collections.map((c) => c.id),
|
||||
collections: collections,
|
||||
organization,
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user