mirror of
https://github.com/langgenius/dify.git
synced 2026-05-06 10:28:10 +08:00
feat(web): add sandbox mode check for MCP tool availability
Extend MCP tool availability context to include sandbox mode check alongside version support. MCP tools are now blocked when sandbox is disabled, with appropriate tooltip messages for each blocking condition.
This commit is contained in:
@ -192,10 +192,11 @@ type RenderOptions = {
|
||||
availableNodes?: Node[]
|
||||
nodeId?: string
|
||||
versionSupported?: boolean
|
||||
sandboxEnabled?: boolean
|
||||
}
|
||||
|
||||
const renderComponent = (options: RenderOptions = {}) => {
|
||||
const { versionSupported, ...overrides } = options
|
||||
const { versionSupported, sandboxEnabled, ...overrides } = options
|
||||
const defaultProps = {
|
||||
disabled: false,
|
||||
value: [],
|
||||
@ -216,7 +217,10 @@ const renderComponent = (options: RenderOptions = {}) => {
|
||||
return {
|
||||
...render(
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<MCPToolAvailabilityProvider versionSupported={versionSupported}>
|
||||
<MCPToolAvailabilityProvider
|
||||
versionSupported={versionSupported}
|
||||
sandboxEnabled={sandboxEnabled}
|
||||
>
|
||||
<MultipleToolSelector {...props} />
|
||||
</MCPToolAvailabilityProvider>
|
||||
</QueryClientProvider>,
|
||||
@ -447,6 +451,23 @@ describe('MultipleToolSelector', () => {
|
||||
expect(screen.getByText('1/2')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should not count MCP tools when sandbox is disabled', () => {
|
||||
// Arrange
|
||||
const mcpTools = [createMCPTool({ id: 'mcp-provider' })]
|
||||
mockMCPToolsData.mockReturnValue(mcpTools)
|
||||
|
||||
const tools = [
|
||||
createToolValue({ tool_name: 'tool-1', provider_name: 'regular-provider', enabled: true }),
|
||||
createToolValue({ tool_name: 'mcp-tool', provider_name: 'mcp-provider', enabled: true }),
|
||||
]
|
||||
|
||||
// Act
|
||||
renderComponent({ value: tools, sandboxEnabled: false })
|
||||
|
||||
// Assert
|
||||
expect(screen.getByText('1/2')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('should manage open state for add tool panel', () => {
|
||||
// Arrange
|
||||
const { container } = renderComponent()
|
||||
|
||||
Reference in New Issue
Block a user