mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-21 16:18:28 +01: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:
parent
77c50860a9
commit
4b9fbfc832
@ -114,8 +114,8 @@ export class SendAddEditComponent {
|
||||
/**
|
||||
* Handles the event when the send is updated.
|
||||
*/
|
||||
onSendUpdated(send: SendView) {
|
||||
this.location.back();
|
||||
async onSendUpdated(_: SendView) {
|
||||
await this.router.navigate(["/tabs/send"]);
|
||||
}
|
||||
|
||||
deleteSend = async () => {
|
||||
|
@ -4,7 +4,7 @@
|
||||
slot="header"
|
||||
[pageTitle]="'createdSend' | i18n"
|
||||
showBackButton
|
||||
[backAction]="close.bind(this)"
|
||||
[backAction]="goToEditSend.bind(this)"
|
||||
>
|
||||
<ng-container slot="end">
|
||||
<app-pop-out></app-pop-out>
|
||||
@ -27,7 +27,7 @@
|
||||
<button bitButton type="button" buttonType="primary" (click)="copyLink()">
|
||||
<b>{{ "copyLink" | i18n }}</b>
|
||||
</button>
|
||||
<button bitButton type="button" buttonType="secondary" (click)="close()">
|
||||
<button bitButton type="button" buttonType="secondary" (click)="goBack()">
|
||||
{{ "close" | i18n }}
|
||||
</button>
|
||||
</popup-footer>
|
||||
|
@ -11,6 +11,7 @@ import { EnvironmentService } from "@bitwarden/common/platform/abstractions/envi
|
||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.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 { SendService } from "@bitwarden/common/tools/send/services/send.service.abstraction";
|
||||
import { ButtonModule, I18nMockService, IconModule, ToastService } from "@bitwarden/components";
|
||||
@ -50,6 +51,7 @@ describe("SendCreatedComponent", () => {
|
||||
sendView = {
|
||||
id: sendId,
|
||||
deletionDate: new Date(),
|
||||
type: SendType.Text,
|
||||
accessId: "abc",
|
||||
urlB64Key: "123",
|
||||
} as SendView;
|
||||
@ -129,9 +131,11 @@ describe("SendCreatedComponent", () => {
|
||||
expect(component["hoursAvailable"]).toBe(0);
|
||||
});
|
||||
|
||||
it("should navigate back to send list on close", async () => {
|
||||
await component.close();
|
||||
expect(router.navigate).toHaveBeenCalledWith(["/tabs/send"]);
|
||||
it("should navigate back to the edit send form on close", async () => {
|
||||
await component.goToEditSend();
|
||||
expect(router.navigate).toHaveBeenCalledWith(["/edit-send"], {
|
||||
queryParams: { sendId: "test-send-id", type: SendType.Text },
|
||||
});
|
||||
});
|
||||
|
||||
describe("getHoursAvailable", () => {
|
||||
|
@ -77,7 +77,13 @@ export class SendCreatedComponent {
|
||||
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"]);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user