aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@atuin.sh>2024-07-26 12:51:15 +0100
committerGitHub <noreply@github.com>2024-07-26 12:51:15 +0100
commita34efd6c6bb6199da59b096196a97495b32d0c1f (patch)
treeaf61addce7342c974e1b00486a7330bd5a8fa3b8 /ui
parentfeat(gui): directory block, re-org of some code (#2314) (diff)
downloadatuin-a34efd6c6bb6199da59b096196a97495b32d0c1f.zip
feat(gui): folder select dialogue for directory block (#2315)
Diffstat (limited to 'ui')
-rw-r--r--ui/backend/Cargo.lock74
-rw-r--r--ui/backend/Cargo.toml1
-rw-r--r--ui/backend/capabilities/migrated.json19
-rw-r--r--ui/backend/src/main.rs1
-rw-r--r--ui/backend/src/run/pty.rs4
-rw-r--r--ui/package.json1
-rw-r--r--ui/pnpm-lock.yaml9
-rw-r--r--ui/src/components/runbooks/editor/blocks/Directory/index.tsx56
8 files changed, 142 insertions, 23 deletions
diff --git a/ui/backend/Cargo.lock b/ui/backend/Cargo.lock
index 11659c11..4c7ad8fe 100644
--- a/ui/backend/Cargo.lock
+++ b/ui/backend/Cargo.lock
@@ -168,6 +168,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711"
[[package]]
+name = "ashpd"
+version = "0.8.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dd884d7c72877a94102c3715f3b1cd09ff4fac28221add3e57cfbe25c236d093"
+dependencies = [
+ "enumflags2",
+ "futures-channel",
+ "futures-util",
+ "rand 0.8.5",
+ "serde",
+ "serde_repr",
+ "tokio",
+ "url",
+ "zbus",
+]
+
+[[package]]
name = "async-broadcast"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -3349,6 +3366,17 @@ dependencies = [
]
[[package]]
+name = "objc-foundation"
+version = "0.1.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1add1b659e36c9607c7aab864a76c7a4c2760cd0cd2e120f3fb8b952c7e22bf9"
+dependencies = [
+ "block",
+ "objc",
+ "objc_id",
+]
+
+[[package]]
name = "objc-sys"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -4412,6 +4440,30 @@ dependencies = [
]
[[package]]
+name = "rfd"
+version = "0.14.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "25a73a7337fc24366edfca76ec521f51877b114e42dab584008209cca6719251"
+dependencies = [
+ "ashpd",
+ "block",
+ "dispatch",
+ "glib-sys",
+ "gobject-sys",
+ "gtk-sys",
+ "js-sys",
+ "log",
+ "objc",
+ "objc-foundation",
+ "objc_id",
+ "raw-window-handle 0.6.2",
+ "wasm-bindgen",
+ "wasm-bindgen-futures",
+ "web-sys",
+ "windows-sys 0.48.0",
+]
+
+[[package]]
name = "ring"
version = "0.17.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5813,6 +5865,24 @@ dependencies = [
]
[[package]]
+name = "tauri-plugin-dialog"
+version = "2.0.0-beta.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8860dd73c96969eb14813f9f04d8665f2853342670456fb6619d637137ef0d09"
+dependencies = [
+ "dunce",
+ "log",
+ "raw-window-handle 0.6.2",
+ "rfd",
+ "serde",
+ "serde_json",
+ "tauri",
+ "tauri-plugin",
+ "tauri-plugin-fs",
+ "thiserror",
+]
+
+[[package]]
name = "tauri-plugin-fs"
version = "2.0.0-beta.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -6174,6 +6244,7 @@ dependencies = [
"signal-hook-registry",
"socket2",
"tokio-macros",
+ "tracing",
"windows-sys 0.52.0",
]
@@ -6487,6 +6558,7 @@ dependencies = [
"syntect",
"tauri",
"tauri-build",
+ "tauri-plugin-dialog",
"tauri-plugin-http",
"tauri-plugin-os",
"tauri-plugin-shell",
@@ -7457,6 +7529,7 @@ dependencies = [
"serde_repr",
"sha1",
"static_assertions",
+ "tokio",
"tracing",
"uds_windows",
"windows-sys 0.52.0",
@@ -7541,6 +7614,7 @@ dependencies = [
"enumflags2",
"serde",
"static_assertions",
+ "url",
"zvariant_derive",
]
diff --git a/ui/backend/Cargo.toml b/ui/backend/Cargo.toml
index 96a9b1c6..4477674e 100644
--- a/ui/backend/Cargo.toml
+++ b/ui/backend/Cargo.toml
@@ -37,6 +37,7 @@ tauri-plugin-http = "2.0.0-beta"
tauri-plugin-single-instance = "2.0.0-beta"
tauri-plugin-os = "2.0.0-beta.8"
tauri-plugin-shell = "2.0.0-beta.7"
+tauri-plugin-dialog = "2.0.0-beta.11"
[target."cfg(target_os = \"macos\")".dependencies]
cocoa = "0.25"
diff --git a/ui/backend/capabilities/migrated.json b/ui/backend/capabilities/migrated.json
index 60a713da..88d809ca 100644
--- a/ui/backend/capabilities/migrated.json
+++ b/ui/backend/capabilities/migrated.json
@@ -2,7 +2,9 @@
"identifier": "migrated",
"description": "permissions that were migrated from v1",
"context": "local",
- "windows": ["main"],
+ "windows": [
+ "main"
+ ],
"permissions": [
"path:default",
"event:default",
@@ -19,9 +21,16 @@
"window:allow-start-dragging",
{
"identifier": "http:default",
- "allow": ["https://api.atuin.sh/*"]
+ "allow": [
+ "https://api.atuin.sh/*"
+ ]
},
- "os:default"
+ "os:default",
+ "dialog:default"
],
- "platforms": ["linux", "macOS", "windows"]
-}
+ "platforms": [
+ "linux",
+ "macOS",
+ "windows"
+ ]
+} \ No newline at end of file
diff --git a/ui/backend/src/main.rs b/ui/backend/src/main.rs
index c8a88136..eed6bfd3 100644
--- a/ui/backend/src/main.rs
+++ b/ui/backend/src/main.rs
@@ -282,6 +282,7 @@ fn show_window(app: &AppHandle) {
fn main() {
tauri::Builder::default()
+ .plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_os::init())
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![
diff --git a/ui/backend/src/run/pty.rs b/ui/backend/src/run/pty.rs
index 0ca5ece0..72ca98d2 100644
--- a/ui/backend/src/run/pty.rs
+++ b/ui/backend/src/run/pty.rs
@@ -3,7 +3,7 @@ use std::io::BufRead;
use std::path::PathBuf;
use crate::state::AtuinState;
-use tauri::{Manager, State, Emitter};
+use tauri::{Emitter, Manager, State};
use atuin_client::{database::Sqlite, record::sqlite_store::SqliteStore, settings::Settings};
@@ -15,7 +15,7 @@ pub async fn pty_open<'a>(
) -> Result<uuid::Uuid, String> {
let id = uuid::Uuid::new_v4();
- let cwd = cwd.map(|c|shellexpand::tilde(c.as_str()).to_string());
+ let cwd = cwd.map(|c| shellexpand::tilde(c.as_str()).to_string());
let pty = crate::pty::Pty::open(24, 80, cwd).await.unwrap();
let reader = pty.reader.clone();
diff --git a/ui/package.json b/ui/package.json
index 3d79634e..afdffb04 100644
--- a/ui/package.json
+++ b/ui/package.json
@@ -31,6 +31,7 @@
"@tanstack/react-table": "^8.19.3",
"@tanstack/react-virtual": "^3.8.3",
"@tauri-apps/api": "2.0.0-beta.15",
+ "@tauri-apps/plugin-dialog": "2.0.0-beta.7",
"@tauri-apps/plugin-http": "2.0.0-beta.8",
"@tauri-apps/plugin-os": "2.0.0-beta.7",
"@tauri-apps/plugin-shell": "2.0.0-beta.8",
diff --git a/ui/pnpm-lock.yaml b/ui/pnpm-lock.yaml
index d9e71a6a..4f2101ef 100644
--- a/ui/pnpm-lock.yaml
+++ b/ui/pnpm-lock.yaml
@@ -68,6 +68,9 @@ dependencies:
'@tauri-apps/api':
specifier: 2.0.0-beta.15
version: 2.0.0-beta.15
+ '@tauri-apps/plugin-dialog':
+ specifier: 2.0.0-beta.7
+ version: 2.0.0-beta.7
'@tauri-apps/plugin-http':
specifier: 2.0.0-beta.8
version: 2.0.0-beta.8
@@ -5145,6 +5148,12 @@ packages:
'@tauri-apps/cli-win32-x64-msvc': 2.0.0-beta.22
dev: true
+ /@tauri-apps/plugin-dialog@2.0.0-beta.7:
+ resolution: {integrity: sha512-myywwpsKbquDDzl5zaOmmLLv5O8EJ/GgHDAoVSPwO97R4iWzkDvj3HFF91tNh7i25Tu/bP6jYPAdZA1NCRxxtg==}
+ dependencies:
+ '@tauri-apps/api': 2.0.0-beta.15
+ dev: false
+
/@tauri-apps/plugin-http@2.0.0-beta.8:
resolution: {integrity: sha512-FhZP4WtS1o69Mn7z2RpNIdVS+2nPqmXyz6LhqweuP1FTjgTVraVxIfGLQCOMLpEUwo8zWY2uChllolV6WGYZ/A==}
dependencies:
diff --git a/ui/src/components/runbooks/editor/blocks/Directory/index.tsx b/ui/src/components/runbooks/editor/blocks/Directory/index.tsx
index 38e974ff..a1eccd92 100644
--- a/ui/src/components/runbooks/editor/blocks/Directory/index.tsx
+++ b/ui/src/components/runbooks/editor/blocks/Directory/index.tsx
@@ -1,10 +1,12 @@
import { useState } from "react";
-import { Input, Tooltip } from "@nextui-org/react";
+import { Input, Tooltip, Button } from "@nextui-org/react";
import { FolderInputIcon, HelpCircleIcon } from "lucide-react";
// @ts-ignore
import { createReactBlockSpec } from "@blocknote/react";
+import { open } from "@tauri-apps/plugin-dialog";
+
interface DirectoryProps {
path: string;
onInputChange: (string) => void;
@@ -13,27 +15,49 @@ interface DirectoryProps {
const Directory = ({ path, onInputChange }: DirectoryProps) => {
const [value, setValue] = useState(path);
+ const selectFolder = async () => {
+ const path = await open({
+ multiple: false,
+ directory: true,
+ });
+
+ setValue(path);
+ onInputChange(path);
+ };
+
return (
<div className="w-full !max-w-full !outline-none overflow-none">
<Tooltip
content="Change working directory for all subsequent code blocks"
delay={1000}
>
- <Input
- label="Directory"
- placeholder="~"
- labelPlacement="outside"
- value={value}
- autoComplete="off"
- autoCapitalize="off"
- autoCorrect="off"
- spellCheck="false"
- onValueChange={(val) => {
- setValue(val);
- onInputChange(val);
- }}
- startContent={<FolderInputIcon />}
- />
+ <div className="flex flex-row">
+ <div className="mr-2">
+ <Button
+ isIconOnly
+ variant="flat"
+ aria-label="Select folder"
+ onPress={selectFolder}
+ >
+ <FolderInputIcon />
+ </Button>
+ </div>
+
+ <div className="w-full">
+ <Input
+ placeholder="~"
+ value={value}
+ autoComplete="off"
+ autoCapitalize="off"
+ autoCorrect="off"
+ spellCheck="false"
+ onValueChange={(val) => {
+ setValue(val);
+ onInputChange(val);
+ }}
+ />
+ </div>
+ </div>
</Tooltip>
</div>
);