22/* eslint-disable @typescript-eslint/no-explicit-any */
33import { ref , computed , watch } from ' vue'
44import { useI18n } from ' vue-i18n'
5- import { Settings , Eye , EyeOff , Info } from ' lucide-vue-next'
5+ import { Settings , Eye , EyeOff } from ' lucide-vue-next'
66import { Button } from ' @/components/ui/button'
77import { Input } from ' @/components/ui/input'
88import { Textarea } from ' @/components/ui/textarea'
99import { Label } from ' @/components/ui/label'
10- import { Badge } from ' @/components/ui/badge'
1110import { Card , CardDescription , CardHeader , CardTitle } from ' @/components/ui/card'
12- import { Alert , AlertDescription } from ' @/components/ui/alert'
13- import {
14- Tooltip ,
15- TooltipContent ,
16- TooltipProvider ,
17- TooltipTrigger ,
18- } from ' @/components/ui/tooltip'
1911
2012// Props and model
2113const modelValue = defineModel <Record <string , string >>({ required: true })
2214
2315interface Props {
2416 serverData? : any
17+ variables? : any []
2518}
2619
2720const props = defineProps <Props >()
@@ -38,10 +31,16 @@ const showPasswords = ref<Record<string, boolean>>({})
3831
3932// Computed
4033const environmentVariables = computed (() => {
34+ // First try the variables prop (passed from EnvironmentVariablesStep)
35+ if (props .variables && props .variables .length > 0 ) {
36+ return props .variables
37+ }
38+ // Fallback to serverData.environment_variables
4139 if (! props .serverData ?.environment_variables ) return []
4240 return props .serverData .environment_variables
4341})
4442
43+
4544const hasRequiredVariables = computed (() => {
4645 return environmentVariables .value .some ((env : any ) => env .required )
4746})
@@ -147,11 +146,11 @@ watch(modelValue, () => {
147146 // Validation will be triggered by the validationState watcher
148147}, { deep: true })
149148
150- // Watch for server data changes to reset form
151- watch (() => props . serverData , (newData ) => {
152- if (newData ?. environment_variables ) {
149+ // Watch for environment variables changes to initialize form values
150+ watch (() => environmentVariables . value , (newVariables ) => {
151+ if (newVariables && newVariables . length > 0 ) {
153152 const newValues: Record <string , string > = {}
154- newData . environment_variables .forEach ((env : any ) => {
153+ newVariables .forEach ((env : any ) => {
155154 // Keep existing values if they exist
156155 if (modelValue .value [env .name ] !== undefined ) {
157156 newValues [env .name ] = modelValue .value [env .name ]
@@ -171,16 +170,6 @@ watch(() => props.serverData, (newData) => {
171170
172171<template >
173172 <div class =" space-y-6" >
174- <!-- Step Header -->
175- <div >
176- <h2 class =" text-xl font-semibold text-gray-900 mb-2" >
177- {{ t('mcpInstallations.wizard.environment.title') }}
178- </h2 >
179- <p class =" text-gray-600" >
180- {{ t('mcpInstallations.wizard.environment.description') }}
181- </p >
182- </div >
183-
184173 <!-- No Environment Variables -->
185174 <div v-if =" !environmentVariables.length" class =" text-center py-8" >
186175 <Settings class =" h-12 w-12 text-gray-400 mx-auto mb-4" />
@@ -210,43 +199,19 @@ watch(() => props.serverData, (newData) => {
210199
211200 <!-- Required Variables -->
212201 <div v-if =" hasRequiredVariables" class =" space-y-4" >
213- <div class =" flex items-center gap-2" >
214- <h3 class =" text-lg font-medium text-gray-900" >
215- {{ t('mcpInstallations.wizard.environment.requiredVariables') }}
216- </h3 >
217- <Badge variant =" destructive" class =" text-xs" >
218- {{ t('labels.required') }}
219- </Badge >
220- </div >
202+ <h3 class =" text-lg font-medium text-gray-900" >
203+ {{ t('mcpInstallations.wizard.environment.requiredVariables') }}
204+ </h3 >
221205
222206 <div class =" space-y-4" >
223207 <div
224208 v-for =" env in requiredVariables"
225209 :key =" env.name"
226210 class =" space-y-2"
227211 >
228- <div class =" flex items-center gap-2" >
229- <Label :for =" env.name" class =" text-sm font-medium" >
230- {{ env.name }}
231- </Label >
232- <Badge variant =" destructive" class =" text-xs" >
233- {{ t('labels.required') }}
234- </Badge >
235-
236- <!-- Info tooltip -->
237- <TooltipProvider v-if =" env.description" >
238- <Tooltip >
239- <TooltipTrigger as-child >
240- <Button variant =" ghost" size =" sm" class =" h-4 w-4 p-0" >
241- <Info class =" h-3 w-3" />
242- </Button >
243- </TooltipTrigger >
244- <TooltipContent >
245- <p class =" max-w-xs" >{{ env.description }}</p >
246- </TooltipContent >
247- </Tooltip >
248- </TooltipProvider >
249- </div >
212+ <Label :for =" env.name" class =" text-sm font-medium" >
213+ {{ env.name }}
214+ </Label >
250215
251216 <!-- Textarea for long values -->
252217 <div v-if =" isTextarea(env)" class =" relative" >
@@ -295,43 +260,19 @@ watch(() => props.serverData, (newData) => {
295260
296261 <!-- Optional Variables -->
297262 <div v-if =" hasOptionalVariables" class =" space-y-4" >
298- <div class =" flex items-center gap-2" >
299- <h3 class =" text-lg font-medium text-gray-900" >
300- {{ t('mcpInstallations.wizard.environment.optionalVariables') }}
301- </h3 >
302- <Badge variant =" secondary" class =" text-xs" >
303- {{ t('labels.optional') }}
304- </Badge >
305- </div >
263+ <h3 class =" text-lg font-medium text-gray-900" >
264+ {{ t('mcpInstallations.wizard.environment.optionalVariables') }}
265+ </h3 >
306266
307267 <div class =" space-y-4" >
308268 <div
309269 v-for =" env in optionalVariables"
310270 :key =" env.name"
311271 class =" space-y-2"
312272 >
313- <div class =" flex items-center gap-2" >
314- <Label :for =" env.name" class =" text-sm font-medium" >
315- {{ env.name }}
316- </Label >
317- <Badge variant =" secondary" class =" text-xs" >
318- {{ t('labels.optional') }}
319- </Badge >
320-
321- <!-- Info tooltip -->
322- <TooltipProvider v-if =" env.description" >
323- <Tooltip >
324- <TooltipTrigger as-child >
325- <Button variant =" ghost" size =" sm" class =" h-4 w-4 p-0" >
326- <Info class =" h-3 w-3" />
327- </Button >
328- </TooltipTrigger >
329- <TooltipContent >
330- <p class =" max-w-xs" >{{ env.description }}</p >
331- </TooltipContent >
332- </Tooltip >
333- </TooltipProvider >
334- </div >
273+ <Label :for =" env.name" class =" text-sm font-medium" >
274+ {{ env.name }}
275+ </Label >
335276
336277 <!-- Textarea for long values -->
337278 <div v-if =" isTextarea(env)" class =" relative" >
@@ -376,13 +317,6 @@ watch(() => props.serverData, (newData) => {
376317 </div >
377318 </div >
378319
379- <!-- Help Text -->
380- <Alert >
381- <Info class =" h-4 w-4" />
382- <AlertDescription >
383- {{ t('mcpInstallations.wizard.environment.helpText') }}
384- </AlertDescription >
385- </Alert >
386320 </div >
387321 </div >
388322</template >
0 commit comments