mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-23 11:56:00 +01:00
[AC-1999] Fix deleting collections from collection dialog (#8647)
* [AC-1999] Fix null check this.collection can be both null or unassigned and `!= null` will handle both cases. * [AC-1999] Navigate away when selected collection is deleted --------- Co-authored-by: bnagawiecki <107435978+bnagawiecki@users.noreply.github.com>
This commit is contained in:
parent
100b43dd8f
commit
b395cb40a7
@ -679,6 +679,14 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
} else if (result.action === CollectionDialogAction.Deleted) {
|
} else if (result.action === CollectionDialogAction.Deleted) {
|
||||||
await this.collectionService.delete(result.collection?.id);
|
await this.collectionService.delete(result.collection?.id);
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
// Navigate away if we deleted the collection we were viewing
|
||||||
|
if (this.selectedCollection?.node.id === c?.id) {
|
||||||
|
void this.router.navigate([], {
|
||||||
|
queryParams: { collectionId: this.selectedCollection.parent?.node.id ?? null },
|
||||||
|
queryParamsHandling: "merge",
|
||||||
|
replaceUrl: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -710,9 +718,7 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
);
|
);
|
||||||
// Navigate away if we deleted the collection we were viewing
|
// Navigate away if we deleted the collection we were viewing
|
||||||
if (this.selectedCollection?.node.id === collection.id) {
|
if (this.selectedCollection?.node.id === collection.id) {
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
void this.router.navigate([], {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
this.router.navigate([], {
|
|
||||||
queryParams: { collectionId: this.selectedCollection.parent?.node.id ?? null },
|
queryParams: { collectionId: this.selectedCollection.parent?.node.id ?? null },
|
||||||
queryParamsHandling: "merge",
|
queryParamsHandling: "merge",
|
||||||
replaceUrl: true,
|
replaceUrl: true,
|
||||||
|
@ -80,7 +80,7 @@ export class VaultHeaderComponent implements OnInit {
|
|||||||
? this.i18nService.t("collections").toLowerCase()
|
? this.i18nService.t("collections").toLowerCase()
|
||||||
: this.i18nService.t("vault").toLowerCase();
|
: this.i18nService.t("vault").toLowerCase();
|
||||||
|
|
||||||
if (this.collection !== undefined) {
|
if (this.collection != null) {
|
||||||
return this.collection.node.name;
|
return this.collection.node.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -958,11 +958,9 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
this.i18nService.t("deletedCollectionId", collection.name),
|
this.i18nService.t("deletedCollectionId", collection.name),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Navigate away if we deleted the colletion we were viewing
|
// Navigate away if we deleted the collection we were viewing
|
||||||
if (this.selectedCollection?.node.id === collection.id) {
|
if (this.selectedCollection?.node.id === collection.id) {
|
||||||
// FIXME: Verify that this floating promise is intentional. If it is, add an explanatory comment and ensure there is proper error handling.
|
void this.router.navigate([], {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
this.router.navigate([], {
|
|
||||||
queryParams: { collectionId: this.selectedCollection.parent?.node.id ?? null },
|
queryParams: { collectionId: this.selectedCollection.parent?.node.id ?? null },
|
||||||
queryParamsHandling: "merge",
|
queryParamsHandling: "merge",
|
||||||
replaceUrl: true,
|
replaceUrl: true,
|
||||||
@ -1095,6 +1093,18 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
result.action === CollectionDialogAction.Deleted
|
result.action === CollectionDialogAction.Deleted
|
||||||
) {
|
) {
|
||||||
this.refresh();
|
this.refresh();
|
||||||
|
|
||||||
|
// If we deleted the selected collection, navigate up/away
|
||||||
|
if (
|
||||||
|
result.action === CollectionDialogAction.Deleted &&
|
||||||
|
this.selectedCollection?.node.id === c?.id
|
||||||
|
) {
|
||||||
|
void this.router.navigate([], {
|
||||||
|
queryParams: { collectionId: this.selectedCollection.parent?.node.id ?? null },
|
||||||
|
queryParamsHandling: "merge",
|
||||||
|
replaceUrl: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user