Skip to content

Commit 1090375

Browse files
author
Lasim
committed
refactor: implement server pre-selection in installation wizard and enhance UI with install button
1 parent 5f4882d commit 1090375

File tree

4 files changed

+85
-6
lines changed

4 files changed

+85
-6
lines changed

services/frontend/src/components/mcp-server/wizard/McpServerInstallWizard.vue

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,38 @@
22
/* eslint-disable @typescript-eslint/no-explicit-any */
33
import { ref, computed, onMounted } from 'vue'
44
import { useI18n } from 'vue-i18n'
5+
import { useRoute } from 'vue-router'
56
import { Button } from '@/components/ui/button'
67
import { ProgressBars } from '@/components/ui/progress-bars'
78
import { Alert, AlertDescription } from '@/components/ui/alert'
89
import { Server, Settings, Cloud, Loader2 } from 'lucide-vue-next'
910
import { McpInstallationService } from '@/services/mcpInstallationService'
1011
import { TeamService } from '@/services/teamService'
12+
import { McpCatalogService } from '@/services/mcpCatalogService'
1113
import { useEventBus } from '@/composables/useEventBus'
1214
import McpServerSelectionStep from './McpServerSelectionStep.vue'
1315
import EnvironmentVariablesStep from './EnvironmentVariablesStep.vue'
1416
import PlatformSelectionStep from './PlatformSelectionStep.vue'
1517
18+
// Props
19+
interface Props {
20+
initialServerId?: string
21+
initialStep?: number
22+
}
23+
24+
withDefaults(defineProps<Props>(), {
25+
initialServerId: '',
26+
initialStep: 0
27+
})
28+
1629
// Emits
1730
const emit = defineEmits<{
1831
complete: [installationData: any]
1932
cancel: []
2033
}>()
2134
2235
const { t } = useI18n()
36+
const route = useRoute()
2337
const eventBus = useEventBus()
2438
2539
// Form data interface
@@ -63,13 +77,13 @@ const steps = [
6377
const progressSteps = computed(() => {
6478
return steps.map((step, index) => {
6579
let status: 'completed' | 'current' | 'pending' = 'pending'
66-
80+
6781
if (index < currentStep.value) {
6882
status = 'completed'
6983
} else if (index === currentStep.value) {
7084
status = 'current'
7185
}
72-
86+
7387
return {
7488
id: step.key,
7589
label: step.label,
@@ -157,7 +171,7 @@ const nextStep = () => {
157171
const previousStep = () => {
158172
if (canGoPrevious.value) {
159173
currentStep.value--
160-
174+
161175
// Reset form data when going back to previous steps
162176
if (currentStep.value === 0) {
163177
// Going back to server selection - clear server data
@@ -276,10 +290,51 @@ const handleValidationChange = (isValid: boolean, missingFields: string[]) => {
276290
}
277291
}
278292
293+
// Handle query parameters for pre-selection
294+
const handleQueryParameters = async () => {
295+
const serverId = route.query.serverId as string
296+
const step = route.query.step as string
297+
298+
if (serverId) {
299+
try {
300+
// Fetch server data from API
301+
const serverData = await McpCatalogService.getServerById(serverId)
302+
303+
if (serverData) {
304+
// Pre-populate form data
305+
formData.value.server.server_id = serverId
306+
formData.value.server.server_data = serverData
307+
308+
// Pre-populate environment variables with default values
309+
if (serverData.environment_variables) {
310+
serverData.environment_variables.forEach((env: any) => {
311+
if (env.placeholder && env.placeholder !== `<insert-your-${env.name.toLowerCase()}-here>`) {
312+
formData.value.environment.user_environment_variables[env.name] = env.placeholder
313+
} else {
314+
formData.value.environment.user_environment_variables[env.name] = ''
315+
}
316+
})
317+
}
318+
319+
// Set initial step if specified
320+
if (step === '2') {
321+
currentStep.value = 1 // Step 2 = index 1
322+
}
323+
}
324+
} catch (error) {
325+
console.error('Error loading server from query parameters:', error)
326+
submitError.value = 'Failed to load the selected server. Please try again.'
327+
}
328+
}
329+
}
330+
279331
onMounted(async () => {
280332
// Initialize team context
281333
await initializeTeamContext()
282334
335+
// Handle query parameters for pre-selection
336+
await handleQueryParameters()
337+
283338
// Listen for wizard reset events
284339
eventBus.on('mcp-install-wizard-reset', () => {
285340
currentStep.value = 0

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ export default {
167167
title: 'MCP Server: {name}',
168168
titleLoading: 'Loading MCP Server...',
169169
backToServers: 'Back to MCP Servers',
170+
installServer: 'Install MCP Server',
170171
loading: 'Loading server details...',
171172
errorLoading: 'Error loading server: {error}',
172173
serverInformation: 'Server Information',

services/frontend/src/views/mcp-server/add.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
import { onMounted } from 'vue'
3-
import { useRouter } from 'vue-router'
3+
import { useRouter, useRoute } from 'vue-router'
44
import { useI18n } from 'vue-i18n'
55
import { ArrowLeft } from 'lucide-vue-next'
66
import { Button } from '@/components/ui/button'
@@ -10,6 +10,7 @@ import McpServerInstallWizard from '@/components/mcp-server/wizard/McpServerInst
1010
1111
const { t } = useI18n()
1212
const router = useRouter()
13+
const route = useRoute()
1314
const eventBus = useEventBus()
1415
1516
@@ -65,6 +66,8 @@ onMounted(() => {
6566

6667
<!-- Wizard Component -->
6768
<McpServerInstallWizard
69+
:initial-server-id="route.query.serverId as string"
70+
:initial-step="route.query.step ? parseInt(route.query.step as string) - 1 : 0"
6871
@complete="handleWizardComplete"
6972
@cancel="handleWizardCancel"
7073
/>

services/frontend/src/views/mcp-server/view/[id].vue

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useRoute, useRouter } from 'vue-router'
44
import { useI18n } from 'vue-i18n'
55
import { Button } from '@/components/ui/button'
66
import { Badge } from '@/components/ui/badge'
7-
import { ArrowLeft, Github, ExternalLink, Star, Package, Code, Settings, Calendar, Tag } from 'lucide-vue-next'
7+
import { ArrowLeft, Github, ExternalLink, Star, Package, Code, Settings, Calendar, Tag, Download } from 'lucide-vue-next'
88
import DashboardLayout from '@/components/DashboardLayout.vue'
99
import EnvironmentVariablesDisplay from '@/components/admin/mcp-catalog/EnvironmentVariablesDisplay.vue'
1010
import { McpCatalogService } from '@/services/mcpCatalogService'
@@ -188,12 +188,23 @@ const formatDate = (dateString: string) => {
188188
const goBack = () => {
189189
router.push('/mcp-server')
190190
}
191+
192+
const installServer = () => {
193+
// Navigate to installation wizard with server pre-selected
194+
router.push({
195+
path: '/mcp-server/add',
196+
query: {
197+
serverId: serverId,
198+
step: '2'
199+
}
200+
})
201+
}
191202
</script>
192203

193204
<template>
194205
<DashboardLayout :title="server ? t('mcpInstallations.view.title', { name: server.name }) : t('mcpInstallations.view.titleLoading')">
195206
<div class="space-y-6">
196-
<!-- Header with Back Button -->
207+
<!-- Header with Back Button and Install Button -->
197208
<div class="flex items-center justify-between">
198209
<Button
199210
variant="outline"
@@ -202,6 +213,15 @@ const goBack = () => {
202213
<ArrowLeft class="h-4 w-4 mr-2" />
203214
{{ t('mcpInstallations.view.backToServers') }}
204215
</Button>
216+
217+
<Button
218+
v-if="server"
219+
@click="installServer"
220+
class="flex items-center gap-2"
221+
>
222+
<Download class="h-4 w-4" />
223+
{{ t('mcpInstallations.view.installServer') }}
224+
</Button>
205225
</div>
206226

207227
<!-- Loading State -->

0 commit comments

Comments
 (0)