Skip to content

Commit 206a356

Browse files
author
Lasim
committed
chore(frontend): update button loading states and improve form submission handling
1 parent 0e18eb7 commit 206a356

File tree

5 files changed

+26
-14
lines changed

5 files changed

+26
-14
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/frontend/src/components/globalSettings/GitHubAppSettings.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,13 @@ function getSetting(key: string) {
178178
<Button
179179
type="button"
180180
@click="handleTestConnection"
181-
:disabled="!canTestConnection || isTestingConnection"
181+
:disabled="!canTestConnection"
182+
:loading="isTestingConnection"
182183
variant="outline"
183184
size="sm"
184185
>
185186
<TestTube class="h-4 w-4 mr-2" />
186-
{{ isTestingConnection ? t('githubApp.connectionTest.button.testing') : t('githubApp.connectionTest.button.test') }}
187+
{{ t('githubApp.connectionTest.button.test') }}
187188
</Button>
188189
</div>
189190

@@ -226,10 +227,11 @@ function getSetting(key: string) {
226227
</div>
227228
<Button
228229
type="submit"
229-
:disabled="!hasChanges || isSaving"
230+
:disabled="!hasChanges"
231+
:loading="isSaving"
230232
class="min-w-[120px]"
231233
>
232-
{{ isSaving ? t('githubApp.form.saving') : t('githubApp.form.saveChanges') }}
234+
{{ t('githubApp.form.saveChanges') }}
233235
</Button>
234236
</div>
235237
</form>

services/frontend/src/components/globalSettings/SmtpSettings.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,14 @@ function getSetting(key: string) {
298298
<Button
299299
type="button"
300300
@click="handleTestEmail"
301-
:disabled="!canTestConnection || isTestingConnection"
301+
:disabled="!canTestConnection"
302+
:loading="isTestingConnection"
302303
variant="outline"
303304
size="sm"
304305
class="w-full sm:w-auto"
305306
>
306307
<TestTube class="h-4 w-4 mr-2" />
307-
{{ isTestingConnection ? t('smtp.emailTest.button.testing') : t('smtp.emailTest.button.test') }}
308+
{{ t('smtp.emailTest.button.test') }}
308309
</Button>
309310

310311
<!-- Test Status -->
@@ -349,10 +350,11 @@ function getSetting(key: string) {
349350
</div>
350351
<Button
351352
type="submit"
352-
:disabled="!hasChanges || isSaving"
353+
:disabled="!hasChanges"
354+
:loading="isSaving"
353355
class="min-w-[120px]"
354356
>
355-
{{ isSaving ? t('smtp.form.saving') : t('smtp.form.saveChanges') }}
357+
{{ t('smtp.form.saveChanges') }}
356358
</Button>
357359
</div>
358360
</form>

services/frontend/src/components/ui/button/Button.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ const spinnerSize = computed(() => {
4747
>
4848
<Loader2
4949
v-if="loading"
50-
:class="cn(spinnerSize, 'animate-spin')"
50+
:class="cn(spinnerSize, 'animate-spin mr-2')"
5151
/>
5252
<template v-if="loading && loadingText">
5353
{{ loadingText }}
5454
</template>
55-
<slot v-else-if="!loading" />
55+
<slot v-else />
5656
</Primitive>
5757
</template>

services/frontend/src/views/admin/settings/[type].vue

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ const route = useRoute()
2626
const settingGroups = ref<GlobalSettingGroup[]>([])
2727
const isLoading = ref(true)
2828
const error = ref<string | null>(null)
29+
const isSubmitting = ref(false)
2930
3031
const apiUrl = getEnv('VITE_DEPLOYSTACK_BACKEND_URL') || '' // Fallback to empty string if not set
3132
@@ -194,6 +195,8 @@ async function handleSubmit(event: Event) {
194195
}
195196
})
196197
198+
isSubmitting.value = true
199+
197200
try {
198201
if (!apiUrl) {
199202
throw new Error(t('globalSettings.errors.savingConfigNotSet'))
@@ -254,6 +257,8 @@ async function handleSubmit(event: Event) {
254257
description: errorMessage
255258
})
256259
console.error('Failed to save settings:', err)
260+
} finally {
261+
isSubmitting.value = false
257262
}
258263
}
259264
</script>
@@ -329,9 +334,12 @@ async function handleSubmit(event: Event) {
329334
<p v-if="setting.is_encrypted" class="text-xs text-muted-foreground">{{ t('globalSettings.form.encryptedValue') }}</p>
330335
</div>
331336

332-
<Button type="submit">
333-
{{ t('globalSettings.form.saveChanges') }}
334-
</Button>
337+
<Button
338+
type="submit"
339+
:loading="isSubmitting"
340+
>
341+
{{ t('globalSettings.form.saveChanges') }}
342+
</Button>
335343
</form>
336344
<div v-else-if="selectedGroup && (!selectedGroup.settings || selectedGroup.settings.length === 0)">
337345
<p class="text-sm text-muted-foreground">{{ t('globalSettings.form.noSettings') }}</p>

0 commit comments

Comments
 (0)