1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-10-22 07:50:04 +02:00

[PM-13769] - fix routing for send created page (#11629)

* fix routing for send created page

* fix test

---------

Co-authored-by: Daniel James Smith <2670567+djsmith85@users.noreply.github.com>
This commit is contained in:
Jordan Aasen 2024-10-21 10:45:07 -07:00 committed by GitHub
parent 77c50860a9
commit 4b9fbfc832
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 8 deletions

View File

@ -114,8 +114,8 @@ export class SendAddEditComponent {
/** /**
* Handles the event when the send is updated. * Handles the event when the send is updated.
*/ */
onSendUpdated(send: SendView) { async onSendUpdated(_: SendView) {
this.location.back(); await this.router.navigate(["/tabs/send"]);
} }
deleteSend = async () => { deleteSend = async () => {

View File

@ -4,7 +4,7 @@
slot="header" slot="header"
[pageTitle]="'createdSend' | i18n" [pageTitle]="'createdSend' | i18n"
showBackButton showBackButton
[backAction]="close.bind(this)" [backAction]="goToEditSend.bind(this)"
> >
<ng-container slot="end"> <ng-container slot="end">
<app-pop-out></app-pop-out> <app-pop-out></app-pop-out>
@ -27,7 +27,7 @@
<button bitButton type="button" buttonType="primary" (click)="copyLink()"> <button bitButton type="button" buttonType="primary" (click)="copyLink()">
<b>{{ "copyLink" | i18n }}</b> <b>{{ "copyLink" | i18n }}</b>
</button> </button>
<button bitButton type="button" buttonType="secondary" (click)="close()"> <button bitButton type="button" buttonType="secondary" (click)="goBack()">
{{ "close" | i18n }} {{ "close" | i18n }}
</button> </button>
</popup-footer> </popup-footer>

View File

@ -11,6 +11,7 @@ import { EnvironmentService } from "@bitwarden/common/platform/abstractions/envi
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service"; import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service"; import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { SelfHostedEnvironment } from "@bitwarden/common/platform/services/default-environment.service"; import { SelfHostedEnvironment } from "@bitwarden/common/platform/services/default-environment.service";
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
import { SendView } from "@bitwarden/common/tools/send/models/view/send.view"; import { SendView } from "@bitwarden/common/tools/send/models/view/send.view";
import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction"; import { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
import { ButtonModule, I18nMockService, IconModule, ToastService } from "@bitwarden/components"; import { ButtonModule, I18nMockService, IconModule, ToastService } from "@bitwarden/components";
@ -50,6 +51,7 @@ describe("SendCreatedComponent", () => {
sendView = { sendView = {
id: sendId, id: sendId,
deletionDate: new Date(), deletionDate: new Date(),
type: SendType.Text,
accessId: "abc", accessId: "abc",
urlB64Key: "123", urlB64Key: "123",
} as SendView; } as SendView;
@ -129,9 +131,11 @@ describe("SendCreatedComponent", () => {
expect(component["hoursAvailable"]).toBe(0); expect(component["hoursAvailable"]).toBe(0);
}); });
it("should navigate back to send list on close", async () => { it("should navigate back to the edit send form on close", async () => {
await component.close(); await component.goToEditSend();
expect(router.navigate).toHaveBeenCalledWith(["/tabs/send"]); expect(router.navigate).toHaveBeenCalledWith(["/edit-send"], {
queryParams: { sendId: "test-send-id", type: SendType.Text },
});
}); });
describe("getHoursAvailable", () => { describe("getHoursAvailable", () => {

View File

@ -77,7 +77,13 @@ export class SendCreatedComponent {
return Math.max(0, Math.ceil((send.deletionDate.getTime() - now) / (1000 * 60 * 60))); return Math.max(0, Math.ceil((send.deletionDate.getTime() - now) / (1000 * 60 * 60)));
} }
async close() { async goToEditSend() {
await this.router.navigate([`/edit-send`], {
queryParams: { sendId: this.send.id, type: this.send.type },
});
}
async goBack() {
await this.router.navigate(["/tabs/send"]); await this.router.navigate(["/tabs/send"]);
} }