Skip to content

Commit 4fe6ad3

Browse files
committed
fix(frontend): prevent value loss when changing argument category to template
When editing an argument in the MCP catalog Configuration Schema step and changing its category from team/user to template, the argument value would disappear and become uneditable, causing the table to display empty cells. This fix adds: - Value input field in ConfigItemModal with conditional visibility - Auto-population logic that sets value=name when changing to template - Validation to ensure template items have required values - Enhanced i18n translations for value field help text and placeholders The watcher automatically fills the value field when switching to template category while still allowing manual editing for cases where the value differs from the name (e.g., package-name vs @org/package).
1 parent 3de872a commit 4fe6ad3

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

services/frontend/src/components/admin/mcp-catalog/steps/ConfigurationSchemaStepAdd.vue

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,13 @@ const validateForm = () => {
742742
}
743743
}
744744
745+
// Validate value field for template items
746+
if (formDataLocal.value.category === 'template') {
747+
if (!formDataLocal.value.value || !formDataLocal.value.value.trim()) {
748+
errors.value = t('mcpCatalog.form.configurationSchema.modal.validation.valueRequired')
749+
}
750+
}
751+
745752
formErrors.value = errors
746753
return Object.keys(errors).length === 0
747754
}
@@ -984,6 +991,32 @@ watch(localData, () => {
984991
})
985992
}
986993
}, { deep: true })
994+
995+
// Watch for category changes to auto-populate value for template arguments
996+
watch(() => formDataLocal.value.category, (newCategory, oldCategory) => {
997+
// When changing TO template category
998+
if (newCategory === 'template' && oldCategory !== 'template') {
999+
// For arguments: auto-populate value with name if value is empty
1000+
if (formDataLocal.value.type === 'arg' && !formDataLocal.value.value) {
1001+
formDataLocal.value.value = formDataLocal.value.name
1002+
}
1003+
// For env/headers/query params: keep existing value or leave empty for user to fill
1004+
1005+
// Always lock template items by default
1006+
formDataLocal.value.locked = true
1007+
}
1008+
1009+
// When changing FROM template to team/user
1010+
if (oldCategory === 'template' && newCategory !== 'template') {
1011+
// Unlock the item (team/user items can be unlocked)
1012+
formDataLocal.value.locked = false
1013+
1014+
// For arguments: clear the value (team/user args don't need pre-filled values)
1015+
if (formDataLocal.value.type === 'arg') {
1016+
formDataLocal.value.value = ''
1017+
}
1018+
}
1019+
})
9871020
</script>
9881021

9891022
<template>

services/frontend/src/components/admin/mcp-catalog/steps/ConfigurationSchemaStepAdd/ConfigItemModal.vue

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,43 @@ const updateFormField = (field: keyof ConfigItem, value: any) => {
111111
</div>
112112
</div>
113113

114+
<!-- Value Field (for template items and editing) -->
115+
<div v-if="formData.category === 'template' || formData.type === 'arg'" class="space-y-2">
116+
<Label for="item-value">
117+
{{ $t('mcpCatalog.form.configurationSchema.modal.fields.value.label') }}
118+
<span v-if="formData.category !== 'template'" class="text-muted-foreground text-xs ml-2">
119+
({{ $t('mcpCatalog.form.configurationSchema.modal.fields.value.optionalForTeamUser') }})
120+
</span>
121+
</Label>
122+
<Input
123+
id="item-value"
124+
:model-value="formData.value"
125+
@update:model-value="(value) => updateFormField('value', value)"
126+
:placeholder="
127+
formData.type === 'arg'
128+
? $t('mcpCatalog.form.configurationSchema.modal.fields.value.placeholderArg')
129+
: formData.type === 'env'
130+
? $t('mcpCatalog.form.configurationSchema.modal.fields.value.placeholderEnv')
131+
: formData.type === 'header'
132+
? $t('mcpCatalog.form.configurationSchema.modal.fields.value.placeholderHeader')
133+
: $t('mcpCatalog.form.configurationSchema.modal.fields.value.placeholderQueryParam')
134+
"
135+
:class="{ 'border-destructive': formErrors.value }"
136+
class="font-mono"
137+
:required="formData.category === 'template'"
138+
/>
139+
<div v-if="formErrors.value" class="text-sm text-destructive">
140+
{{ formErrors.value }}
141+
</div>
142+
<p class="text-sm text-muted-foreground">
143+
{{
144+
formData.category === 'template'
145+
? $t('mcpCatalog.form.configurationSchema.modal.fields.value.helpTextTemplate')
146+
: $t('mcpCatalog.form.configurationSchema.modal.fields.value.helpTextTeamUser')
147+
}}
148+
</p>
149+
</div>
150+
114151
<!-- Category -->
115152
<div class="space-y-2">
116153
<Label for="item-category">{{ $t('mcpCatalog.form.configurationSchema.modal.fields.category.label') }}</Label>

services/frontend/src/i18n/locales/en/mcp-catalog.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,14 @@ export default {
305305
},
306306
value: {
307307
label: 'Value',
308-
placeholder: 'Example: --verbose or package-name'
308+
optionalForTeamUser: 'optional for team/user items',
309+
placeholder: 'Enter value',
310+
placeholderArg: 'e.g., -y, --transport, stdio',
311+
placeholderEnv: 'e.g., 1.0, production, true',
312+
placeholderHeader: 'e.g., application/json, Bearer token',
313+
placeholderQueryParam: 'e.g., api-key-value, true',
314+
helpTextTemplate: 'This value will be locked and passed to the MCP server at runtime',
315+
helpTextTeamUser: 'Optional: Set a default value for this configuration item'
309316
},
310317
category: {
311318
label: 'Category',
@@ -334,7 +341,7 @@ export default {
334341
validation: {
335342
nameRequired: 'Name is required',
336343
nameExists: 'Name already exists for this type',
337-
valueRequired: 'Value is required for template arguments'
344+
valueRequired: 'Value is required for template items'
338345
}
339346
}
340347
},

0 commit comments

Comments
 (0)