mirror of
https://github.com/bitwarden/browser.git
synced 2025-03-11 13:30:39 +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.
|
* 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 () => {
|
||||||
|
@ -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>
|
||||||
|
@ -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", () => {
|
||||||
|
@ -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"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user