Skip to content

Commit 942ee1a

Browse files
authored
feat: add select, file_path, and directory_path input types (#121)
Signed-off-by: Mohammod Al Amin Ashik <maa.ashik00@gmail.com>
1 parent b40c59b commit 942ee1a

10 files changed

Lines changed: 160 additions & 18 deletions

File tree

Cargo.lock

Lines changed: 78 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/desktop/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"dependencies": {
1919
"@monaco-editor/react": "^4.7.0",
2020
"@tauri-apps/api": "^2.10.1",
21+
"@tauri-apps/plugin-dialog": "^2",
2122
"@tauri-apps/plugin-opener": "^2",
2223
"@tauri-apps/plugin-process": "^2",
2324
"@tauri-apps/plugin-updater": "^2",

apps/desktop/src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ tauri-plugin-single-instance = { version = "2", features = ["deep-link"] }
2121
tauri-plugin-deep-link = "2"
2222
tauri-plugin-updater = "2"
2323
tauri-plugin-autostart = "2"
24+
tauri-plugin-dialog = "2"
2425
image = { version = "0.25", default-features = false, features = ["png"] }
2526
serde.workspace = true
2627
serde_json.workspace = true

apps/desktop/src-tauri/capabilities/default.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"core:window:allow-set-focus",
1717
"opener:default",
1818
"deep-link:default",
19-
"updater:default"
19+
"updater:default",
20+
"dialog:default"
2021
]
2122
}

apps/desktop/src-tauri/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ pub fn run() {
188188

189189
tauri::Builder::default()
190190
.plugin(tauri_plugin_opener::init())
191+
.plugin(tauri_plugin_dialog::init())
191192
.plugin(tauri_plugin_deep_link::init())
192193
.plugin(tauri_plugin_autostart::init(
193194
tauri_plugin_autostart::MacosLauncher::LaunchAgent,

apps/desktop/src/features/servers/ServersPage.tsx

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*/
99

1010
import { useEffect, useState, useCallback } from 'react';
11+
import { open } from '@tauri-apps/plugin-dialog';
1112
import {
1213
ChevronDown,
1314
ChevronRight,
@@ -17,6 +18,7 @@ import {
1718
Loader2,
1819
Clock,
1920
FileJson,
21+
FolderOpen,
2022
} from 'lucide-react';
2123
import { ServerActionMenu } from './ServerActionMenu';
2224
import type { ServerViewModel, ServerDefinition, InstalledServerState, InputDefinition } from '../../types/registry';
@@ -1338,16 +1340,67 @@ export function ServersPage() {
13381340
className="input w-full"
13391341
/>
13401342
);
1341-
case 'password':
1343+
case 'select':
13421344
return (
1343-
<input
1344-
type="password"
1345+
<select
13451346
value={currentValue}
13461347
onChange={(e) => handleChange(e.target.value)}
1347-
placeholder={input.placeholder || `Enter ${input.label.toLowerCase()}...`}
13481348
className="input w-full"
13491349
data-testid={`config-input-${input.id}`}
1350-
/>
1350+
>
1351+
<option value="">{input.placeholder || `Select ${input.label.toLowerCase()}...`}</option>
1352+
{(input.options ?? []).map((opt) => (
1353+
<option key={opt.value} value={opt.value}>
1354+
{opt.label}
1355+
</option>
1356+
))}
1357+
</select>
1358+
);
1359+
case 'file_path':
1360+
return (
1361+
<div className="flex gap-2">
1362+
<input
1363+
type="text"
1364+
value={currentValue}
1365+
onChange={(e) => handleChange(e.target.value)}
1366+
placeholder={input.placeholder || 'Select a file...'}
1367+
className="input w-full"
1368+
data-testid={`config-input-${input.id}`}
1369+
/>
1370+
<button
1371+
type="button"
1372+
className="btn btn-secondary shrink-0 px-2"
1373+
onClick={async () => {
1374+
const selected = await open({ multiple: false });
1375+
if (selected) handleChange(selected);
1376+
}}
1377+
>
1378+
<FolderOpen className="w-4 h-4" />
1379+
</button>
1380+
</div>
1381+
);
1382+
case 'directory_path':
1383+
return (
1384+
<div className="flex gap-2">
1385+
<input
1386+
type="text"
1387+
value={currentValue}
1388+
onChange={(e) => handleChange(e.target.value)}
1389+
placeholder={input.placeholder || 'Select a directory...'}
1390+
className="input w-full"
1391+
data-testid={`config-input-${input.id}`}
1392+
/>
1393+
<button
1394+
type="button"
1395+
className="btn btn-secondary shrink-0 px-2"
1396+
onClick={async () => {
1397+
const selected = await open({ directory: true });
1398+
if (selected) handleChange(selected);
1399+
}}
1400+
>
1401+
<FolderOpen className="w-4 h-4" />
1402+
</button>
1403+
</div>
13511404
);
13521405
case 'text':
13531406
default:

apps/desktop/src/types/registry.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ export interface InputDefinition {
88
label: string;
99
description?: string;
1010
/** Input type - determines how the field is rendered */
11-
type?: 'text' | 'password' | 'boolean' | 'number' | 'url';
11+
type?: 'text' | 'boolean' | 'number' | 'url' | 'select' | 'file_path' | 'directory_path';
1212
required?: boolean;
13+
/** Predefined options for select input type */
14+
options?: { value: string; label: string; description?: string }[];
1315
secret?: boolean;
1416
placeholder?: string;
1517
/** URL to obtain credentials/values */

crates/mcpmux-gateway/src/pool/transport/shell_env.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
1212
use std::ffi::OsString;
1313
use std::sync::OnceLock;
14+
#[cfg(unix)]
1415
use tracing::{debug, info, warn};
1516

1617
/// Cached shell PATH, resolved once on first access.

pnpm-lock.yaml

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/ts/setup.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ vi.mock('@tauri-apps/plugin-updater', () => ({
2424
Update: vi.fn(),
2525
}));
2626

27+
// Mock Tauri dialog plugin
28+
vi.mock('@tauri-apps/plugin-dialog', () => ({
29+
open: vi.fn(),
30+
}));
31+
2732
// Mock Tauri process plugin
2833
vi.mock('@tauri-apps/plugin-process', () => ({
2934
relaunch: vi.fn(),

0 commit comments

Comments
 (0)