mirror of
https://github.com/tiennm99/goclaw.git
synced 2026-10-14 10:18:42 +00:00
fix(desktop): address code review findings — deduplicate slugify, restore moveFile guard, fix name collision
- H1: rename McpTestResult component import to McpTestResultDisplay (avoid type collision) - H2: replace local slugify with shared lib/slug import in McpFormDialog - H3: restore same-path no-op guard in storageService.moveFile - H4: deduplicate StorageFileContent interface (use service as source of truth) - M1: replace inline import() syntax with standard import in use-storage
This commit is contained in:
1 parent
6be88f4178
commit
3466df726c
3 files changed
+7
-14
No files matched your search
@@ -3,17 +3,14 @@ import { useForm } from 'react-hook-form'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Switch } from '../common/Switch'
|
||||
import { McpTestResult } from './mcp-test-result'
|
||||
import { McpTestResult as McpTestResultDisplay } from './mcp-test-result'
|
||||
import { McpTransportFields } from './mcp-transport-fields'
|
||||
import { mcpFormSchema, type MCPFormData } from '../../schemas/mcp.schema'
|
||||
import { slugify } from '../../lib/slug'
|
||||
import type { MCPServerData, MCPServerInput, MCPTestResult } from '../../types/mcp'
|
||||
|
||||
const TRANSPORTS = ['stdio', 'sse', 'streamable-http'] as const
|
||||
|
||||
function slugify(v: string): string {
|
||||
return v.toLowerCase().replace(/[^a-z0-9-]/g, '-').replace(/-+/g, '-').replace(/^-/, '')
|
||||
}
|
||||
|
||||
interface McpFormDialogProps {
|
||||
open: boolean
|
||||
onOpenChange: (open: boolean) => void
|
||||
@@ -195,7 +192,7 @@ export function McpFormDialog({ open, onOpenChange, server, onSubmit, onTest }:
|
||||
|
||||
{/* Footer */}
|
||||
<div className="border-t border-border px-5 py-4 space-y-2">
|
||||
<McpTestResult state={testState} result={testResult} />
|
||||
<McpTestResultDisplay state={testState} result={testResult} />
|
||||
<div className="flex items-center justify-between">
|
||||
<button type="button" onClick={handleTest} disabled={isSubmitting || testState === 'testing'} className="border border-border rounded-lg px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-tertiary transition-colors disabled:opacity-50 shrink-0">
|
||||
{testState === 'testing' ? (
|
||||
|
||||
@@ -4,16 +4,11 @@
|
||||
import { useState, useCallback, useEffect, useRef } from 'react'
|
||||
import { storageService } from '../services/storage-service'
|
||||
|
||||
export type { StorageFile } from '../services/storage-service'
|
||||
|
||||
interface StorageFileContent {
|
||||
content: string
|
||||
path: string
|
||||
size: number
|
||||
}
|
||||
export type { StorageFile, StorageFileContent } from '../services/storage-service'
|
||||
import type { StorageFile, StorageFileContent } from '../services/storage-service'
|
||||
|
||||
export function useStorage() {
|
||||
const [files, setFiles] = useState<import('../services/storage-service').StorageFile[]>([])
|
||||
const [files, setFiles] = useState<StorageFile[]>([])
|
||||
const [baseDir, setBaseDir] = useState('')
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ export const storageService = {
|
||||
moveFile(fromPath: string, toFolder: string): Promise<void> {
|
||||
const fileName = fromPath.split('/').pop() ?? fromPath
|
||||
const newPath = toFolder ? `${toFolder}/${fileName}` : fileName
|
||||
if (fromPath === newPath) return Promise.resolve()
|
||||
return getApiClient().putRaw(
|
||||
`/v1/storage/move?from=${encodeURIComponent(fromPath)}&to=${encodeURIComponent(newPath)}`,
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user