Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

refactor(web): remove unnecessary use prefixes (#44231)

Stephen Zhou43c5f3c83f51
diff --git a/oxlint-suppressions.json b/oxlint-suppressions.json
index 5f7c6f67567..ea3909e3092 100644
--- a/oxlint-suppressions.json
+++ b/oxlint-suppressions.json
@@ -817,11 +817,6 @@
"count": 1
}
},
- "web/app/components/base/file-uploader/hooks.ts": {
- "eslint-react/no-unnecessary-use-prefix": {
- "count": 1
- }
- },
"web/app/components/base/file-uploader/index.ts": {
"no-barrel-files/no-barrel-files": {
"count": 5
@@ -1731,11 +1726,6 @@
"count": 6
}
},
- "web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-custom-models.ts": {
- "eslint-react/no-unnecessary-use-prefix": {
- "count": 2
- }
- },
"web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-model-form-schemas.ts": {
"typescript/no-explicit-any": {
"count": 2
@@ -1799,11 +1789,6 @@
"count": 4
}
},
- "web/app/components/plugins/install-plugin/hooks/use-fold-anim-into.ts": {
- "eslint-react/no-unnecessary-use-prefix": {
- "count": 1
- }
- },
"web/app/components/plugins/install-plugin/install-bundle/index.tsx": {
"react/only-export-components": {
"count": 1
@@ -1863,11 +1848,6 @@
"count": 1
}
},
- "web/app/components/plugins/plugin-auth/hooks/use-get-api.ts": {
- "eslint-react/no-unnecessary-use-prefix": {
- "count": 1
- }
- },
"web/app/components/plugins/plugin-auth/index.tsx": {
"no-barrel-files/no-barrel-files": {
"count": 12
@@ -2554,11 +2534,6 @@
"count": 1
}
},
- "web/app/components/workflow/nodes/_base/components/variable/variable-label/hooks.ts": {
- "eslint-react/no-unnecessary-use-prefix": {
- "count": 1
- }
- },
"web/app/components/workflow/nodes/_base/components/variable/variable-label/index.tsx": {
"no-barrel-files/no-barrel-files": {
"count": 5
@@ -2581,9 +2556,6 @@
}
},
"web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts": {
- "eslint-react/no-unnecessary-use-prefix": {
- "count": 2
- },
"eslint-react/set-state-in-effect": {
"count": 1
},
diff --git a/web/app/components/base/file-uploader/__tests__/hooks.spec.ts b/web/app/components/base/file-uploader/__tests__/hooks.spec.ts
index 0c5225ab96a..495692c9a46 100644
--- a/web/app/components/base/file-uploader/__tests__/hooks.spec.ts
+++ b/web/app/components/base/file-uploader/__tests__/hooks.spec.ts
@@ -2,7 +2,7 @@ import type { UploadConfig } from '@dify/contracts/api/console/files/types.gen'
import type { FileEntity } from '../types'
import type { FileUpload } from '@/app/components/base/features/types'
import { act, renderHook } from '@testing-library/react'
-import { useFile, useFileSizeLimit } from '../hooks'
+import { getFileSizeLimit, useFile } from '../hooks'
const mockNotify = vi.fn()
const mockNavigationState = vi.hoisted(() => ({
@@ -67,20 +67,20 @@ vi.mock('uuid', () => ({
v4: () => 'mock-uuid',
}))
-describe('useFileSizeLimit', () => {
+describe('getFileSizeLimit', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('should return default limits when no config is provided', () => {
- const { result } = renderHook(() => useFileSizeLimit())
-
- expect(result.current.imgSizeLimit).toBe(10 * 1024 * 1024)
- expect(result.current.docSizeLimit).toBe(15 * 1024 * 1024)
- expect(result.current.audioSizeLimit).toBe(50 * 1024 * 1024)
- expect(result.current.videoSizeLimit).toBe(100 * 1024 * 1024)
- expect(result.current.skillSizeLimit).toBe(50 * 1024 * 1024)
- expect(result.current.maxFileUploadLimit).toBe(10)
+ const result = getFileSizeLimit()
+
+ expect(result.imgSizeLimit).toBe(10 * 1024 * 1024)
+ expect(result.docSizeLimit).toBe(15 * 1024 * 1024)
+ expect(result.audioSizeLimit).toBe(50 * 1024 * 1024)
+ expect(result.videoSizeLimit).toBe(100 * 1024 * 1024)
+ expect(result.skillSizeLimit).toBe(50 * 1024 * 1024)
+ expect(result.maxFileUploadLimit).toBe(10)
})
it('should use config values when provided', () => {
@@ -93,14 +93,14 @@ describe('useFileSizeLimit', () => {
workflow_file_upload_limit: 20,
} as UploadConfig
- const { result } = renderHook(() => useFileSizeLimit(config))
+ const result = getFileSizeLimit(config)
- expect(result.current.imgSizeLimit).toBe(20 * 1024 * 1024)
- expect(result.current.docSizeLimit).toBe(30 * 1024 * 1024)
- expect(result.current.audioSizeLimit).toBe(100 * 1024 * 1024)
- expect(result.current.videoSizeLimit).toBe(200 * 1024 * 1024)
- expect(result.current.skillSizeLimit).toBe(60 * 1024 * 1024)
- expect(result.current.maxFileUploadLimit).toBe(20)
+ expect(result.imgSizeLimit).toBe(20 * 1024 * 1024)
+ expect(result.docSizeLimit).toBe(30 * 1024 * 1024)
+ expect(result.audioSizeLimit).toBe(100 * 1024 * 1024)
+ expect(result.videoSizeLimit).toBe(200 * 1024 * 1024)
+ expect(result.skillSizeLimit).toBe(60 * 1024 * 1024)
+ expect(result.maxFileUploadLimit).toBe(20)
})
it('should fall back to defaults when config values are zero', () => {
@@ -113,14 +113,14 @@ describe('useFileSizeLimit', () => {
workflow_file_upload_limit: 0,
} as UploadConfig
- const { result } = renderHook(() => useFileSizeLimit(config))
+ const result = getFileSizeLimit(config)
- expect(result.current.imgSizeLimit).toBe(10 * 1024 * 1024)
- expect(result.current.docSizeLimit).toBe(15 * 1024 * 1024)
- expect(result.current.audioSizeLimit).toBe(50 * 1024 * 1024)
- expect(result.current.videoSizeLimit).toBe(100 * 1024 * 1024)
- expect(result.current.skillSizeLimit).toBe(50 * 1024 * 1024)
- expect(result.current.maxFileUploadLimit).toBe(10)
+ expect(result.imgSizeLimit).toBe(10 * 1024 * 1024)
+ expect(result.docSizeLimit).toBe(15 * 1024 * 1024)
+ expect(result.audioSizeLimit).toBe(50 * 1024 * 1024)
+ expect(result.videoSizeLimit).toBe(100 * 1024 * 1024)
+ expect(result.skillSizeLimit).toBe(50 * 1024 * 1024)
+ expect(result.maxFileUploadLimit).toBe(10)
})
})
diff --git a/web/app/components/base/file-uploader/hooks.ts b/web/app/components/base/file-uploader/hooks.ts
index 1cb1db97e4c..a5f6a33ec2a 100644
--- a/web/app/components/base/file-uploader/hooks.ts
+++ b/web/app/components/base/file-uploader/hooks.ts
@@ -31,7 +31,7 @@ import {
isAllowedFileExtension,
} from './utils'
-export const useFileSizeLimit = (fileUploadConfig?: UploadConfig) => {
+export const getFileSizeLimit = (fileUploadConfig?: UploadConfig) => {
const imgSizeLimit =
Number(fileUploadConfig?.image_file_size_limit) * 1024 * 1024 || IMG_SIZE_LIMIT
const docSizeLimit = Number(fileUploadConfig?.file_size_limit) * 1024 * 1024 || FILE_SIZE_LIMIT
@@ -60,7 +60,7 @@ export const useFile = (fileConfig: FileUpload, noNeedToCheckEnable = true) => {
const params = useParams()
const pathname = usePathname()
const { localUploadUrl, remoteUploadUrl } = useFileUploadContext()
- const { imgSizeLimit, docSizeLimit, audioSizeLimit, videoSizeLimit } = useFileSizeLimit(
+ const { imgSizeLimit, docSizeLimit, audioSizeLimit, videoSizeLimit } = getFileSizeLimit(
fileConfig.fileUploadConfig,
)
const formToken = typeof params.token === 'string' ? params.token : undefined
diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/__tests__/add-custom-model.spec.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/__tests__/add-custom-model.spec.tsx
index 4dbf2eac649..066c054012c 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-auth/__tests__/add-custom-model.spec.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-auth/__tests__/add-custom-model.spec.tsx
@@ -27,8 +27,8 @@ vi.mock('../hooks/use-auth', () => ({
}))
let mockCanAddedModels: { model: string; model_type: string }[] = []
-vi.mock('../hooks/use-custom-models', () => ({
- useCanAddedModels: () => mockCanAddedModels,
+vi.mock('../hooks/get-custom-models', () => ({
+ getCanAddedModels: () => mockCanAddedModels,
}))
const mockWorkspacePermissionKeys = vi.hoisted(() => ({
diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/__tests__/manage-custom-model-credentials.spec.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/__tests__/manage-custom-model-credentials.spec.tsx
index f96164ebbae..e7fa71d49fb 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-auth/__tests__/manage-custom-model-credentials.spec.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-auth/__tests__/manage-custom-model-credentials.spec.tsx
@@ -4,9 +4,9 @@ import userEvent from '@testing-library/user-event'
import ManageCustomModelCredentials from '../manage-custom-model-credentials'
// Mock hooks
-const mockUseCustomModels = vi.fn()
+const mockGetCustomModels = vi.fn()
vi.mock('../hooks', () => ({
- useCustomModels: () => mockUseCustomModels(),
+ getCustomModels: () => mockGetCustomModels(),
useAuth: () => ({
handleOpenModal: vi.fn(),
}),
@@ -64,7 +64,7 @@ describe('ManageCustomModelCredentials', () => {
})
it('should return null when no custom models exist', () => {
- mockUseCustomModels.mockReturnValue([])
+ mockGetCustomModels.mockReturnValue([])
const { container } = render(<ManageCustomModelCredentials provider={mockProvider} />)
expect(container.firstChild).toBeNull()
})
@@ -82,7 +82,7 @@ describe('ManageCustomModelCredentials', () => {
// testing undefined credentials branch
},
]
- mockUseCustomModels.mockReturnValue(mockModels)
+ mockGetCustomModels.mockReturnValue(mockModels)
render(<ManageCustomModelCredentials provider={mockProvider} />)
@@ -103,7 +103,7 @@ describe('ManageCustomModelCredentials', () => {
current_credential_name: 'Key 1',
},
]
- mockUseCustomModels.mockReturnValue(mockModels)
+ mockGetCustomModels.mockReturnValue(mockModels)
render(<ManageCustomModelCredentials provider={mockProvider} />)
@@ -114,7 +114,7 @@ describe('ManageCustomModelCredentials', () => {
it('should forward controlled open state', async () => {
const user = userEvent.setup()
const onOpenChange = vi.fn()
- mockUseCustomModels.mockReturnValue([{ model: 'gpt-4' }])
+ mockGetCustomModels.mockReturnValue([{ model: 'gpt-4' }])
render(
<ManageCustomModelCredentials provider={mockProvider} isOpen onOpenChange={onOpenChange} />,
@@ -135,7 +135,7 @@ describe('ManageCustomModelCredentials', () => {
current_credential_name: '',
},
]
- mockUseCustomModels.mockReturnValue(mockModels)
+ mockGetCustomModels.mockReturnValue(mockModels)
render(<ManageCustomModelCredentials provider={mockProvider} />)
diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx
index 023ba0e3e05..781a6761e6c 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-auth/add-custom-model.tsx
@@ -12,8 +12,8 @@ import { useTranslation } from 'react-i18next'
import { ModelModalModeEnum } from '@/app/components/header/account-setting/model-provider-page/declarations'
import { useCredentialPermissions } from '@/hooks/use-credential-permissions'
import ModelIcon from '../model-icon'
+import { getCanAddedModels } from './hooks/get-custom-models'
import { useAuth } from './hooks/use-auth'
-import { useCanAddedModels } from './hooks/use-custom-models'
type AddCustomModelProps = {
provider: ModelProvider
@@ -36,7 +36,7 @@ const AddCustomModel = ({
setLocalOpen(nextOpen)
onOpenChange?.(nextOpen)
}
- const canAddedModels = useCanAddedModels(provider)
+ const canAddedModels = getCanAddedModels(provider)
const noModels = !canAddedModels.length
const { canUseCredential, canCreateCredential } = useCredentialPermissions()
const { handleOpenModal: handleOpenModalForAddNewCustomModel } = useAuth(
diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/__tests__/get-custom-models.spec.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/__tests__/get-custom-models.spec.tsx
new file mode 100644
index 00000000000..8ab725ee373
--- /dev/null
+++ b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/__tests__/get-custom-models.spec.tsx
@@ -0,0 +1,37 @@
+import type { ModelProvider } from '../../../declarations'
+import { getCanAddedModels, getCustomModels } from '../get-custom-models'
+
+describe('getCustomModels and getCanAddedModels', () => {
+ it('extracts custom models from provider correctly', () => {
+ const mockProvider = {
+ custom_configuration: {
+ custom_models: [
+ { model: 'gpt-4', model_type: 'text-generation' },
+ { model: 'gpt-3.5', model_type: 'text-generation' },
+ ],
+ },
+ } as unknown as ModelProvider
+
+ const result = getCustomModels(mockProvider)
+ expect(result).toHaveLength(2)
+ expect(result[0]!.model).toBe('gpt-4')
+
+ const emptyRes = getCustomModels({ custom_configuration: {} } as unknown as ModelProvider)
+ expect(emptyRes).toEqual([])
+ })
+
+ it('extracts can_added_models from provider correctly', () => {
+ const mockProvider = {
+ custom_configuration: {
+ can_added_models: [{ model: 'gpt-4-turbo', model_type: 'text-generation' }],
+ },
+ } as unknown as ModelProvider
+
+ const result = getCanAddedModels(mockProvider)
+ expect(result).toHaveLength(1)
+ expect(result[0]!.model).toBe('gpt-4-turbo')
+
+ const emptyRes = getCanAddedModels({ custom_configuration: {} } as unknown as ModelProvider)
+ expect(emptyRes).toEqual([])
+ })
+})
diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/__tests__/use-custom-models.spec.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/__tests__/use-custom-models.spec.tsx
deleted file mode 100644
index 6538a9d3440..00000000000
--- a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/__tests__/use-custom-models.spec.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import type { ModelProvider } from '../../../declarations'
-import { renderHook } from '@testing-library/react'
-import { useCanAddedModels, useCustomModels } from '../use-custom-models'
-
-describe('useCustomModels and useCanAddedModels', () => {
- it('extracts custom models from provider correctly', () => {
- const mockProvider = {
- custom_configuration: {
- custom_models: [
- { model: 'gpt-4', model_type: 'text-generation' },
- { model: 'gpt-3.5', model_type: 'text-generation' },
- ],
- },
- } as unknown as ModelProvider
-
- const { result } = renderHook(() => useCustomModels(mockProvider))
- expect(result.current).toHaveLength(2)
- expect(result.current[0]!.model).toBe('gpt-4')
-
- const { result: emptyRes } = renderHook(() =>
- useCustomModels({ custom_configuration: {} } as unknown as ModelProvider),
- )
- expect(emptyRes.current).toEqual([])
- })
-
- it('extracts can_added_models from provider correctly', () => {
- const mockProvider = {
- custom_configuration: {
- can_added_models: [{ model: 'gpt-4-turbo', model_type: 'text-generation' }],
- },
- } as unknown as ModelProvider
-
- const { result } = renderHook(() => useCanAddedModels(mockProvider))
- expect(result.current).toHaveLength(1)
- expect(result.current[0]!.model).toBe('gpt-4-turbo')
-
- const { result: emptyRes } = renderHook(() =>
- useCanAddedModels({ custom_configuration: {} } as unknown as ModelProvider),
- )
- expect(emptyRes.current).toEqual([])
- })
-})
diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-custom-models.ts b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/get-custom-models.ts
similarity index 65%
rename from web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-custom-models.ts
rename to web/app/components/header/account-setting/model-provider-page/model-auth/hooks/get-custom-models.ts
index fe7a063b000..e2ab5f6325b 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/use-custom-models.ts
+++ b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/get-custom-models.ts
@@ -1,12 +1,12 @@
import type { ModelProvider } from '../../declarations'
-export const useCustomModels = (provider: ModelProvider) => {
+export const getCustomModels = (provider: ModelProvider) => {
const { custom_models } = provider.custom_configuration
return custom_models || []
}
-export const useCanAddedModels = (provider: ModelProvider) => {
+export const getCanAddedModels = (provider: ModelProvider) => {
const { can_added_models } = provider.custom_configuration
return can_added_models || []
diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/index.ts b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/index.ts
index 4d0698e1028..1c2d172af02 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/index.ts
+++ b/web/app/components/header/account-setting/model-provider-page/model-auth/hooks/index.ts
@@ -1,6 +1,6 @@
+export * from './get-custom-models'
export * from './use-auth'
export * from './use-auth-service'
export * from './use-credential-data'
export * from './use-credential-status'
-export * from './use-custom-models'
export * from './use-model-form-schemas'
diff --git a/web/app/components/header/account-setting/model-provider-page/model-auth/manage-custom-model-credentials.tsx b/web/app/components/header/account-setting/model-provider-page/model-auth/manage-custom-model-credentials.tsx
index 90e6a3a70fb..6e90c4aac9c 100644
--- a/web/app/components/header/account-setting/model-provider-page/model-auth/manage-custom-model-credentials.tsx
+++ b/web/app/components/header/account-setting/model-provider-page/model-auth/manage-custom-model-credentials.tsx
@@ -11,7 +11,7 @@ import {
ModelModalModeEnum,
} from '@/app/components/header/account-setting/model-provider-page/declarations'
import Authorized from './authorized'
-import { useCustomModels } from './hooks'
+import { getCustomModels } from './hooks'
type ManageCustomModelCredentialsProps = {
provider: ModelProvider
@@ -26,7 +26,7 @@ const ManageCustomModelCredentials = ({
onOpenChange,
}: ManageCustomModelCredentialsProps) => {
const { t } = useTranslation(['common', 'modelProvider'])
- const customModels = useCustomModels(provider)
+ const customModels = getCustomModels(provider)
const noModels = !customModels.length
const renderTrigger = useCallback(
diff --git a/web/app/components/plugins/install-plugin/hooks/__tests__/use-fold-anim-into.spec.ts b/web/app/components/plugins/install-plugin/hooks/__tests__/create-fold-anim-into.spec.ts
similarity index 73%
rename from web/app/components/plugins/install-plugin/hooks/__tests__/use-fold-anim-into.spec.ts
rename to web/app/components/plugins/install-plugin/hooks/__tests__/create-fold-anim-into.spec.ts
index 32f1850d065..bada488e605 100644
--- a/web/app/components/plugins/install-plugin/hooks/__tests__/use-fold-anim-into.spec.ts
+++ b/web/app/components/plugins/install-plugin/hooks/__tests__/create-fold-anim-into.spec.ts
@@ -1,8 +1,8 @@
import type { Mock } from 'vite-plus/test'
-import { act, renderHook } from '@testing-library/react'
+import { act } from '@testing-library/react'
import { afterEach, beforeEach, describe, expect, it, vi } from 'vite-plus/test'
-describe('useFoldAnimInto', () => {
+describe('createFoldAnimInto', () => {
let mockOnClose: Mock<() => void>
beforeEach(() => {
@@ -20,34 +20,34 @@ describe('useFoldAnimInto', () => {
describe('foldIntoAnim', () => {
it('should call onClose immediately when modal element is not found', async () => {
- const useFoldAnimInto = (await import('../use-fold-anim-into')).default
- const { result } = renderHook(() => useFoldAnimInto(mockOnClose))
+ const createFoldAnimInto = (await import('../create-fold-anim-into')).default
+ const result = createFoldAnimInto(mockOnClose)
await act(async () => {
- await result.current.foldIntoAnim()
+ await result.foldIntoAnim()
})
expect(mockOnClose).toHaveBeenCalledTimes(1)
})
it('should call onClose when modal exists but trigger element is not found', async () => {
- const useFoldAnimInto = (await import('../use-fold-anim-into')).default
- const { result } = renderHook(() => useFoldAnimInto(mockOnClose))
+ const createFoldAnimInto = (await import('../create-fold-anim-into')).default
+ const result = createFoldAnimInto(mockOnClose)
const modal = document.createElement('div')
modal.className = 'install-modal'
document.body.appendChild(modal)
await act(async () => {
- await result.current.foldIntoAnim()
+ await result.foldIntoAnim()
})
expect(mockOnClose).toHaveBeenCalledTimes(1)
})
it('should animate and call onClose when both elements exist', async () => {
- const useFoldAnimInto = (await import('../use-fold-anim-into')).default
- const { result } = renderHook(() => useFoldAnimInto(mockOnClose))
+ const createFoldAnimInto = (await import('../create-fold-anim-into')).default
+ const result = createFoldAnimInto(mockOnClose)
const modal = document.createElement('div')
modal.className = 'install-modal'
@@ -65,7 +65,7 @@ describe('useFoldAnimInto', () => {
document.body.appendChild(trigger)
await act(async () => {
- await result.current.foldIntoAnim()
+ await result.foldIntoAnim()
})
// Should apply animation styles
@@ -76,8 +76,8 @@ describe('useFoldAnimInto', () => {
})
it('should use plugins-nav-button as fallback trigger element', async () => {
- const useFoldAnimInto = (await import('../use-fold-anim-into')).default
- const { result } = renderHook(() => useFoldAnimInto(mockOnClose))
+ const createFoldAnimInto = (await import('../create-fold-anim-into')).default
+ const result = createFoldAnimInto(mockOnClose)
const modal = document.createElement('div')
modal.className = 'install-modal'
@@ -95,7 +95,7 @@ describe('useFoldAnimInto', () => {
document.body.appendChild(navButton)
await act(async () => {
- await result.current.foldIntoAnim()
+ await result.foldIntoAnim()
})
expect(modal.style.transform).toContain('translate')
@@ -105,15 +105,15 @@ describe('useFoldAnimInto', () => {
describe('clearCountDown', () => {
it('should clear the countdown timer', async () => {
- const useFoldAnimInto = (await import('../use-fold-anim-into')).default
- const { result } = renderHook(() => useFoldAnimInto(mockOnClose))
+ const createFoldAnimInto = (await import('../create-fold-anim-into')).default
+ const result = createFoldAnimInto(mockOnClose)
// Start countdown then clear it
await act(async () => {
- result.current.countDownFoldIntoAnim()
+ result.countDownFoldIntoAnim()
})
- result.current.clearCountDown()
+ result.clearCountDown()
// Advance past the countdown time — onClose should NOT be called
await act(async () => {
@@ -127,11 +127,11 @@ describe('useFoldAnimInto', () => {
describe('countDownFoldIntoAnim', () => {
it('should trigger foldIntoAnim after 15 seconds', async () => {
- const useFoldAnimInto = (await import('../use-fold-anim-into')).default
- const { result } = renderHook(() => useFoldAnimInto(mockOnClose))
+ const createFoldAnimInto = (await import('../create-fold-anim-into')).default
+ const result = createFoldAnimInto(mockOnClose)
await act(async () => {
- result.current.countDownFoldIntoAnim()
+ result.countDownFoldIntoAnim()
})
// Advance by 15 seconds
@@ -144,11 +144,11 @@ describe('useFoldAnimInto', () => {
})
it('should not trigger before 15 seconds', async () => {
- const useFoldAnimInto = (await import('../use-fold-anim-into')).default
- const { result } = renderHook(() => useFoldAnimInto(mockOnClose))
+ const createFoldAnimInto = (await import('../create-fold-anim-into')).default
+ const result = createFoldAnimInto(mockOnClose)
await act(async () => {
- result.current.countDownFoldIntoAnim()
+ result.countDownFoldIntoAnim()
})
// Advance only 10 seconds
diff --git a/web/app/components/plugins/install-plugin/hooks/__tests__/use-hide-logic.spec.ts b/web/app/components/plugins/install-plugin/hooks/__tests__/use-hide-logic.spec.ts
index 98d9274032d..1d8dc9c7666 100644
--- a/web/app/components/plugins/install-plugin/hooks/__tests__/use-hide-logic.spec.ts
+++ b/web/app/components/plugins/install-plugin/hooks/__tests__/use-hide-logic.spec.ts
@@ -6,7 +6,7 @@ const mockFoldAnimInto = vi.fn()
const mockClearCountDown = vi.fn()
const mockCountDownFoldIntoAnim = vi.fn()
-vi.mock('../use-fold-anim-into', () => ({
+vi.mock('../create-fold-anim-into', () => ({
default: () => ({
modalClassName: 'test-modal-class',
foldIntoAnim: mockFoldAnimInto,
diff --git a/web/app/components/plugins/install-plugin/hooks/use-fold-anim-into.ts b/web/app/components/plugins/install-plugin/hooks/create-fold-anim-into.ts
similarity index 95%
rename from web/app/components/plugins/install-plugin/hooks/use-fold-anim-into.ts
rename to web/app/components/plugins/install-plugin/hooks/create-fold-anim-into.ts
index dd29c6d4613..99bb5ea07d9 100644
--- a/web/app/components/plugins/install-plugin/hooks/use-fold-anim-into.ts
+++ b/web/app/components/plugins/install-plugin/hooks/create-fold-anim-into.ts
@@ -12,7 +12,7 @@ function getElemCenter(elem: HTMLElement) {
}
}
-const useFoldAnimInto = (onClose: () => void) => {
+const createFoldAnimInto = (onClose: () => void) => {
let countDownRunId: number
const clearCountDown = () => {
clearTimeout(countDownRunId)
@@ -56,4 +56,4 @@ const useFoldAnimInto = (onClose: () => void) => {
}
}
-export default useFoldAnimInto
+export default createFoldAnimInto
diff --git a/web/app/components/plugins/install-plugin/hooks/use-hide-logic.ts b/web/app/components/plugins/install-plugin/hooks/use-hide-logic.ts
index bdb4da8aa3a..13bc3c7174d 100644
--- a/web/app/components/plugins/install-plugin/hooks/use-hide-logic.ts
+++ b/web/app/components/plugins/install-plugin/hooks/use-hide-logic.ts
@@ -1,5 +1,5 @@
import { useCallback, useState } from 'react'
-import useFoldAnimInto from './use-fold-anim-into'
+import createFoldAnimInto from './create-fold-anim-into'
const useHideLogic = (onClose: () => void) => {
const {
@@ -7,7 +7,7 @@ const useHideLogic = (onClose: () => void) => {
foldIntoAnim: doFoldAnimInto,
clearCountDown,
countDownFoldIntoAnim,
- } = useFoldAnimInto(onClose)
+ } = createFoldAnimInto(onClose)
const [isInstalling, doSetIsInstalling] = useState(false)
const setIsInstalling = useCallback(
diff --git a/web/app/components/plugins/plugin-auth/hooks/__tests__/use-get-api.spec.ts b/web/app/components/plugins/plugin-auth/hooks/__tests__/get-api.spec.ts
similarity index 82%
rename from web/app/components/plugins/plugin-auth/hooks/__tests__/use-get-api.spec.ts
rename to web/app/components/plugins/plugin-auth/hooks/__tests__/get-api.spec.ts
index 843cd9736ca..1eb492d57f1 100644
--- a/web/app/components/plugins/plugin-auth/hooks/__tests__/use-get-api.spec.ts
+++ b/web/app/components/plugins/plugin-auth/hooks/__tests__/get-api.spec.ts
@@ -1,13 +1,13 @@
import { describe, expect, it } from 'vite-plus/test'
import { AuthCategory, CredentialTypeEnum } from '../../types'
-import { useGetApi } from '../use-get-api'
+import { getApi } from '../get-api'
-describe('useGetApi', () => {
+describe('getApi', () => {
const provider = 'test-provider'
describe('tool category', () => {
it('returns correct API paths for tool category', () => {
- const api = useGetApi({ category: AuthCategory.tool, provider })
+ const api = getApi({ category: AuthCategory.tool, provider })
expect(api.getCredentialInfo).toBe(
`/workspaces/current/tool-provider/builtin/${provider}/credential/info`,
)
@@ -28,7 +28,7 @@ describe('useGetApi', () => {
})
it('returns a function for getCredentialSchema', () => {
- const api = useGetApi({ category: AuthCategory.tool, provider })
+ const api = getApi({ category: AuthCategory.tool, provider })
expect(typeof api.getCredentialSchema).toBe('function')
const schemaUrl = api.getCredentialSchema('api-key' as never)
expect(schemaUrl).toBe(
@@ -37,7 +37,7 @@ describe('useGetApi', () => {
})
it('includes OAuth client endpoints', () => {
- const api = useGetApi({ category: AuthCategory.tool, provider })
+ const api = getApi({ category: AuthCategory.tool, provider })
expect(api.getOauthClientSchema).toBe(
`/workspaces/current/tool-provider/builtin/${provider}/oauth/client-schema`,
)
@@ -49,7 +49,7 @@ describe('useGetApi', () => {
describe('datasource category', () => {
it('returns correct API paths for datasource category', () => {
- const api = useGetApi({ category: AuthCategory.datasource, provider })
+ const api = getApi({ category: AuthCategory.datasource, provider })
expect(api.getCredentials).toBe(`/auth/plugin/datasource/${provider}`)
expect(api.addCredential).toBe(`/auth/plugin/datasource/${provider}`)
expect(api.updateCredential).toBe(`/auth/plugin/datasource/${provider}/update`)
@@ -59,19 +59,19 @@ describe('useGetApi', () => {
})
it('returns empty string for getCredentialInfo', () => {
- const api = useGetApi({ category: AuthCategory.datasource, provider })
+ const api = getApi({ category: AuthCategory.datasource, provider })
expect(api.getCredentialInfo).toBe('')
})
it('returns a function for getCredentialSchema that returns empty string', () => {
- const api = useGetApi({ category: AuthCategory.datasource, provider })
+ const api = getApi({ category: AuthCategory.datasource, provider })
expect(api.getCredentialSchema(CredentialTypeEnum.API_KEY)).toBe('')
})
})
describe('other categories', () => {
it('returns empty strings as fallback for unsupported category', () => {
- const api = useGetApi({ category: AuthCategory.model, provider })
+ const api = getApi({ category: AuthCategory.model, provider })
expect(api.getCredentialInfo).toBe('')
expect(api.setDefaultCredential).toBe('')
expect(api.getCredentials).toBe('')
@@ -82,14 +82,14 @@ describe('useGetApi', () => {
})
it('returns a function for getCredentialSchema that returns empty string', () => {
- const api = useGetApi({ category: AuthCategory.model, provider })
+ const api = getApi({ category: AuthCategory.model, provider })
expect(api.getCredentialSchema(CredentialTypeEnum.API_KEY)).toBe('')
})
})
describe('default category', () => {
it('defaults to tool category when category is not specified', () => {
- const api = useGetApi({ provider } as { category: AuthCategory; provider: string })
+ const api = getApi({ provider } as { category: AuthCategory; provider: string })
expect(api.getCredentialInfo).toContain('tool-provider')
})
})
diff --git a/web/app/components/plugins/plugin-auth/hooks/use-get-api.ts b/web/app/components/plugins/plugin-auth/hooks/get-api.ts
similarity index 96%
rename from web/app/components/plugins/plugin-auth/hooks/use-get-api.ts
rename to web/app/components/plugins/plugin-auth/hooks/get-api.ts
index 0eb18ebdd13..959476cf437 100644
--- a/web/app/components/plugins/plugin-auth/hooks/use-get-api.ts
+++ b/web/app/components/plugins/plugin-auth/hooks/get-api.ts
@@ -1,7 +1,7 @@
import type { CredentialTypeEnum, PluginPayload } from '../types'
import { AuthCategory } from '../types'
-export const useGetApi = ({ category = AuthCategory.tool, provider }: PluginPayload) => {
+export const getApi = ({ category = AuthCategory.tool, provider }: PluginPayload) => {
if (category === AuthCategory.tool) {
return {
getCredentialInfo: `/workspaces/current/tool-provider/builtin/${provider}/credential/info`,
diff --git a/web/app/components/plugins/plugin-auth/hooks/use-credential.ts b/web/app/components/plugins/plugin-auth/hooks/use-credential.ts
index a9150a50cb4..40995dc8d4d 100644
--- a/web/app/components/plugins/plugin-auth/hooks/use-credential.ts
+++ b/web/app/components/plugins/plugin-auth/hooks/use-credential.ts
@@ -15,14 +15,14 @@ import {
useSetPluginOAuthCustomClient,
useUpdatePluginCredential,
} from '@/service/use-plugins-auth'
-import { useGetApi } from './use-get-api'
+import { getApi } from './get-api'
export const useGetPluginCredentialInfoHook = (
pluginPayload: PluginPayload,
enable?: boolean,
includeCredentialIds?: string[],
) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
const ids = (includeCredentialIds ?? []).filter(Boolean)
let url = enable ? apiMap.getCredentialInfo : ''
if (url && ids.length > 0) {
@@ -34,13 +34,13 @@ export const useGetPluginCredentialInfoHook = (
}
export const useDeletePluginCredentialHook = (pluginPayload: PluginPayload) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
return useDeletePluginCredential(apiMap.deleteCredential)
}
export const useInvalidPluginCredentialInfoHook = (pluginPayload: PluginPayload) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
const invalidPluginCredentialInfo = useInvalidPluginCredentialInfo(apiMap.getCredentialInfo)
const queryClient = useQueryClient()
const toolListQueryKey = getToolListQueryKey(pluginPayload.providerType)
@@ -52,7 +52,7 @@ export const useInvalidPluginCredentialInfoHook = (pluginPayload: PluginPayload)
}
export const useSetPluginDefaultCredentialHook = (pluginPayload: PluginPayload) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
return useSetPluginDefaultCredential(apiMap.setDefaultCredential)
}
@@ -61,49 +61,49 @@ export const useGetPluginCredentialSchemaHook = (
pluginPayload: PluginPayload,
credentialType: CredentialTypeEnum,
) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
return useGetPluginCredentialSchema(apiMap.getCredentialSchema(credentialType))
}
export const useAddPluginCredentialHook = (pluginPayload: PluginPayload) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
return useAddPluginCredential(apiMap.addCredential)
}
export const useUpdatePluginCredentialHook = (pluginPayload: PluginPayload) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
return useUpdatePluginCredential(apiMap.updateCredential)
}
export const useGetPluginOAuthUrlHook = (pluginPayload: PluginPayload) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
return useGetPluginOAuthUrl(apiMap.getOauthUrl)
}
export const useGetPluginOAuthClientSchemaHook = (pluginPayload: PluginPayload, enabled = true) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
return useGetPluginOAuthClientSchema(enabled ? apiMap.getOauthClientSchema : '')
}
export const useInvalidPluginOAuthClientSchemaHook = (pluginPayload: PluginPayload) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
return useInvalidPluginOAuthClientSchema(apiMap.getOauthClientSchema)
}
export const useSetPluginOAuthCustomClientHook = (pluginPayload: PluginPayload) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
return useSetPluginOAuthCustomClient(apiMap.setCustomOauthClient)
}
export const useDeletePluginOAuthCustomClientHook = (pluginPayload: PluginPayload) => {
- const apiMap = useGetApi(pluginPayload)
+ const apiMap = getApi(pluginPayload)
return useDeletePluginOAuthCustomClient(apiMap.deleteCustomOAuthClient)
}
diff --git a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/__tests__/hooks.spec.ts b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/__tests__/hooks.spec.ts
index 6e7be1f00e8..39f362de361 100644
--- a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/__tests__/hooks.spec.ts
+++ b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/__tests__/hooks.spec.ts
@@ -11,7 +11,7 @@ vi.mock('@tanstack/react-query', async (importOriginal) => {
})
vi.mock('@/app/components/base/file-uploader/hooks', () => ({
- useFileSizeLimit: () => ({
+ getFileSizeLimit: () => ({
imgSizeLimit: 10 * 1024 * 1024,
docSizeLimit: 15 * 1024 * 1024,
audioSizeLimit: 50 * 1024 * 1024,
diff --git a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/hooks.ts b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/hooks.ts
index 2051b621613..35bda7e7bf0 100644
--- a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/hooks.ts
+++ b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/hooks.ts
@@ -4,7 +4,7 @@ import type { InputFieldConfiguration } from '@/app/components/base/form/form-sc
import { useQuery } from '@tanstack/react-query'
import { useCallback, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
-import { useFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
+import { getFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
import { InputFieldType } from '@/app/components/base/form/form-scenarios/input-field/types'
import { DEFAULT_FILE_UPLOAD_SETTING } from '@/app/components/workflow/constants'
import { PipelineInputVarType } from '@/models/pipeline'
@@ -220,7 +220,7 @@ export const useHiddenConfigurations = (props: { options: string[] | undefined }
const { data: fileUploadConfigResponse } = useQuery(consoleQuery.files.upload.get.queryOptions())
const { imgSizeLimit, docSizeLimit, audioSizeLimit, videoSizeLimit } =
- useFileSizeLimit(fileUploadConfigResponse)
+ getFileSizeLimit(fileUploadConfigResponse)
const defaultSelectOptions = useMemo(() => {
if (options) {
diff --git a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.tsx b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.tsx
index df0dc6e3594..fed6f63530b 100644
--- a/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.tsx
+++ b/web/app/components/rag-pipeline/components/panel/input-field/editor/form/index.tsx
@@ -5,7 +5,7 @@ import { Separator } from '@langgenius/dify-ui/separator'
import { useQuery } from '@tanstack/react-query'
import { useCallback, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
+import { getFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
import { useAppForm } from '@/app/components/base/form'
import { ChangeType } from '@/app/components/workflow/types'
import { toast } from '@/app/notifications'
@@ -24,7 +24,7 @@ const InputFieldForm = ({
}: InputFieldFormProps) => {
const { t } = useTranslation(['appDebug', 'common'])
const { data: fileUploadConfigResponse } = useQuery(consoleQuery.files.upload.get.queryOptions())
- const { maxFileUploadLimit } = useFileSizeLimit(fileUploadConfigResponse)
+ const { maxFileUploadLimit } = getFileSizeLimit(fileUploadConfigResponse)
const inputFieldForm = useAppForm({
defaultValues: initialData,
validators: {
diff --git a/web/app/components/workflow/nodes/_base/components/__tests__/file-support.spec.tsx b/web/app/components/workflow/nodes/_base/components/__tests__/file-support.spec.tsx
index 7c5446ee6e3..1967d60d018 100644
--- a/web/app/components/workflow/nodes/_base/components/__tests__/file-support.spec.tsx
+++ b/web/app/components/workflow/nodes/_base/components/__tests__/file-support.spec.tsx
@@ -2,7 +2,7 @@ import type { UploadFileSetting } from '@/app/components/workflow/types'
import { fireEvent, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { useState } from 'react'
-import { useFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
+import { getFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
import { TransferMethod } from '@/types/app'
import FileTypeItem from '../file-type-item'
@@ -20,10 +20,10 @@ vi.mock('@tanstack/react-query', async (importOriginal) => {
})
const mockUseFileUploadConfig = mockFileUploadConfigHook
-const mockUseFileSizeLimit = vi.mocked(useFileSizeLimit)
+const mockGetFileSizeLimit = vi.mocked(getFileSizeLimit)
vi.mock('@/app/components/base/file-uploader/hooks', () => ({
- useFileSizeLimit: vi.fn(),
+ getFileSizeLimit: vi.fn(),
}))
vi.mock('@/app/notifications', () => ({
@@ -49,13 +49,13 @@ describe('File upload support components', () => {
mockUseFileUploadConfig.mockReturnValue({ data: {} } as ReturnType<
typeof mockFileUploadConfigHook
>)
- mockUseFileSizeLimit.mockReturnValue({
+ mockGetFileSizeLimit.mockReturnValue({
imgSizeLimit: 10 * 1024 * 1024,
docSizeLimit: 20 * 1024 * 1024,
audioSizeLimit: 30 * 1024 * 1024,
videoSizeLimit: 40 * 1024 * 1024,
maxFileUploadLimit: 10,
- } as ReturnType<typeof useFileSizeLimit>)
+ } as ReturnType<typeof getFileSizeLimit>)
})
describe('FileTypeItem', () => {
diff --git a/web/app/components/workflow/nodes/_base/components/file-upload-setting.tsx b/web/app/components/workflow/nodes/_base/components/file-upload-setting.tsx
index 6572d6cbcc9..1af990ff6ee 100644
--- a/web/app/components/workflow/nodes/_base/components/file-upload-setting.tsx
+++ b/web/app/components/workflow/nodes/_base/components/file-upload-setting.tsx
@@ -11,7 +11,7 @@ import * as React from 'react'
import { useCallback, useId } from 'react'
import { useTranslation } from 'react-i18next'
import Field from '@/app/components/app/configuration/config-var/config-modal/field'
-import { useFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
+import { getFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
import { consoleQuery } from '@/service/console'
import { TransferMethod } from '@/types/app'
import { formatFileSize } from '@/utils/format'
@@ -53,7 +53,7 @@ const FileUploadSetting: FC<Props> = ({
} = payload
const { data: fileUploadConfigResponse } = useQuery(consoleQuery.files.upload.get.queryOptions())
const { imgSizeLimit, docSizeLimit, audioSizeLimit, videoSizeLimit, maxFileUploadLimit } =
- useFileSizeLimit(fileUploadConfigResponse)
+ getFileSizeLimit(fileUploadConfigResponse)
const handleSupportFileTypeChange = useCallback(
(type: SupportUploadFileTypes) => {
diff --git a/web/app/components/workflow/nodes/_base/components/variable/variable-label/hooks.ts b/web/app/components/workflow/nodes/_base/components/variable/variable-label/hooks.ts
index 7577eb06edd..01925ec9444 100644
--- a/web/app/components/workflow/nodes/_base/components/variable/variable-label/hooks.ts
+++ b/web/app/components/workflow/nodes/_base/components/variable/variable-label/hooks.ts
@@ -81,7 +81,7 @@ export const useVarName = (variables: string[], notShowFullPath?: boolean) => {
return varName
}
-export const useVarBgColorInEditor = (variables: string[], hasError?: boolean) => {
+export const getVarBgColorInEditor = (variables: string[], hasError?: boolean) => {
if (hasError) {
return {
hoverBorderColor: 'hover:border-state-destructive-active',
diff --git a/web/app/components/workflow/nodes/_base/components/variable/variable-label/variable-label-in-editor.tsx b/web/app/components/workflow/nodes/_base/components/variable/variable-label/variable-label-in-editor.tsx
index 5b4a9395dd1..161cfd49b5d 100644
--- a/web/app/components/workflow/nodes/_base/components/variable/variable-label/variable-label-in-editor.tsx
+++ b/web/app/components/workflow/nodes/_base/components/variable/variable-label/variable-label-in-editor.tsx
@@ -2,7 +2,7 @@ import type { VariablePayload } from './types'
import { cn } from '@langgenius/dify-ui/cn'
import { memo } from 'react'
import VariableLabel from './base/variable-label'
-import { useVarBgColorInEditor } from './hooks'
+import { getVarBgColorInEditor } from './hooks'
type VariableLabelInEditorProps = {
isSelected?: boolean
@@ -14,7 +14,7 @@ const VariableLabelInEditor = ({
...rest
}: VariableLabelInEditorProps) => {
const { hoverBorderColor, hoverBgColor, selectedBorderColor, selectedBgColor } =
- useVarBgColorInEditor(variables, !!errorMsg)
+ getVarBgColorInEditor(variables, !!errorMsg)
return (
<VariableLabel
diff --git a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts
index 72f5e76521f..ae11a5fbd9e 100644
--- a/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts
+++ b/web/app/components/workflow/nodes/_base/components/workflow-panel/last-run/use-last-run.ts
@@ -69,7 +69,7 @@ const singleRunFormParamsHooks: Record<BlockEnum, any> = {
[BlockEnum.TriggerPlugin]: undefined,
}
-const useSingleRunFormParamsHooks = (nodeType: BlockEnum) => {
+const createSingleRunFormParamsHook = (nodeType: BlockEnum) => {
return (params: any) => {
return singleRunFormParamsHooks[nodeType]?.(params) || {}
}
@@ -110,7 +110,7 @@ const getDataForCheckMoreHooks: Record<BlockEnum, any> = {
[BlockEnum.TriggerPlugin]: useTriggerPluginGetDataForCheckMore,
}
-const useGetDataForCheckMoreHooks = <T>(nodeType: BlockEnum) => {
+const createGetDataForCheckMoreHook = <T>(nodeType: BlockEnum) => {
return (id: string, payload: CommonNodeType<T>) => {
return (
getDataForCheckMoreHooks[nodeType]?.({ id, payload }) || {
@@ -133,7 +133,8 @@ const useLastRun = <T>({ ...oneStepRunParams }: Params<T>) => {
const isCustomRunNode = isSupportCustomRunForm(blockType)
const isHumanInputNode = blockType === BlockEnum.HumanInput
const { handleSyncWorkflowDraft } = useNodesSyncDraft()
- const { getData: getDataForCheckMore } = useGetDataForCheckMoreHooks<T>(blockType)(
+ const useGetDataForCheckMore = createGetDataForCheckMoreHook<T>(blockType)
+ const { getData: getDataForCheckMore } = useGetDataForCheckMore(
oneStepRunParams.id,
oneStepRunParams.data,
)
@@ -177,7 +178,8 @@ const useLastRun = <T>({ ...oneStepRunParams }: Params<T>) => {
} = oneStepRunRes
const nodeInfo = runResult
- const { ...singleRunParams } = useSingleRunFormParamsHooks(blockType)({
+ const useSingleRunFormParams = createSingleRunFormParamsHook(blockType)
+ const { ...singleRunParams } = useSingleRunFormParams({
id,
payload: data,
runInputData,
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx
index a0619acdd70..7222d52130b 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/files/upload-dialog.tsx
@@ -22,7 +22,7 @@ import { IconButton } from '@langgenius/dify-ui/icon-button'
import { useMutation, useQuery } from '@tanstack/react-query'
import { useRef, useState } from 'react'
import { useTranslation } from 'react-i18next'
-import { useFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
+import { getFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
import { getSupportFileType } from '@/app/components/base/file-uploader/utils'
import { SupportUploadFileTypes } from '@/app/components/workflow/types'
import { toast } from '@/app/notifications'
@@ -53,7 +53,7 @@ function AgentFileUploader({ file, onChange }: { file?: File; onChange: (file?:
const { t: tCommon } = useTranslation(['common'])
const { data: fileUploadConfig } = useQuery(consoleQuery.files.upload.get.queryOptions())
const { imgSizeLimit, docSizeLimit, audioSizeLimit, videoSizeLimit } =
- useFileSizeLimit(fileUploadConfig)
+ getFileSizeLimit(fileUploadConfig)
const fileInputRef = useRef<HTMLInputElement>(null)
const dragDepthRef = useRef(0)
const [dragging, setDragging] = useState(false)
diff --git a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx
index 20f3f0e89c1..b666e04d314 100644
--- a/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx
+++ b/web/features/agent-v2/agent-detail/configure/components/orchestrate/skills/upload-dialog.tsx
@@ -18,7 +18,7 @@ import { IconButton } from '@langgenius/dify-ui/icon-button'
import { useMutation, useQuery } from '@tanstack/react-query'
import { useRef, useState } from 'react'
import { Trans, useTranslation } from 'react-i18next'
-import { useFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
+import { getFileSizeLimit } from '@/app/components/base/file-uploader/hooks'
import { toast } from '@/app/notifications'
import Link from '@/next/link'
import { consoleQuery } from '@/service/console'
@@ -71,7 +71,7 @@ function AgentSkillPackageUploader({
const { t } = useTranslation(['agentV2'])
const { t: tCommon } = useTranslation(['common'])
const { data: fileUploadConfig } = useQuery(consoleQuery.files.upload.get.queryOptions())
- const { skillSizeLimit } = useFileSizeLimit(fileUploadConfig)
+ const { skillSizeLimit } = getFileSizeLimit(fileUploadConfig)
const fileInputRef = useRef<HTMLInputElement>(null)
const dragDepthRef = useRef(0)
const [dragging, setDragging] = useState(false)