-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(space): add option to open an existing space from filesystem (#11)
- get rid of `@tauri-apps/plugin-dialog` node pkg and add `open_directory_dialog` invoke command
- Loading branch information
Showing
8 changed files
with
84 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"zaku": patch | ||
--- | ||
|
||
Add option to open existing space from filesystem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use serde::{Deserialize, Serialize}; | ||
use tauri::AppHandle; | ||
use tauri_plugin_dialog::DialogExt; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
pub struct OpenDirectoryDialogOptions { | ||
pub title: Option<String>, | ||
} | ||
|
||
#[tauri::command] | ||
pub async fn open_directory_dialog<R: tauri::Runtime>( | ||
options: Option<OpenDirectoryDialogOptions>, | ||
app_handle: AppHandle<R>, | ||
) -> Result<Option<String>, String> { | ||
let mut dialog_builder = app_handle.dialog().file(); | ||
|
||
match options { | ||
Some(OpenDirectoryDialogOptions { | ||
title: Some(ref title), | ||
}) => { | ||
dialog_builder = dialog_builder.set_title(title); | ||
} | ||
_ => {} | ||
} | ||
|
||
let directory_path = dialog_builder.blocking_pick_folder(); | ||
|
||
match directory_path { | ||
Some(path) => { | ||
return Ok(Some(path.to_string_lossy().to_string())); | ||
} | ||
None => { | ||
return Ok(None); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod dialog; | ||
pub mod space; | ||
pub mod window; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { invoke } from "@tauri-apps/api/core"; | ||
|
||
export type OpenDirectoryDialog = { | ||
title?: string; | ||
}; | ||
|
||
export async function openDirectoryDialog(options?: OpenDirectoryDialog) { | ||
const path: string | null = await invoke("open_directory_dialog", { options }); | ||
|
||
return path; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters