mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-01 23:01:28 +01:00
send created redirect
This commit is contained in:
parent
a151f40e3b
commit
36711d54a3
@ -89,8 +89,10 @@ export class SendAddEditComponent {
|
|||||||
* Handles the event when the send is saved.
|
* Handles the event when the send is saved.
|
||||||
*/
|
*/
|
||||||
onSendSaved() {
|
onSendSaved() {
|
||||||
|
if (this.config.mode !== "add") {
|
||||||
this.location.back();
|
this.location.back();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subscribes to the route query parameters and builds the configuration based on the parameters.
|
* Subscribes to the route query parameters and builds the configuration based on the parameters.
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<main class="tw-top-0">
|
<main class="tw-top-0">
|
||||||
<popup-page>
|
<popup-page>
|
||||||
<popup-header slot="header" [pageTitle]="'createdSend' | i18n" showBackButton>
|
<popup-header
|
||||||
|
slot="header"
|
||||||
|
[pageTitle]="'createdSend' | i18n"
|
||||||
|
showBackButton
|
||||||
|
[backAction]="close.bind(this)"
|
||||||
|
>
|
||||||
<ng-container slot="end">
|
<ng-container slot="end">
|
||||||
<app-pop-out></app-pop-out>
|
<app-pop-out></app-pop-out>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { CommonModule, Location } from "@angular/common";
|
import { CommonModule } from "@angular/common";
|
||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||||
import { ActivatedRoute, RouterLink } from "@angular/router";
|
import { ActivatedRoute, Router, RouterLink, RouterModule } from "@angular/router";
|
||||||
import { firstValueFrom } from "rxjs";
|
import { firstValueFrom } from "rxjs";
|
||||||
|
|
||||||
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
import { JslibModule } from "@bitwarden/angular/jslib.module";
|
||||||
@ -30,6 +30,7 @@ import { PopupPageComponent } from "../../../../platform/popup/layout/popup-page
|
|||||||
PopupHeaderComponent,
|
PopupHeaderComponent,
|
||||||
PopupPageComponent,
|
PopupPageComponent,
|
||||||
RouterLink,
|
RouterLink,
|
||||||
|
RouterModule,
|
||||||
PopupFooterComponent,
|
PopupFooterComponent,
|
||||||
IconModule,
|
IconModule,
|
||||||
],
|
],
|
||||||
@ -45,10 +46,11 @@ export class SendCreatedComponent {
|
|||||||
private sendService: SendService,
|
private sendService: SendService,
|
||||||
private route: ActivatedRoute,
|
private route: ActivatedRoute,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private location: Location,
|
private router: Router,
|
||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
) {
|
) {
|
||||||
const sendId = this.route.snapshot.queryParamMap.get("sendId");
|
const sendId = this.route.snapshot.queryParamMap.get("sendId");
|
||||||
|
|
||||||
this.sendService.sendViews$.pipe(takeUntilDestroyed()).subscribe((sendViews) => {
|
this.sendService.sendViews$.pipe(takeUntilDestroyed()).subscribe((sendViews) => {
|
||||||
this.send = sendViews.find((s) => s.id === sendId);
|
this.send = sendViews.find((s) => s.id === sendId);
|
||||||
if (this.send) {
|
if (this.send) {
|
||||||
@ -62,8 +64,8 @@ export class SendCreatedComponent {
|
|||||||
return Math.max(0, Math.ceil((send.deletionDate.getTime() - now) / (1000 * 60 * 60 * 24)));
|
return Math.max(0, Math.ceil((send.deletionDate.getTime() - now) / (1000 * 60 * 60 * 24)));
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
async close() {
|
||||||
this.location.back();
|
await this.router.navigate(["/tabs/send"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async copyLink() {
|
async copyLink() {
|
||||||
|
@ -135,11 +135,12 @@ export class SendApiService implements SendApiServiceAbstraction {
|
|||||||
return this.apiService.send("DELETE", "/sends/" + id, null, true, false);
|
return this.apiService.send("DELETE", "/sends/" + id, null, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
async save(sendData: [Send, EncArrayBuffer]): Promise<any> {
|
async save(sendData: [Send, EncArrayBuffer]): Promise<SendData> {
|
||||||
const response = await this.upload(sendData);
|
const response = await this.upload(sendData);
|
||||||
|
|
||||||
const data = new SendData(response);
|
const data = new SendData(response);
|
||||||
await this.sendService.upsert(data);
|
await this.sendService.upsert(data);
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(id: string): Promise<any> {
|
async delete(id: string): Promise<any> {
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
} from "@angular/core";
|
} from "@angular/core";
|
||||||
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
||||||
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
import { FormBuilder, ReactiveFormsModule } from "@angular/forms";
|
||||||
|
import { Router } from "@angular/router";
|
||||||
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
import { SendType } from "@bitwarden/common/tools/send/enums/send-type";
|
||||||
@ -186,6 +187,7 @@ export class SendFormComponent implements AfterViewInit, OnInit, OnChanges, Send
|
|||||||
private addEditFormService: SendFormService,
|
private addEditFormService: SendFormService,
|
||||||
private toastService: ToastService,
|
private toastService: ToastService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
|
private router: Router,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
submit = async () => {
|
submit = async () => {
|
||||||
@ -195,18 +197,24 @@ export class SendFormComponent implements AfterViewInit, OnInit, OnChanges, Send
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add file handling
|
// TODO: Add file handling
|
||||||
await this.addEditFormService.saveSend(this.updatedSendView, null, this.config);
|
const sendView = await this.addEditFormService.saveSend(
|
||||||
|
this.updatedSendView,
|
||||||
|
null,
|
||||||
|
this.config,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.config.mode === "add") {
|
||||||
|
await this.router.navigate(["/send-created"], {
|
||||||
|
queryParams: { sendId: sendView.id },
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.toastService.showToast({
|
this.toastService.showToast({
|
||||||
variant: "success",
|
variant: "success",
|
||||||
title: null,
|
title: null,
|
||||||
message: this.i18nService.t(
|
message: this.i18nService.t("editedItem"),
|
||||||
this.config.mode === "edit" || this.config.mode === "partial-edit"
|
|
||||||
? "editedItem"
|
|
||||||
: "addedItem",
|
|
||||||
),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
this.sendSaved.emit(this.updatedSendView);
|
this.sendSaved.emit(this.updatedSendView);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user