Skip to content

Commit 5616f7f

Browse files
author
Lasim
committed
refactor(frontend): separate user args and env in user configuration
1 parent b021ddb commit 5616f7f

File tree

1 file changed

+45
-41
lines changed

1 file changed

+45
-41
lines changed

services/frontend/src/components/mcp-server/installation/UserConfiguration.vue

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ onMounted(async () => {
103103
104104
// Load user configurations
105105
await loadUserConfigurations()
106-
106+
107107
// Load user devices
108108
await loadUserDevices()
109109
} catch (error) {
@@ -170,7 +170,7 @@ const currentUserEnv = computed(() => {
170170
const userArgsWithData = computed(() => {
171171
return userArgsSchema.value.map((argSchema: any) => ({
172172
...argSchema,
173-
currentValue: currentUserEnv.value[argSchema.name] || ''
173+
currentValue: currentUserArgs.value[argSchema.name] || ''
174174
}))
175175
})
176176
@@ -201,9 +201,13 @@ const hasDevices = computed(() => {
201201
const getDeviceValue = (item: any, deviceId: string, type: 'arg' | 'env') => {
202202
const userConfig = userConfigurations.value.find(config => config.device_id === deviceId)
203203
if (!userConfig) return ''
204-
205-
// Both args and env are stored in user_env (args are named env vars)
206-
return userConfig.user_env?.[item.name] || ''
204+
205+
// Args and env are now properly separated
206+
if (type === 'arg') {
207+
return userConfig.user_args?.[item.name] || ''
208+
} else {
209+
return userConfig.user_env?.[item.name] || ''
210+
}
207211
}
208212
209213
// Modal functions
@@ -257,22 +261,22 @@ const validateForm = () => {
257261
258262
const handleEdit = async () => {
259263
if (!validateForm()) return
260-
264+
261265
isSubmitting.value = true
262-
266+
263267
try {
264268
// Find existing user config for this device
265269
let userConfig = userConfigurations.value.find(config => config.device_id === editingDevice.value.id)
266-
270+
267271
if (!userConfig) {
268272
// Create new user configuration for this device with only the specific field
269273
const createData: any = {
270274
device_id: editingDevice.value.id
271275
}
272-
276+
273277
if (editingType.value === 'arg') {
274-
// Create env object with the named argument (args are actually env vars)
275-
createData.user_env = {
278+
// Create args object with the named argument mapping
279+
createData.user_args = {
276280
[editingItem.value.name]: editingValue.value
277281
}
278282
} else {
@@ -281,68 +285,68 @@ const handleEdit = async () => {
281285
[editingItem.value.name]: editingValue.value
282286
}
283287
}
284-
288+
285289
userConfig = await McpInstallationService.createUserConfiguration(
286290
props.teamId,
287291
props.installation.id,
288292
createData
289293
)
290-
294+
291295
userConfigurations.value.push(userConfig)
292296
} else {
293297
// Update existing configuration with only the specific field
294298
const updateData: any = {
295299
device_id: editingDevice.value.id
296300
}
297-
301+
298302
if (editingType.value === 'arg') {
299-
// Update only the env vars object (args are actually env vars)
300-
const updatedEnv = { ...(userConfig.user_env || {}) }
301-
updatedEnv[editingItem.value.name] = editingValue.value
302-
updateData.user_env = updatedEnv
303+
// Update only the args object
304+
const updatedArgs = { ...(userConfig.user_args || {}) }
305+
updatedArgs[editingItem.value.name] = editingValue.value
306+
updateData.user_args = updatedArgs
303307
} else {
304308
// Update only the env vars object
305309
const updatedEnv = { ...(userConfig.user_env || {}) }
306310
updatedEnv[editingItem.value.name] = editingValue.value
307311
updateData.user_env = updatedEnv
308312
}
309-
313+
310314
// Update the configuration
311315
const updatedConfig = await McpInstallationService.updateUserConfiguration(
312316
props.teamId,
313317
props.installation.id,
314318
userConfig.id,
315319
updateData
316320
)
317-
321+
318322
// Update local state
319323
const configIndex = userConfigurations.value.findIndex(c => c.id === userConfig!.id)
320324
if (configIndex >= 0) {
321325
userConfigurations.value[configIndex] = updatedConfig
322326
}
323-
327+
324328
userConfig = updatedConfig
325329
}
326-
330+
327331
emit('configuration-updated', userConfig)
328-
332+
329333
// Show success toast
330334
toast.success(t('mcpInstallations.userConfiguration.editModal.messages.saveSuccess'), {
331335
description: t('mcpInstallations.userConfiguration.editModal.messages.saveSuccessDescription', {
332336
item: editingItem.value.name,
333337
device: editingDevice.value.device_name
334338
})
335339
})
336-
340+
337341
closeEditModal()
338342
} catch (error) {
339343
console.error('Error updating user configuration:', error)
340-
344+
341345
// Show error toast
342346
toast.error(t('mcpInstallations.userConfiguration.editModal.messages.saveError'), {
343347
description: error instanceof Error ? error.message : t('mcpInstallations.userConfiguration.editModal.messages.saveErrorDescription')
344348
})
345-
349+
346350
formErrors.value.general = error instanceof Error ? error.message : 'Failed to update configuration'
347351
} finally {
348352
isSubmitting.value = false
@@ -351,12 +355,12 @@ const handleEdit = async () => {
351355
352356
const modalTitle = computed(() => {
353357
if (!editingItem.value || !editingDevice.value) return ''
354-
358+
355359
const itemName = editingItem.value.name
356-
357-
return t('mcpInstallations.userConfiguration.editModal.title', {
358-
item: itemName,
359-
device: editingDevice.value.device_name
360+
361+
return t('mcpInstallations.userConfiguration.editModal.title', {
362+
item: itemName,
363+
device: editingDevice.value.device_name
360364
})
361365
})
362366
</script>
@@ -432,7 +436,7 @@ const modalTitle = computed(() => {
432436
</div>
433437
</div>
434438
</div>
435-
439+
436440
<!-- Device-specific values table -->
437441
<div v-if="hasDevices" class="w-full">
438442
<h5 class="text-xs font-medium text-gray-800 mb-2">{{ t('mcpInstallations.userConfiguration.deviceTable.title') }}</h5>
@@ -457,9 +461,9 @@ const modalTitle = computed(() => {
457461
{{ getDeviceValue(arg, device.id, 'arg') || t('mcpInstallations.userConfiguration.table.values.notSet') }}
458462
</TableCell>
459463
<TableCell>
460-
<Button
461-
size="sm"
462-
variant="outline"
464+
<Button
465+
size="sm"
466+
variant="outline"
463467
class="h-7 text-xs"
464468
@click="openEditModal(arg, device, 'arg')"
465469
>
@@ -519,7 +523,7 @@ const modalTitle = computed(() => {
519523
</div>
520524
</div>
521525
</div>
522-
526+
523527
<!-- Device-specific values table -->
524528
<div v-if="hasDevices" class="w-full">
525529
<h5 class="text-xs font-medium text-gray-800 mb-2">{{ t('mcpInstallations.userConfiguration.deviceTable.title') }}</h5>
@@ -549,9 +553,9 @@ const modalTitle = computed(() => {
549553
</span>
550554
</TableCell>
551555
<TableCell>
552-
<Button
553-
size="sm"
554-
variant="outline"
556+
<Button
557+
size="sm"
558+
variant="outline"
555559
class="h-7 text-xs"
556560
@click="openEditModal(envVar, device, 'env')"
557561
>
@@ -671,8 +675,8 @@ const modalTitle = computed(() => {
671675
<Button type="button" variant="outline" @click="closeEditModal">
672676
{{ t('mcpInstallations.userConfiguration.editModal.form.buttons.cancel') }}
673677
</Button>
674-
<Button
675-
type="submit"
678+
<Button
679+
type="submit"
676680
:loading="isSubmitting"
677681
:loadingText="t('mcpInstallations.userConfiguration.editModal.form.buttons.saving')"
678682
>

0 commit comments

Comments
 (0)