Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): expose message dialog's title option, ref #4183 #4186

Merged
merged 1 commit into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/expose-message-dialog-title.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri": patch
"api": patch
---

Expose `title` option in the message dialog API.
2 changes: 1 addition & 1 deletion core/tauri/scripts/bundle.js

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions core/tauri/src/endpoints/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ pub enum Cmd {
#[cmd(dialog_save, "dialog > save")]
SaveDialog { options: SaveDialogOptions },
#[cmd(dialog_message, "dialog > message")]
MessageDialog { message: String },
MessageDialog {
title: Option<String>,
message: String,
},
#[cmd(dialog_ask, "dialog > ask")]
AskDialog {
title: Option<String>,
Expand Down Expand Up @@ -168,10 +171,14 @@ impl Cmd {
}

#[module_command_handler(dialog_message)]
fn message_dialog<R: Runtime>(context: InvokeContext<R>, message: String) -> super::Result<()> {
fn message_dialog<R: Runtime>(
context: InvokeContext<R>,
title: Option<String>,
message: String,
) -> super::Result<()> {
crate::api::dialog::blocking::message(
Some(&context.window),
&context.window.app_handle.package_info().name,
title.unwrap_or_else(|| context.window.app_handle.package_info().name.clone()),
message,
);
Ok(())
Expand Down
3 changes: 2 additions & 1 deletion tooling/api/src/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,12 @@ async function save(options: SaveDialogOptions = {}): Promise<string> {
*
* @return {Promise<void>} A promise indicating the success or failure of the operation.
*/
async function message(message: string): Promise<void> {
async function message(message: string, title?: string): Promise<void> {
return invokeTauriCommand({
__tauriModule: 'Dialog',
message: {
cmd: 'messageDialog',
title,
message
}
})
Expand Down