Skip to content

Commit 8baa8e8

Browse files
committed
fix: simplify condition for copying tool in ToolListContainer
1 parent 754cb89 commit 8baa8e8

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

ui/src/locales/lang/en-US/views/tool.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export default {
99
editDataSourceTool: 'Edit Data Source',
1010
editMcpTool: 'Edit MCP',
1111
copyTool: 'Copy Tool',
12+
copyMcpTool: 'Copy MCP',
13+
copyDataSource: 'Copy Data Source',
1214
importTool: 'Import Tool',
1315
settingTool: 'Set Tool',
1416
mcpConfig: 'MCP Service Config',

ui/src/locales/lang/zh-CN/views/tool.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export default {
99
editDataSourceTool: '编辑数据源',
1010
editMcpTool: '编辑MCP',
1111
copyTool: '复制工具',
12+
copyMcpTool: '复制MCP',
13+
copyDataSource: '复制数据源',
1214
importTool: '导入工具',
1315
settingTool: '设置工具',
1416
mcpConfig: 'MCP服务配置',

ui/src/locales/lang/zh-Hant/views/tool.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export default {
99
editDataSourceTool: '編輯資料來源',
1010
editMcpTool: '編輯MCP',
1111
copyTool: '複製工具',
12+
copyMcpTool: '複製MCP',
13+
copyDataSource: '複製資料來源',
1214
importTool: '匯入工具',
1315
settingTool: '設定工具',
1416
mcpConfig: 'MCP服務配置',

ui/src/views/tool/component/ToolListContainer.vue

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@
204204
</el-dropdown-item>
205205
<el-dropdown-item v-if="
206206
!item.template_id &&
207-
permissionPrecise.copy(item.id) &&
208-
item.tool_type !== 'MCP'
207+
permissionPrecise.copy(item.id)
209208
" @click.stop="copyTool(item)">
210209
<AppIcon iconName="app-copy" class="color-secondary"></AppIcon>
211210
{{ $t('common.copy') }}
@@ -540,6 +539,18 @@ async function changeState(row: any) {
540539
}
541540
542541
async function copyTool(row: any) {
542+
// mcp工具
543+
if (row?.tool_type === 'MCP') {
544+
bus.emit('select_node', row.folder_id)
545+
await copyMcpTool(row)
546+
return
547+
}
548+
// 数据源工具
549+
if (row?.tool_type === 'DATA_SOURCE') {
550+
bus.emit('select_node', row.folder_id)
551+
await copyDataSource(row)
552+
return
553+
}
543554
ToolDrawertitle.value = t('views.tool.copyTool')
544555
const res = await loadSharedApi({ type: 'tool', systemType: apiType.value }).getToolById(
545556
row.id,
@@ -551,6 +562,30 @@ async function copyTool(row: any) {
551562
ToolFormDrawerRef.value.open(obj)
552563
}
553564
565+
async function copyMcpTool(row: any) {
566+
McpToolDrawertitle.value = t('views.tool.copyMcpTool')
567+
const res = await loadSharedApi({ type: 'tool', systemType: apiType.value }).getToolById(
568+
row.id,
569+
changeStateloading,
570+
)
571+
const obj = cloneDeep(res.data)
572+
delete obj['id']
573+
obj['name'] = obj['name'] + ` ${t('common.copyTitle')}`
574+
McpToolFormDrawerRef.value.open(obj)
575+
}
576+
577+
async function copyDataSource(row: any) {
578+
DataSourceToolDrawertitle.value = t('views.tool.copyDataSource')
579+
const res = await loadSharedApi({ type: 'tool', systemType: apiType.value }).getToolById(
580+
row.id,
581+
changeStateloading,
582+
)
583+
const obj = cloneDeep(res.data)
584+
delete obj['id']
585+
obj['name'] = obj['name'] + ` ${t('common.copyTitle')}`
586+
DataSourceToolFormDrawerRef.value.open(obj)
587+
}
588+
554589
function exportTool(row: any) {
555590
loadSharedApi({ type: 'tool', systemType: apiType.value })
556591
.exportTool(row.id, row.name, loading)

0 commit comments

Comments
 (0)