From cd2c18b77c45143ecdec3d84c9dbc451fcffe53d Mon Sep 17 00:00:00 2001 From: Rice <1840169763@qq.com> Date: Wed, 28 Jan 2026 11:13:17 +0800 Subject: [PATCH] feat: add tree view mode for host list with sorting and persistence - Add tree view mode alongside existing grid and list views - Implement hierarchical display of hosts organized by groups - Add expand/collapse all controls with Chinese translations - Support all sorting modes (A-Z, Z-A, newest, oldest) in tree view - Persist expand/collapse state across view switches and app restarts - Hide Groups section in tree view to avoid duplication - Display ungrouped hosts at root level instead of "General" group - Add missing delete group dialog with proper translations - Maintain full functionality: search, filtering, drag-drop, context menus Technical changes: - Create HostTreeView component with TreeNode recursive structure - Add useTreeExpandedState hook for persistent state management - Extend ViewMode type to include "tree" option - Add sortMode prop to enable dynamic sorting in tree structure - Separate group tree logic for tree view vs other view modes - Add comprehensive English and Chinese translations --- application/i18n/locales/en.ts | 5 + application/i18n/locales/zh-CN.ts | 5 + application/state/useStoredViewMode.ts | 4 +- application/state/useTreeExpandedState.ts | 47 ++ components/HostTreeView.tsx | 467 ++++++++++++++++++++ components/VaultView.tsx | 507 +++++++++++++++------- infrastructure/config/storageKeys.ts | 1 + package-lock.json | 32 +- 8 files changed, 885 insertions(+), 183 deletions(-) create mode 100644 application/state/useTreeExpandedState.ts create mode 100644 components/HostTreeView.tsx diff --git a/application/i18n/locales/en.ts b/application/i18n/locales/en.ts index f25a5d8ba..efdf304c5 100644 --- a/application/i18n/locales/en.ts +++ b/application/i18n/locales/en.ts @@ -313,6 +313,8 @@ const en: Messages = { 'vault.groups.createDialog.desc': 'Create a new group for organizing hosts.', 'vault.groups.renameDialogTitle': 'Rename Group', 'vault.groups.renameDialog.desc': 'Rename an existing group.', + 'vault.groups.deleteDialogTitle': 'Delete Group', + 'vault.groups.deleteDialog.desc': 'This will permanently delete the group and move all hosts to the root level.', 'vault.groups.field.name': 'Group Name', 'vault.groups.placeholder.example': 'e.g. Production', 'vault.groups.parentLabel': 'Parent', @@ -328,6 +330,9 @@ const en: Messages = { 'vault.hosts.connect': 'Connect', 'vault.view.grid': 'Grid', 'vault.view.list': 'List', + 'vault.view.tree': 'Tree', + 'vault.tree.expandAll': 'Expand All', + 'vault.tree.collapseAll': 'Collapse All', 'vault.hosts.newHost': 'New Host', 'vault.hosts.newGroup': 'New Group', 'vault.hosts.import': 'Import', diff --git a/application/i18n/locales/zh-CN.ts b/application/i18n/locales/zh-CN.ts index d6355b035..521281d2b 100644 --- a/application/i18n/locales/zh-CN.ts +++ b/application/i18n/locales/zh-CN.ts @@ -184,6 +184,8 @@ const zhCN: Messages = { 'vault.groups.createDialog.desc': '创建新的分组用于组织主机。', 'vault.groups.renameDialogTitle': '重命名分组', 'vault.groups.renameDialog.desc': '重命名已有分组。', + 'vault.groups.deleteDialogTitle': '删除分组', + 'vault.groups.deleteDialog.desc': '这将永久删除该分组并将所有主机移动到根级别。', 'vault.groups.field.name': '分组名称', 'vault.groups.placeholder.example': '例如:Production', 'vault.groups.parentLabel': '父级', @@ -199,6 +201,9 @@ const zhCN: Messages = { 'vault.hosts.connect': '连接', 'vault.view.grid': '网格', 'vault.view.list': '列表', + 'vault.view.tree': '树形', + 'vault.tree.expandAll': '展开全部', + 'vault.tree.collapseAll': '折叠全部', 'vault.hosts.newHost': '新建主机', 'vault.hosts.newGroup': '新建分组', 'vault.hosts.import': '导入', diff --git a/application/state/useStoredViewMode.ts b/application/state/useStoredViewMode.ts index 60304fc2b..a0c488431 100644 --- a/application/state/useStoredViewMode.ts +++ b/application/state/useStoredViewMode.ts @@ -1,10 +1,10 @@ import { useEffect, useState } from "react"; import { localStorageAdapter } from "../../infrastructure/persistence/localStorageAdapter"; -export type ViewMode = "grid" | "list"; +export type ViewMode = "grid" | "list" | "tree"; const isViewMode = (value: string | null): value is ViewMode => - value === "grid" || value === "list"; + value === "grid" || value === "list" || value === "tree"; export const useStoredViewMode = ( storageKey: string, diff --git a/application/state/useTreeExpandedState.ts b/application/state/useTreeExpandedState.ts new file mode 100644 index 000000000..408cec9ec --- /dev/null +++ b/application/state/useTreeExpandedState.ts @@ -0,0 +1,47 @@ +import { useEffect, useState } from "react"; +import { localStorageAdapter } from "../../infrastructure/persistence/localStorageAdapter"; + +export const useTreeExpandedState = (storageKey: string) => { + const [expandedPaths, setExpandedPaths] = useState>(() => { + const stored = localStorageAdapter.readString(storageKey); + if (stored) { + try { + const paths = JSON.parse(stored) as string[]; + return new Set(paths); + } catch { + return new Set(); + } + } + return new Set(); + }); + + useEffect(() => { + const pathsArray = Array.from(expandedPaths); + localStorageAdapter.writeString(storageKey, JSON.stringify(pathsArray)); + }, [storageKey, expandedPaths]); + + const togglePath = (path: string) => { + const newExpanded = new Set(expandedPaths); + if (newExpanded.has(path)) { + newExpanded.delete(path); + } else { + newExpanded.add(path); + } + setExpandedPaths(newExpanded); + }; + + const expandAll = (allPaths: string[]) => { + setExpandedPaths(new Set(allPaths)); + }; + + const collapseAll = () => { + setExpandedPaths(new Set()); + }; + + return { + expandedPaths, + togglePath, + expandAll, + collapseAll, + }; +}; \ No newline at end of file diff --git a/components/HostTreeView.tsx b/components/HostTreeView.tsx new file mode 100644 index 000000000..b557c2c71 --- /dev/null +++ b/components/HostTreeView.tsx @@ -0,0 +1,467 @@ +import { ChevronRight, Folder, FolderOpen, Monitor, Server, Expand, Minimize2 } from 'lucide-react'; +import React, { useMemo } from 'react'; +import { useI18n } from '../application/i18n/I18nProvider'; +import { useTreeExpandedState } from '../application/state/useTreeExpandedState'; +import { STORAGE_KEY_VAULT_HOSTS_TREE_EXPANDED } from '../infrastructure/config/storageKeys'; +import { cn } from '../lib/utils'; +import { GroupNode, Host } from '../types'; +import { Collapsible, CollapsibleContent, CollapsibleTrigger } from './ui/collapsible'; +import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuTrigger } from './ui/context-menu'; +import { DistroAvatar } from './DistroAvatar'; +import { Button } from './ui/button'; + +interface HostTreeViewProps { + groupTree: GroupNode[]; + hosts: Host[]; + sortMode?: 'az' | 'za' | 'newest' | 'oldest'; + expandedPaths?: Set; + onTogglePath?: (path: string) => void; + onExpandAll?: (paths: string[]) => void; + onCollapseAll?: () => void; + onConnect: (host: Host) => void; + onEditHost: (host: Host) => void; + onDuplicateHost: (host: Host) => void; + onDeleteHost: (host: Host) => void; + onCopyCredentials: (host: Host) => void; + onNewHost: (groupPath?: string) => void; + onNewGroup: (parentPath?: string) => void; + onEditGroup: (groupPath: string) => void; + onDeleteGroup: (groupPath: string) => void; + moveHostToGroup: (hostId: string, groupPath: string | null) => void; + moveGroup: (sourcePath: string, targetPath: string) => void; +} + +interface TreeNodeProps { + node: GroupNode; + depth: number; + sortMode: 'az' | 'za' | 'newest' | 'oldest'; + expandedPaths: Set; + onToggle: (path: string) => void; + onConnect: (host: Host) => void; + onEditHost: (host: Host) => void; + onDuplicateHost: (host: Host) => void; + onDeleteHost: (host: Host) => void; + onCopyCredentials: (host: Host) => void; + onNewHost: (groupPath?: string) => void; + onNewGroup: (parentPath?: string) => void; + onEditGroup: (groupPath: string) => void; + onDeleteGroup: (groupPath: string) => void; + moveHostToGroup: (hostId: string, groupPath: string | null) => void; + moveGroup: (sourcePath: string, targetPath: string) => void; +} + +const TreeNode: React.FC = ({ + node, + depth, + sortMode, + expandedPaths, + onToggle, + onConnect, + onEditHost, + onDuplicateHost, + onDeleteHost, + onCopyCredentials, + onNewHost, + onNewGroup, + onEditGroup, + onDeleteGroup, + moveHostToGroup, + moveGroup, +}) => { + const { t } = useI18n(); + const isExpanded = expandedPaths.has(node.path); + const hasChildren = node.children && Object.keys(node.children).length > 0; + const paddingLeft = `${depth * 20 + 12}px`; + + const childNodes = useMemo(() => { + if (!node.children) return []; + const nodes = Object.values(node.children) as unknown as GroupNode[]; + return nodes.sort((a, b) => { + switch (sortMode) { + case 'za': + return b.name.localeCompare(a.name); + case 'newest': + case 'oldest': + // For groups, fall back to name sorting since groups don't have creation dates + return a.name.localeCompare(b.name); + case 'az': + default: + return a.name.localeCompare(b.name); + } + }); + }, [node.children, sortMode]); + + const sortedHosts = useMemo(() => { + return [...node.hosts].sort((a, b) => { + switch (sortMode) { + case 'az': + return a.label.localeCompare(b.label); + case 'za': + return b.label.localeCompare(a.label); + case 'newest': + return (b.createdAt || 0) - (a.createdAt || 0); + case 'oldest': + return (a.createdAt || 0) - (b.createdAt || 0); + default: + return a.label.localeCompare(b.label); + } + }); + }, [node.hosts, sortMode]); + + return ( +
+ {/* Group Node */} + onToggle(node.path)}> + + + +
e.dataTransfer.setData("group-path", node.path)} + onDragOver={(e) => { + e.preventDefault(); + e.stopPropagation(); + }} + onDrop={(e) => { + e.preventDefault(); + e.stopPropagation(); + const hostId = e.dataTransfer.getData("host-id"); + const groupPath = e.dataTransfer.getData("group-path"); + if (hostId) moveHostToGroup(hostId, node.path); + if (groupPath) moveGroup(groupPath, node.path); + }} + > +
+ {(hasChildren || node.hosts.length > 0) && ( +
+ +
+ )} +
+
+ {isExpanded ? : } +
+ {node.name} + {(node.hosts.length > 0 || hasChildren) && ( + + {node.hosts.length} + + )} +
+
+
+ + onNewHost(node.path)}> + {t("vault.hosts.newHost")} + + onNewGroup(node.path)}> + {t("vault.hosts.newGroup")} + + onEditGroup(node.path)}> + {t("vault.groups.rename")} + + onDeleteGroup(node.path)} + className="text-destructive focus:text-destructive" + > + {t("vault.groups.delete")} + + +
+ + + {/* Child Groups */} + {childNodes.map((child) => ( + + ))} + + {/* Hosts in this group */} + {sortedHosts.map((host) => ( + + ))} + +
+
+ ); +}; + +interface HostTreeItemProps { + host: Host; + depth: number; + onConnect: (host: Host) => void; + onEditHost: (host: Host) => void; + onDuplicateHost: (host: Host) => void; + onDeleteHost: (host: Host) => void; + onCopyCredentials: (host: Host) => void; + moveHostToGroup: (hostId: string, groupPath: string | null) => void; +} + +const HostTreeItem: React.FC = ({ + host, + depth, + onConnect, + onEditHost, + onDuplicateHost, + onDeleteHost, + onCopyCredentials, + moveHostToGroup, +}) => { + const { t } = useI18n(); + const paddingLeft = `${depth * 20 + 12}px`; + + return ( + + +
e.dataTransfer.setData("host-id", host.id)} + onDoubleClick={() => onConnect(host)} + > +
+
+ +
+
+
{host.label}
+
+ {host.username}@{host.hostname}:{host.port} +
+
+
+ {host.protocol && host.protocol !== 'ssh' && ( + + {host.protocol.toUpperCase()} + + )} + {host.tags.length > 0 && ( + + {host.tags.slice(0, 2).join(', ')} + {host.tags.length > 2 && '...'} + + )} +
+
+ + + onConnect(host)}> + {t("vault.hosts.connect")} + + onEditHost(host)}> + {t("action.edit")} + + onDuplicateHost(host)}> + {t("action.duplicate")} + + onCopyCredentials(host)}> + {t("vault.hosts.copyCredentials")} + + onDeleteHost(host)} + className="text-destructive focus:text-destructive" + > + {t("action.delete")} + + + + ); +}; + +export const HostTreeView: React.FC = ({ + groupTree, + hosts, + sortMode = 'az', + expandedPaths: externalExpandedPaths, + onTogglePath: externalOnTogglePath, + onExpandAll: externalOnExpandAll, + onCollapseAll: externalOnCollapseAll, + onConnect, + onEditHost, + onDuplicateHost, + onDeleteHost, + onCopyCredentials, + onNewHost, + onNewGroup, + onEditGroup, + onDeleteGroup, + moveHostToGroup, + moveGroup, +}) => { + const { t } = useI18n(); + + // Use external state if provided, otherwise use local persistent state + const localTreeState = useTreeExpandedState(STORAGE_KEY_VAULT_HOSTS_TREE_EXPANDED); + + const expandedPaths = externalExpandedPaths || localTreeState.expandedPaths; + const togglePath = externalOnTogglePath || localTreeState.togglePath; + const expandAll = externalOnExpandAll || localTreeState.expandAll; + const collapseAll = externalOnCollapseAll || localTreeState.collapseAll; + + // Get all possible group paths for expand/collapse all functionality + const getAllGroupPaths = (nodes: GroupNode[]): string[] => { + const paths: string[] = []; + const traverse = (nodeList: GroupNode[]) => { + nodeList.forEach(node => { + paths.push(node.path); + if (node.children) { + traverse(Object.values(node.children) as GroupNode[]); + } + }); + }; + traverse(nodes); + return paths; + }; + + const allGroupPaths = useMemo(() => getAllGroupPaths(groupTree), [groupTree]); + + const handleExpandAll = () => { + expandAll(allGroupPaths); + }; + + const handleCollapseAll = () => { + collapseAll(); + }; + + // Get ungrouped hosts (hosts without a group or with empty group) and sort them + const ungroupedHosts = useMemo(() => { + const hosts_without_group = hosts.filter(host => !host.group || host.group === ''); + return hosts_without_group.sort((a, b) => { + switch (sortMode) { + case 'az': + return a.label.localeCompare(b.label); + case 'za': + return b.label.localeCompare(a.label); + case 'newest': + return (b.createdAt || 0) - (a.createdAt || 0); + case 'oldest': + return (a.createdAt || 0) - (b.createdAt || 0); + default: + return a.label.localeCompare(b.label); + } + }); + }, [hosts, sortMode]); + + // Sort group tree based on sort mode + const sortedGroupTree = useMemo(() => { + return [...groupTree].sort((a, b) => { + switch (sortMode) { + case 'za': + return b.name.localeCompare(a.name); + case 'newest': + case 'oldest': + // For groups, fall back to name sorting since groups don't have creation dates + return a.name.localeCompare(b.name); + case 'az': + default: + return a.name.localeCompare(b.name); + } + }); + }, [groupTree, sortMode]); + + return ( +
+ {/* Expand/Collapse controls */} + {groupTree.length > 0 && ( +
+ + +
+ )} + + {/* Ungrouped hosts at root level */} + {ungroupedHosts.map((host) => ( + + ))} + + {/* Group tree */} + {sortedGroupTree.map((node) => ( + + ))} + + {/* Empty state */} + {ungroupedHosts.length === 0 && groupTree.length === 0 && ( +
+ +

{t("vault.hosts.empty")}

+
+ )} +
+ ); +}; \ No newline at end of file diff --git a/components/VaultView.tsx b/components/VaultView.tsx index 9ae8bbde9..da8969049 100644 --- a/components/VaultView.tsx +++ b/components/VaultView.tsx @@ -12,6 +12,7 @@ import { Key, LayoutGrid, List, + Network, Plug, Plus, Search, @@ -25,10 +26,11 @@ import { import React, { Suspense, lazy, memo, useCallback, useEffect, useMemo, useState } from "react"; import { useI18n } from "../application/i18n/I18nProvider"; import { useStoredViewMode } from "../application/state/useStoredViewMode"; +import { useTreeExpandedState } from "../application/state/useTreeExpandedState"; import { sanitizeHost } from "../domain/host"; import { importVaultHostsFromText, exportHostsToCsvWithStats } from "../domain/vaultImport"; import type { VaultImportFormat } from "../domain/vaultImport"; -import { STORAGE_KEY_VAULT_HOSTS_VIEW_MODE } from "../infrastructure/config/storageKeys"; +import { STORAGE_KEY_VAULT_HOSTS_VIEW_MODE, STORAGE_KEY_VAULT_HOSTS_TREE_EXPANDED } from "../infrastructure/config/storageKeys"; import { cn } from "../lib/utils"; import { ConnectionLog, @@ -46,6 +48,7 @@ import { import { AppLogo } from "./AppLogo"; import { DistroAvatar } from "./DistroAvatar"; import HostDetailsPanel from "./HostDetailsPanel"; +import { HostTreeView } from "./HostTreeView"; import KeychainManager from "./KeychainManager"; import KnownHostsManager from "./KnownHostsManager"; import PortForwarding from "./PortForwardingNew"; @@ -166,6 +169,8 @@ const VaultViewInner: React.FC = ({ const [renameGroupError, setRenameGroupError] = useState(null); const [isImportOpen, setIsImportOpen] = useState(false); const [isSerialModalOpen, setIsSerialModalOpen] = useState(false); + const [isDeleteGroupOpen, setIsDeleteGroupOpen] = useState(false); + const [deleteTargetPath, setDeleteTargetPath] = useState(null); // Handle external navigation requests useEffect(() => { @@ -180,6 +185,7 @@ const VaultViewInner: React.FC = ({ STORAGE_KEY_VAULT_HOSTS_VIEW_MODE, "grid", ); + const treeExpandedState = useTreeExpandedState(STORAGE_KEY_VAULT_HOSTS_TREE_EXPANDED); const [sortMode, setSortMode] = useState("az"); const [selectedTags, setSelectedTags] = useState([]); @@ -540,6 +546,48 @@ const VaultViewInner: React.FC = ({ return root; }, [hosts, customGroups]); + // Create a separate group tree for tree view that doesn't include ungrouped hosts + const buildTreeViewGroupTree = useMemo>(() => { + const root: Record = {}; + const insertPath = (path: string, host?: Host) => { + const parts = path.split("/").filter(Boolean); + let currentLevel = root; + let currentPath = ""; + parts.forEach((part, index) => { + currentPath = currentPath ? `${currentPath}/${part}` : part; + if (!currentLevel[part]) { + currentLevel[part] = { + name: part, + path: currentPath, + children: {}, + hosts: [], + }; + } + if (host && index === parts.length - 1) + currentLevel[part].hosts.push(host); + currentLevel = currentLevel[part].children; + }); + }; + customGroups.forEach((path) => insertPath(path)); + // Only add hosts that have a non-empty group + hosts.forEach((host) => { + if (host.group && host.group.trim() !== "") { + insertPath(host.group, host); + } + }); + return root; + }, [hosts, customGroups]); + + // Convert buildGroupTree to array for tree view + const groupTree = useMemo(() => { + return (Object.values(buildGroupTree) as GroupNode[]).sort((a, b) => a.name.localeCompare(b.name)); + }, [buildGroupTree]); + + // Create tree view specific group tree that excludes ungrouped hosts + const treeViewGroupTree = useMemo(() => { + return (Object.values(buildTreeViewGroupTree) as GroupNode[]).sort((a, b) => a.name.localeCompare(b.name)); + }, [buildTreeViewGroupTree]); + const findGroupNode = (path: string | null): GroupNode | null => { if (!path) return { @@ -606,6 +654,42 @@ const VaultViewInner: React.FC = ({ return filtered; }, [hosts, selectedGroupPath, search, selectedTags, sortMode]); + // For tree view: apply search, tag filter, and sorting, but not group filtering + const treeViewHosts = useMemo(() => { + let filtered = hosts; + if (search.trim()) { + const s = search.toLowerCase(); + filtered = filtered.filter( + (h) => + h.label.toLowerCase().includes(s) || + h.hostname.toLowerCase().includes(s) || + h.tags.some((t) => t.toLowerCase().includes(s)), + ); + } + // Apply tag filter + if (selectedTags.length > 0) { + filtered = filtered.filter((h) => + selectedTags.some((t) => h.tags?.includes(t)), + ); + } + // Apply sorting + filtered = [...filtered].sort((a, b) => { + switch (sortMode) { + case "az": + return a.label.localeCompare(b.label); + case "za": + return b.label.localeCompare(a.label); + case "newest": + return (b.createdAt || 0) - (a.createdAt || 0); + case "oldest": + return (a.createdAt || 0) - (b.createdAt || 0); + default: + return 0; + } + }); + return filtered; + }, [hosts, search, selectedTags, sortMode]); + // Compute all unique tags across all hosts const allTags = useMemo(() => { const tagSet = new Set(); @@ -986,8 +1070,10 @@ const VaultViewInner: React.FC = ({ @@ -1007,6 +1093,13 @@ const VaultViewInner: React.FC = ({ > {t("vault.view.list")} + = ({ {currentSection === "hosts" && ( <>
-
- - {selectedGroupPath && - selectedGroupPath - .split("/") - .filter(Boolean) - .map((part, idx, arr) => { - const crumbPath = arr.slice(0, idx + 1).join("/"); - const isLast = idx === arr.length - 1; - return ( - - › - + {selectedGroupPath && + selectedGroupPath + .split("/") + .filter(Boolean) + .map((part, idx, arr) => { + const crumbPath = arr.slice(0, idx + 1).join("/"); + const isLast = idx === arr.length - 1; + return ( + - {part} - - - ); - })} -
- {displayedGroups.length > 0 && ( + › + + + ); + })} +
+ )} + {viewMode !== "tree" && displayedGroups.length > 0 && ( <>

@@ -1159,26 +1254,27 @@ const VaultViewInner: React.FC = ({

)} -
{ - e.preventDefault(); - }} - onDrop={(e) => { - e.preventDefault(); - e.stopPropagation(); - const hostId = e.dataTransfer.getData("host-id"); - const groupPath = e.dataTransfer.getData("group-path"); - if (hostId) moveHostToGroup(hostId, selectedGroupPath); - if (groupPath && selectedGroupPath !== null) - moveGroup(groupPath, selectedGroupPath); - }} - > + {viewMode !== "tree" && ( +
{ + e.preventDefault(); + }} + onDrop={(e) => { + e.preventDefault(); + e.stopPropagation(); + const hostId = e.dataTransfer.getData("host-id"); + const groupPath = e.dataTransfer.getData("group-path"); + if (hostId) moveHostToGroup(hostId, selectedGroupPath); + if (groupPath && selectedGroupPath !== null) + moveGroup(groupPath, selectedGroupPath); + }} + > {displayedGroups.map((node) => ( @@ -1257,6 +1353,7 @@ const VaultViewInner: React.FC = ({ ))}
+ )}
@@ -1266,120 +1363,161 @@ const VaultViewInner: React.FC = ({
- {t("vault.hosts.header.entries", { count: displayedHosts.length })} + {t("vault.hosts.header.entries", { count: viewMode === "tree" ? treeViewHosts.length : displayedHosts.length })}
{t("vault.hosts.header.live", { count: sessions.length })}
-
- {displayedHosts.map((host) => { - const safeHost = sanitizeHost(host); - const distroBadge = { - text: (safeHost.os || "L")[0].toUpperCase(), - label: safeHost.distro || safeHost.os || "Linux", - }; - return ( - - -
{ - e.dataTransfer.effectAllowed = "move"; - e.dataTransfer.setData("host-id", host.id); - }} - onClick={() => handleHostConnect(safeHost)} - > -
- -
-
- {safeHost.label} -
-
- {safeHost.username}@{safeHost.hostname} -
-
- {viewMode === "list" && ( - <> - - + + {viewMode === "tree" ? ( + onDeleteHost(host.id)} + onCopyCredentials={handleCopyCredentials} + onNewHost={(groupPath) => { + setEditingHost(null); + setIsHostPanelOpen(true); + // TODO: Set default group for new host + }} + onNewGroup={(parentPath) => { + setTargetParentPath(parentPath || null); + setNewFolderName(""); + setIsNewFolderOpen(true); + }} + onEditGroup={(groupPath) => { + setRenameTargetPath(groupPath); + const groupName = groupPath.split('/').pop() || ''; + setRenameGroupName(groupName); + setRenameGroupError(null); + setIsRenameGroupOpen(true); + }} + onDeleteGroup={(groupPath) => { + setDeleteTargetPath(groupPath); + setIsDeleteGroupOpen(true); + }} + moveHostToGroup={moveHostToGroup} + moveGroup={moveGroup} + /> + ) : ( +
+ {displayedHosts.map((host) => { + const safeHost = sanitizeHost(host); + const distroBadge = { + text: (safeHost.os || "L")[0].toUpperCase(), + label: safeHost.distro || safeHost.os || "Linux", + }; + return ( + + +
{ + e.dataTransfer.effectAllowed = "move"; + e.dataTransfer.setData("host-id", host.id); + }} + onClick={() => handleHostConnect(safeHost)} + > +
+ +
+
+ {safeHost.label} +
+
+ {safeHost.username}@{safeHost.hostname} +
+
+ {viewMode === "list" && ( + <> + + + )} +
-
- - - handleHostConnect(host)} - > - {t('vault.hosts.connect')} - - handleEditHost(host)} - > - {t('action.edit')} - - handleDuplicateHost(host)} - > - {t('action.duplicate')} - - handleCopyCredentials(host)} - > - {t('vault.hosts.copyCredentials')} - - onDeleteHost(host.id)} - > - {t('action.delete')} - - - - ); - })} - {displayedHosts.length === 0 && ( -
-
- + + + handleHostConnect(host)} + > + {t('vault.hosts.connect')} + + handleEditHost(host)} + > + {t('action.edit')} + + handleDuplicateHost(host)} + > + {t('action.duplicate')} + + handleCopyCredentials(host)} + > + {t('vault.hosts.copyCredentials')} + + onDeleteHost(host.id)} + > + {t('action.delete')} + + + + ); + })} + {displayedHosts.length === 0 && ( +
+
+ +
+

+ Set up your hosts +

+

+ Save hosts to quickly connect to your servers, VMs, + and containers. +

-

- Set up your hosts -

-

- Save hosts to quickly connect to your servers, VMs, - and containers. -

-
- )} -
+ )} +
+ )} )} @@ -1647,6 +1785,49 @@ const VaultViewInner: React.FC = ({ + { + setIsDeleteGroupOpen(open); + if (!open) { + setDeleteTargetPath(null); + } + }} + > + + + {t("vault.groups.deleteDialogTitle")} + + {t("vault.groups.deleteDialog.desc")} + + +
+ {deleteTargetPath && ( +

+ {t("vault.groups.pathLabel")}:{" "} + {deleteTargetPath} +

+ )} +
+ + + + +
+
+ = 10.0.0" } @@ -5618,7 +5621,6 @@ "integrity": "sha512-eEXsVvLPu8Z4PkFibtuFJLJOTAV/nPdgtSjkGoPpddpFk3/ym2oy97jynY6ic2m6+nc5M8SE1e9v/mHKsulcJg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/regexpp": "^4.12.2", "@typescript-eslint/scope-manager": "8.53.0", @@ -5648,7 +5650,6 @@ "integrity": "sha512-npiaib8XzbjtzS2N4HlqPvlpxpmZ14FjSJrteZpPxGUaYPlvhzlzUZ4mZyABo0EFrOWnvyd0Xxroq//hKhtAWg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.53.0", "@typescript-eslint/types": "8.53.0", @@ -5927,8 +5928,7 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/@xterm/xterm/-/xterm-5.5.0.tgz", "integrity": "sha512-hqJHYaQb5OptNunnyAnkHyM8aCjZ1MEIDTQu1iIbbTD/xops91NB5yq1ZK/dC2JDbVWtF23zUtl9JE2NqwT87A==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@yarnpkg/lockfile": { "version": "1.1.0", @@ -5960,7 +5960,6 @@ "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -5993,7 +5992,6 @@ "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "fast-deep-equal": "^3.1.1", "fast-json-stable-stringify": "^2.0.0", @@ -6401,7 +6399,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -7061,7 +7058,8 @@ "integrity": "sha512-+R08/oI0nl3vfPcqftZRpytksBXDzOUveBq/NBVx0sUp1axwzPQrKinNx5yd5sxPu8j1wIy8AfnVQ+5eFdha6Q==", "dev": true, "license": "MIT", - "optional": true + "optional": true, + "peer": true }, "node_modules/cross-env": { "version": "10.1.0", @@ -7301,7 +7299,6 @@ "integrity": "sha512-ce4Ogns4VMeisIuCSK0C62umG0lFy012jd8LMZ6w/veHUeX4fqfDrGe+HTWALAEwK6JwKP+dhPvizhArSOsFbg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "app-builder-lib": "26.4.0", "builder-util": "26.3.4", @@ -7627,6 +7624,7 @@ "dev": true, "hasInstallScript": true, "license": "MIT", + "peer": true, "dependencies": { "@electron/asar": "^3.2.1", "debug": "^4.1.1", @@ -7647,6 +7645,7 @@ "integrity": "sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", @@ -7871,7 +7870,6 @@ "integrity": "sha512-LEyamqS7W5HB3ujJyvi0HQK/dtVINZvd5mAAp9eT5S/ujByGjiZLCzPcHVzuXbpJDJF/cxwHlfceVUDZ2lnSTw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -10154,7 +10152,6 @@ "resolved": "https://registry.npmjs.org/monaco-editor/-/monaco-editor-0.55.1.tgz", "integrity": "sha512-jz4x+TJNFHwHtwuV9vA9rMujcZRb0CEilTEwG2rRSpe/A7Jdkuj8xPKttCgOh+v/lkHy7HsZ64oj+q3xoAFl9A==", "license": "MIT", - "peer": true, "dependencies": { "dompurify": "3.2.7", "marked": "14.0.0" @@ -10780,7 +10777,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -10839,6 +10835,7 @@ "dev": true, "license": "MIT", "optional": true, + "peer": true, "dependencies": { "commander": "^9.4.0" }, @@ -10856,6 +10853,7 @@ "dev": true, "license": "MIT", "optional": true, + "peer": true, "engines": { "node": "^12.20.0 || >=14" } @@ -10956,7 +10954,6 @@ "resolved": "https://registry.npmjs.org/react/-/react-19.2.3.tgz", "integrity": "sha512-Ku/hhYbVjOQnXDZFv2+RibmLFGwFdeeKHFcOTlrt7xplBnya5OGn/hIRDsqDiSUcfORsDC7MPxwork8jBwsIWA==", "license": "MIT", - "peer": true, "engines": { "node": ">=0.10.0" } @@ -10966,7 +10963,6 @@ "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.2.3.tgz", "integrity": "sha512-yELu4WmLPw5Mr/lmeEpox5rw3RETacE++JgHqQzd2dg+YbJuat3jH4ingc+WPZhxaoFzdv9y33G+F7Nl5O0GBg==", "license": "MIT", - "peer": true, "dependencies": { "scheduler": "^0.27.0" }, @@ -11895,6 +11891,7 @@ "integrity": "sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "mkdirp": "^0.5.1", "rimraf": "~2.6.2" @@ -11958,6 +11955,7 @@ "integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==", "dev": true, "license": "MIT", + "peer": true, "dependencies": { "minimist": "^1.2.6" }, @@ -11972,6 +11970,7 @@ "deprecated": "Rimraf versions prior to v4 are no longer supported", "dev": true, "license": "ISC", + "peer": true, "dependencies": { "glob": "^7.1.3" }, @@ -12133,7 +12132,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -12336,7 +12334,6 @@ "integrity": "sha512-w+N7Hifpc3gRjZ63vYBXA56dvvRlNWRczTdmCBBa+CotUzAPf5b7YMdMR/8CQoeYE5LX3W4wj6RYTgonm1b9DA==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.27.0", "fdir": "^6.5.0", @@ -12691,7 +12688,6 @@ "integrity": "sha512-k7Nwx6vuWx1IJ9Bjuf4Zt1PEllcwe7cls3VNzm4CQ1/hgtFUK2bRNG3rvnpPUhFjmqJKAKtjV576KnUkHocg/g==", "dev": true, "license": "MIT", - "peer": true, "funding": { "url": "https://github.com/sponsors/colinhacks" }