mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 05:43:41 +00:00
[PM-11926] - send created redirect (#11140)
* send created redirect * fix test * fix test * fix send form save * return SendData from saveSend * When saving a Send, bubble up a SendView which can be passed to the SendCreated component * Use events to initiate navigation and move actual navigation into client-specific component --------- Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
@@ -85,9 +85,14 @@ export class SendFormComponent implements AfterViewInit, OnInit, OnChanges, Send
|
||||
submitBtn?: ButtonComponent;
|
||||
|
||||
/**
|
||||
* Event emitted when the send is saved successfully.
|
||||
* Event emitted when the send is created successfully.
|
||||
*/
|
||||
@Output() sendSaved = new EventEmitter<SendView>();
|
||||
@Output() onSendCreated = new EventEmitter<SendView>();
|
||||
|
||||
/**
|
||||
* Event emitted when the send is updated successfully.
|
||||
*/
|
||||
@Output() onSendUpdated = new EventEmitter<SendView>();
|
||||
|
||||
/**
|
||||
* The original send being edited or cloned. Null for add mode.
|
||||
@@ -200,22 +205,26 @@ export class SendFormComponent implements AfterViewInit, OnInit, OnChanges, Send
|
||||
return;
|
||||
}
|
||||
|
||||
const sendView = await this.addEditFormService.saveSend(
|
||||
this.updatedSendView,
|
||||
this.file,
|
||||
this.config,
|
||||
);
|
||||
|
||||
if (this.config.mode === "add") {
|
||||
this.onSendCreated.emit(sendView);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Utils.isNullOrWhitespace(this.updatedSendView.password)) {
|
||||
this.updatedSendView.password = null;
|
||||
}
|
||||
|
||||
await this.addEditFormService.saveSend(this.updatedSendView, this.file, this.config);
|
||||
|
||||
this.toastService.showToast({
|
||||
variant: "success",
|
||||
title: null,
|
||||
message: this.i18nService.t(
|
||||
this.config.mode === "edit" || this.config.mode === "partial-edit"
|
||||
? "editedItem"
|
||||
: "addedItem",
|
||||
),
|
||||
message: this.i18nService.t("editedItem"),
|
||||
});
|
||||
|
||||
this.sendSaved.emit(this.updatedSendView);
|
||||
this.onSendUpdated.emit(this.updatedSendView);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ export class DefaultSendFormService implements SendFormService {
|
||||
|
||||
async saveSend(send: SendView, file: File | ArrayBuffer, config: SendFormConfig) {
|
||||
const sendData = await this.sendService.encrypt(send, file, send.password, null);
|
||||
return await this.sendApiService.save(sendData);
|
||||
const newSend = await this.sendApiService.save(sendData);
|
||||
return await this.decryptSend(newSend);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user