Skip to content

Commit 233e190

Browse files
author
Lasim
committed
refactor: optimize step position calculations and remove debug logging in MCP server data conversion
1 parent 903cc05 commit 233e190

File tree

4 files changed

+34
-50
lines changed

4 files changed

+34
-50
lines changed

services/frontend/src/components/admin/mcp-catalog/McpServerAddFormWizard.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ const steps = [
8686
const progressSteps = computed(() => {
8787
return steps.map((step, index) => {
8888
let status: 'completed' | 'current' | 'pending' | 'error' = 'pending'
89-
89+
9090
if (index < currentStep.value) {
9191
status = 'completed'
9292
} else if (index === currentStep.value) {
9393
status = 'current'
9494
}
95-
95+
9696
// Check for errors
9797
if (index === 0 && githubFetchError.value) {
9898
status = 'error'
9999
}
100-
100+
101101
return {
102102
id: step.key,
103103
label: step.label,
@@ -130,7 +130,7 @@ const progressTitle = computed(() => {
130130
if (githubFetchError.value) {
131131
return t('mcpCatalog.form.errors.githubFetch')
132132
}
133-
133+
134134
const currentStepData = steps[currentStep.value]
135135
return `${currentStepData.label} - ${t('mcpCatalog.form.steps.configuring')}`
136136
})
@@ -256,6 +256,7 @@ const goToStep = (stepIndex: number) => {
256256
}
257257
258258
// Handle step click from ProgressBars
259+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
259260
const handleStepClick = (step: any, index: number) => {
260261
if (step.clickable) {
261262
goToStep(index)

services/frontend/src/components/admin/mcp-catalog/McpServerEditFormWizard.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,18 @@ const steps = [
7979
const progressSteps = computed(() => {
8080
return steps.map((step, index) => {
8181
let status: 'completed' | 'current' | 'pending' | 'error' = 'pending'
82-
82+
8383
if (index < currentStep.value) {
8484
status = 'completed'
8585
} else if (index === currentStep.value) {
8686
status = 'current'
8787
}
88-
88+
8989
// Check for errors
9090
if (index === 0 && githubFetchError.value) {
9191
status = 'error'
9292
}
93-
93+
9494
return {
9595
id: step.key,
9696
label: step.label,
@@ -106,15 +106,15 @@ const progressPercentage = computed(() => {
106106
// For 5 steps: 0%, 25%, 50%, 75%, 100%
107107
const totalSteps = steps.length
108108
if (totalSteps <= 1) return 0
109-
109+
110110
const progressIncrement = 100 / (totalSteps - 1)
111111
return currentStep.value * progressIncrement
112112
})
113113
114114
// Progress title based on current step
115115
const progressTitle = computed(() => {
116116
if (isSubmitting.value) {
117-
return props.mode === 'edit'
117+
return props.mode === 'edit'
118118
? t('mcpCatalog.form.navigation.updating')
119119
: t('mcpCatalog.form.navigation.creating')
120120
}
@@ -124,7 +124,7 @@ const progressTitle = computed(() => {
124124
if (githubFetchError.value) {
125125
return t('mcpCatalog.form.errors.githubFetch')
126126
}
127-
127+
128128
const currentStepData = steps[currentStep.value]
129129
return `${currentStepData.label} - ${t('mcpCatalog.form.steps.configuring')}`
130130
})
@@ -250,6 +250,7 @@ const goToStep = (stepIndex: number) => {
250250
}
251251
252252
// Handle step click from ProgressBars
253+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
253254
const handleStepClick = (step: any, index: number) => {
254255
if (step.clickable) {
255256
goToStep(index)

services/frontend/src/components/ui/progress-bars/ProgressBars.vue

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -158,28 +158,29 @@ const stepVariants = cva(
158158
159159
const clampedProgress = computed(() => Math.max(0, Math.min(100, props.progress)))
160160
161-
const gridCols = computed(() => {
162-
const stepCount = props.steps.length
163-
if (stepCount <= 2) return 'grid-cols-2'
164-
if (stepCount <= 3) return 'grid-cols-3'
165-
if (stepCount <= 4) return 'grid-cols-4'
166-
if (stepCount <= 5) return 'grid-cols-5'
167-
if (stepCount <= 6) return 'grid-cols-6'
168-
return 'grid-cols-6' // Max 6 columns for readability
169-
})
161+
// Calculate the exact position percentage for each step
162+
function getStepPosition(index: number) {
163+
const totalSteps = props.steps.length
164+
if (totalSteps <= 1) return 50 // Center if only one step
165+
166+
// Calculate position as percentage (0% to 100%)
167+
return (index / (totalSteps - 1)) * 100
168+
}
170169
171170
function handleStepClick(step: ProgressStep, index: number) {
172171
if (props.interactive && step.clickable) {
173172
emit('stepClick', step, index)
174173
}
175174
}
176175
177-
function getStepAlignment(index: number) {
178-
const totalSteps = props.steps.length
179-
if (totalSteps <= 1) return 'text-center'
180-
if (index === 0) return 'text-left'
181-
if (index === totalSteps - 1) return 'text-right'
182-
return 'text-center'
176+
// Get transform style to center text on the exact position
177+
function getStepTransform(index: number) {
178+
const position = getStepPosition(index)
179+
180+
// Adjust transform to center the text on the position
181+
if (position === 0) return 'translateX(0%)' // First step: no adjustment needed
182+
if (position === 100) return 'translateX(-100%)' // Last step: move completely left
183+
return 'translateX(-50%)' // Middle steps: center on position
183184
}
184185
</script>
185186

@@ -215,10 +216,7 @@ function getStepAlignment(index: number) {
215216
<!-- Steps -->
216217
<div
217218
v-if="showSteps && steps.length > 0"
218-
:class="[
219-
'hidden sm:grid gap-2 text-sm font-medium',
220-
gridCols
221-
]"
219+
class="hidden sm:block relative w-full pt-2"
222220
>
223221
<button
224222
v-for="(step, index) in steps"
@@ -230,8 +228,12 @@ function getStepAlignment(index: number) {
230228
status: step.status,
231229
clickable: interactive && step.clickable
232230
})),
233-
getStepAlignment(index)
231+
'absolute text-sm font-medium whitespace-nowrap'
234232
]"
233+
:style="{
234+
left: `${getStepPosition(index)}%`,
235+
transform: getStepTransform(index)
236+
}"
235237
@click="handleStepClick(step, index)"
236238
>
237239
{{ step.label }}

services/frontend/src/views/admin/mcp-server-catalog/edit/[id].vue

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -150,28 +150,8 @@ const convertServerToFormData = (server: McpServer): Partial<McpServerFormData>
150150
const parsedResources = parseJsonField(server.resources, [])
151151
const parsedPrompts = parseJsonField(server.prompts, [])
152152
153-
// Parse environment variables with robust handling
154153
const parsedEnvironmentVariables = parseEnvironmentVariables(server.environment_variables)
155154
156-
// Debug logging to help troubleshoot
157-
console.log('Server data conversion:', {
158-
serverId: server.id,
159-
rawEnvironmentVariables: server.environment_variables,
160-
parsedEnvironmentVariables,
161-
environmentVariablesType: typeof server.environment_variables,
162-
environmentVariablesLength: parsedEnvironmentVariables.length,
163-
isArray: Array.isArray(server.environment_variables),
164-
rawLength: server.environment_variables?.length
165-
})
166-
167-
// Additional debug logging for capabilities
168-
console.log('Capabilities data being set:', {
169-
environment_variables: parsedEnvironmentVariables,
170-
tools: parsedTools,
171-
resources: parsedResources,
172-
prompts: parsedPrompts
173-
})
174-
175155
return {
176156
basic: {
177157
name: server.name || '',

0 commit comments

Comments
 (0)