Skip to content

Commit a9fce7e

Browse files
author
Lasim
committed
feat(frontend): add loading state and error handling to form submissions
1 parent 361ea9b commit a9fce7e

File tree

7 files changed

+46
-28
lines changed

7 files changed

+46
-28
lines changed

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,15 +226,6 @@ const canSubmit = computed(() => {
226226
canProceedFromClaudeConfig.value
227227
})
228228
229-
// Dynamic button text based on props or defaults
230-
const submitText = computed(() => {
231-
if (props.submitButtonText) return props.submitButtonText
232-
if (isSubmitting.value) {
233-
return t('mcpCatalog.form.navigation.creating')
234-
}
235-
return t('mcpCatalog.form.navigation.submit')
236-
})
237-
238229
const cancelText = computed(() => {
239230
return props.cancelButtonText || t('mcpCatalog.form.navigation.cancel')
240231
})
@@ -361,14 +352,14 @@ const submitForm = async () => {
361352
isSubmitting.value = true
362353
submitError.value = null
363354
364-
// Emit the form data to parent component
365-
emit('submit', formData.value)
355+
// Emit the form data to parent component and wait for completion
356+
await emit('submit', formData.value)
366357
367358
} catch (error) {
368359
submitError.value = error instanceof Error ? error.message : 'Failed to submit form'
369-
} finally {
370360
isSubmitting.value = false
371361
}
362+
// Note: isSubmitting will be reset by parent after successful redirect
372363
}
373364
374365
// Form persistence using event bus
@@ -482,9 +473,11 @@ onUnmounted(() => {
482473
<Button
483474
v-else
484475
@click="submitForm"
485-
:disabled="!canSubmit || isSubmitting"
476+
:disabled="!canSubmit"
477+
:loading="isSubmitting"
478+
:loading-text="t('mcpCatalog.form.navigation.creating')"
486479
>
487-
{{ submitText }}
480+
{{ t('mcpCatalog.form.navigation.submit') }}
488481
</Button>
489482
</div>
490483
</div>

services/frontend/src/components/admin/mcp-categories/CategoryModal.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,12 +295,11 @@ const handleSortOrderChange = () => {
295295
</Button>
296296
<Button
297297
type="submit"
298-
:disabled="!isFormValid || isSubmitting"
298+
:disabled="!isFormValid"
299+
:loading="isSubmitting"
300+
:loading-text="t('mcpCategories.modal.saving')"
299301
>
300-
{{ isSubmitting
301-
? t('mcpCategories.modal.saving')
302-
: (isEditing ? t('mcpCategories.modal.update') : t('mcpCategories.modal.create'))
303-
}}
302+
{{ isEditing ? t('mcpCategories.modal.update') : t('mcpCategories.modal.create') }}
304303
</Button>
305304
</AlertDialogFooter>
306305
</form>

services/frontend/src/views/ForgotPassword.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,13 @@ const navigateToLogin = () => {
196196
</FormItem>
197197
</FormField>
198198

199-
<Button type="submit" class="w-full" :disabled="isLoading">
200-
{{ isLoading ? $t('forgotPassword.buttons.loading') : $t('forgotPassword.buttons.submit') }}
199+
<Button
200+
type="submit"
201+
class="w-full"
202+
:loading="isLoading"
203+
:loading-text="$t('forgotPassword.buttons.loading')"
204+
>
205+
{{ $t('forgotPassword.buttons.submit') }}
201206
</Button>
202207
</form>
203208
</CardContent>

services/frontend/src/views/Login.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,13 @@ onMounted(async () => {
271271
</FormItem>
272272
</FormField>
273273

274-
<Button type="submit" class="w-full" :disabled="isLoading">
275-
{{ isLoading ? $t('login.buttons.loading') : $t('login.buttons.submit') }}
274+
<Button
275+
type="submit"
276+
class="w-full"
277+
:loading="isLoading"
278+
:loading-text="$t('login.buttons.loading')"
279+
>
280+
{{ $t('login.buttons.submit') }}
276281
</Button>
277282
</form>
278283

services/frontend/src/views/Register.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,8 +377,13 @@ onMounted(async () => {
377377
</FormItem>
378378
</FormField>
379379

380-
<Button type="submit" class="w-full mt-6" :disabled="isLoading">
381-
{{ isLoading ? $t('register.buttons.loading') : $t('register.buttons.submit') }}
380+
<Button
381+
type="submit"
382+
class="w-full mt-6"
383+
:loading="isLoading"
384+
:loading-text="$t('register.buttons.loading')"
385+
>
386+
{{ $t('register.buttons.submit') }}
382387
</Button>
383388
</form>
384389

services/frontend/src/views/ResetPassword.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,13 @@ onMounted(() => {
250250
</FormItem>
251251
</FormField>
252252

253-
<Button type="submit" class="w-full" :disabled="isLoading">
254-
{{ isLoading ? $t('resetPassword.buttons.loading') : $t('resetPassword.buttons.submit') }}
253+
<Button
254+
type="submit"
255+
class="w-full"
256+
:loading="isLoading"
257+
:loading-text="$t('resetPassword.buttons.loading')"
258+
>
259+
{{ $t('resetPassword.buttons.submit') }}
255260
</Button>
256261
</form>
257262
</CardContent>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,13 @@ const handleSubmit = async (formData: McpServerAddFormData) => {
117117
await router.push('/admin/mcp-server-catalog')
118118
119119
} catch (error) {
120-
// Re-throw error to let the wizard handle it
120+
// Show error toast
121+
const errorMessage = error instanceof Error ? error.message : 'Failed to create MCP server'
122+
toast.error(t('mcpCatalog.messages.createError'), {
123+
description: errorMessage
124+
})
125+
126+
// Re-throw error to let the wizard handle it and reset loading state
121127
throw error
122128
}
123129
}

0 commit comments

Comments
 (0)