Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,9 @@ function AppContent() {
}, []);

const handleConnectionSelect = (connection: ConnectionNode) => {
setSelectedConnection(connection);
if (connection.type === 'connection') {
setSelectedConnection(connection);
}
};

const handleConnectionConnect = async (connection: ConnectionNode) => {
Expand Down Expand Up @@ -677,7 +679,7 @@ function AppContent() {
}, [state.groups, dispatch]);

const handleNewTab = useCallback((folderPath?: string) => {
setConnectionInitialFolder(folderPath);
setConnectionInitialFolder(typeof folderPath === 'string' ? folderPath : undefined);
setConnectionDialogOpen(true);
setEditingConnection(null);
}, []);
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/connection-dialog-folder.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { type ComponentProps } from 'react';
import { ConnectionDialog } from '../components/connection-dialog';

vi.mock('@tauri-apps/api/core', () => ({
Expand Down Expand Up @@ -62,7 +63,7 @@ function getFolderSelect() {
}

describe('ConnectionDialog folder pre-selection', () => {
function renderDialog(props: Partial<React.ComponentProps<typeof ConnectionDialog>> = {}) {
function renderDialog(props: Partial<ComponentProps<typeof ConnectionDialog>> = {}) {
return render(
<ConnectionDialog
open={true}
Expand Down
12 changes: 7 additions & 5 deletions src/components/connection-dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ export function ConnectionDialog({
const folderPaths = folders.map(f => f.path).sort();
setAvailableFolders(folderPaths);

// Pre-select folder when initialFolder is provided (new connection from folder context menu)
if (initialFolder && !editingConnection) {
setConnectionFolder(initialFolder);
}

// Load editing connection data into config when dialog opens
if (editingConnection) {
setConfig({
Expand All @@ -185,6 +180,13 @@ export function ConnectionDialog({
// Reset connection state when dialog closes
resetConnectionState();
}
}, [open, editingConnection]);

// Dedicated effect: pre-select folder when initialFolder is provided (new connection from folder context menu)
useEffect(() => {
if (open && !editingConnection && initialFolder) {
setConnectionFolder(initialFolder);
}
}, [open, editingConnection, initialFolder]);

const _handleSaveProfile = () => {
Expand Down
20 changes: 13 additions & 7 deletions src/components/connection-manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,8 @@ export function ConnectionManager({
variant="ghost"
size="sm"
className="p-0 h-4 w-4"
aria-label={node.isExpanded ? t('connectionManager.collapseFolder') : t('connectionManager.expandFolder')}
aria-expanded={node.isExpanded}
onClick={(e) => {
e.stopPropagation();
toggleExpanded(node.id);
Expand Down Expand Up @@ -754,13 +756,17 @@ export function ConnectionManager({
{nodeContent}
</ContextMenuTrigger>
<ContextMenuContent>
<ContextMenuItem
onClick={() => onNewConnection?.(node.path)}
>
<Plus className="w-4 h-4 mr-2" />
{t('connectionManager.newConnection')}
</ContextMenuItem>
<ContextMenuSeparator />
{onNewConnection && (
<>
<ContextMenuItem
onClick={() => onNewConnection(node.path)}
>
<Plus className="w-4 h-4 mr-2" />
{t('connectionManager.newConnection')}
</ContextMenuItem>
<ContextMenuSeparator />
</>
)}
<ContextMenuItem
onClick={() => openNewFolderDialog(node.path)}
>
Expand Down
4 changes: 3 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,9 @@
"connectionDetails": "Connection Details",
"noConnectionSelected": "No connection selected",
"movedToRoot": "Moved \"{{name}}\" to All Connections",
"failedToReorder": "Failed to reorder items"
"failedToReorder": "Failed to reorder items",
"expandFolder": "Expand folder",
"collapseFolder": "Collapse folder"
},
"filePanel": {
"selectDirectory": "Select a directory to view its contents",
Expand Down
4 changes: 3 additions & 1 deletion src/locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,9 @@
"connectionDetails": "连接详情",
"noConnectionSelected": "未选择连接",
"movedToRoot": "已将\"{{name}}\"移动到所有连接",
"failedToReorder": "重新排序失败"
"failedToReorder": "重新排序失败",
"expandFolder": "展开文件夹",
"collapseFolder": "折叠文件夹"
},
"filePanel": {
"selectDirectory": "选择目录以查看其内容",
Expand Down
Loading