Skip to content

Commit f1f03e9

Browse files
committed
refactor: simplify ToolStoreDialog by removing unused toolType logic
1 parent c4fd921 commit f1f03e9

File tree

1 file changed

+15
-36
lines changed

1 file changed

+15
-36
lines changed

ui/src/views/tool/toolStore/ToolStoreDialog.vue

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
<h4 :id="titleId" class="medium w-240 mr-8">
1414
{{ $t('views.tool.toolStore.title') }}
1515
</h4>
16-
<el-radio-group v-model="toolType" @change="radioChange" class="app-radio-button-group">
17-
<el-radio-button value="TOOL">{{$t('views.tool.title')}}</el-radio-button>
18-
<el-radio-button value="DATA_SOURCE">{{$t('views.tool.dataSource')}}</el-radio-button>
19-
</el-radio-group>
2016

2117
<div class="flex align-center" style="margin-right: 28px">
2218
<el-input
@@ -125,7 +121,6 @@ const dialogVisible = ref(false)
125121
const loading = ref(false)
126122
const searchValue = ref('')
127123
const folderId = ref('')
128-
const toolType = ref('TOOL')
129124
const defaultCategories = ref<ToolCategory[]>([
130125
{
131126
id: 'web_search',
@@ -142,12 +137,6 @@ const categories = ref<ToolCategory[]>([...defaultCategories.value])
142137
143138
const filterList = ref<any>(null)
144139
145-
watch(dialogVisible, (bool) => {
146-
if (!bool) {
147-
toolType.value = 'TOOL'
148-
}
149-
})
150-
151140
function getSubTitle(tool: any) {
152141
return categories.value.find((i) => i.id === tool.label)?.title ?? ''
153142
}
@@ -162,32 +151,22 @@ function open(id: string) {
162151
163152
async function getList() {
164153
filterList.value = null
165-
if (toolType.value === 'DATA_SOURCE') {
166-
categories.value = [
167-
{
168-
id: 'data_source',
169-
title: t('views.tool.dataSource'),
170-
tools: [],
171-
},
172-
]
173-
} else {
174-
const [v1, v2] = await Promise.all([
175-
getInternalToolList(),
176-
getStoreToolList()
177-
])
178-
179-
const merged = [...v1, ...v2].reduce((acc, category) => {
180-
const existing = acc.find((item: any) => item.id === category.id)
181-
if (existing) {
182-
existing.tools = [...existing.tools, ...category.tools]
183-
} else {
184-
acc.push({...category})
185-
}
186-
return acc
187-
}, [] as ToolCategory[])
154+
const [v1, v2] = await Promise.all([
155+
getInternalToolList(),
156+
getStoreToolList()
157+
])
158+
159+
const merged = [...v1, ...v2].reduce((acc, category) => {
160+
const existing = acc.find((item: any) => item.id === category.id)
161+
if (existing) {
162+
existing.tools = [...existing.tools, ...category.tools]
163+
} else {
164+
acc.push({...category})
165+
}
166+
return acc
167+
}, [] as ToolCategory[])
188168
189-
categories.value = merged
190-
}
169+
categories.value = merged
191170
}
192171
193172
async function getInternalToolList() {

0 commit comments

Comments
 (0)