Skip to content

Commit 7fe7443

Browse files
author
Lasim
committed
feat(frontend): implement toast notifications for category actions
1 parent a9fce7e commit 7fe7443

File tree

1 file changed

+18
-20
lines changed
  • services/frontend/src/views/admin/mcp-categories

1 file changed

+18
-20
lines changed

services/frontend/src/views/admin/mcp-categories/index.vue

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { ref, onMounted, onUnmounted, computed } from 'vue'
33
import { useI18n } from 'vue-i18n'
4+
import { toast } from 'vue-sonner'
45
import { Input } from '@/components/ui/input'
56
import { Button } from '@/components/ui/button'
67
import { Plus } from 'lucide-vue-next'
@@ -9,8 +10,6 @@ import CategoryModal from '@/components/admin/mcp-categories/CategoryModal.vue'
910
import { McpCategoriesService, type McpCategory } from '@/services/mcpCategoriesService'
1011
import { useEventBus } from '@/composables/useEventBus'
1112
import CategoryTableColumns from './CategoryTableColumns.vue'
12-
import { Alert, AlertDescription } from '@/components/ui/alert'
13-
import { CheckCircle } from 'lucide-vue-next'
1413
1514
const { t } = useI18n()
1615
const eventBus = useEventBus()
@@ -20,7 +19,6 @@ const categories = ref<McpCategory[]>([])
2019
const isLoading = ref(true)
2120
const error = ref<string | null>(null)
2221
const searchQuery = ref('')
23-
const successMessage = ref<string | null>(null)
2422
const showAddModal = ref(false)
2523
const editingCategory = ref<McpCategory | null>(null)
2624
@@ -55,16 +53,16 @@ const handleDeleteCategory = async (categoryId: string) => {
5553
// Remove from local state
5654
categories.value = categories.value.filter(c => c.id !== categoryId)
5755
58-
// Show success message
59-
successMessage.value = t('mcpCategories.messages.deleteSuccess')
60-
setTimeout(() => {
61-
successMessage.value = null
62-
}, 5000)
56+
// Show success toast
57+
toast.success(t('mcpCategories.messages.deleteSuccess'))
6358
6459
// Emit global event
6560
eventBus.emit('mcp-categories-updated')
6661
} catch (err) {
67-
error.value = err instanceof Error ? err.message : 'Failed to delete category'
62+
const errorMessage = err instanceof Error ? err.message : 'Failed to delete category'
63+
toast.error(t('mcpCategories.messages.deleteError'), {
64+
description: errorMessage
65+
})
6866
}
6967
}
7068
@@ -76,8 +74,14 @@ const fetchCategories = async (forceRefresh = false): Promise<void> => {
7674
7775
categories.value = await McpCategoriesService.getCategories(forceRefresh)
7876
} catch (err) {
79-
error.value = err instanceof Error ? err.message : 'An unknown error occurred'
77+
const errorMessage = err instanceof Error ? err.message : 'An unknown error occurred'
78+
error.value = errorMessage
8079
categories.value = []
80+
81+
// Show error toast for fetch failures
82+
toast.error(t('mcpCategories.messages.fetchError'), {
83+
description: errorMessage
84+
})
8185
} finally {
8286
isLoading.value = false
8387
}
@@ -86,12 +90,12 @@ const fetchCategories = async (forceRefresh = false): Promise<void> => {
8690
// Handle category creation/update success
8791
const handleCategorySuccess = (action: 'created' | 'updated') => {
8892
fetchCategories(true)
89-
successMessage.value = action === 'created'
93+
94+
// Show success toast
95+
const message = action === 'created'
9096
? t('mcpCategories.messages.createSuccess')
9197
: t('mcpCategories.messages.updateSuccess')
92-
setTimeout(() => {
93-
successMessage.value = null
94-
}, 5000)
98+
toast.success(message)
9599
96100
// Emit global event
97101
eventBus.emit('mcp-categories-updated')
@@ -130,12 +134,6 @@ onUnmounted(() => {
130134
</Button>
131135
</div>
132136

133-
<!-- Success Message -->
134-
<Alert v-if="successMessage" class="border-green-200 bg-green-50 text-green-800">
135-
<CheckCircle class="h-4 w-4" />
136-
<AlertDescription>{{ successMessage }}</AlertDescription>
137-
</Alert>
138-
139137
<!-- Loading State -->
140138
<div v-if="isLoading" class="text-muted-foreground">
141139
{{ t('mcpCategories.table.loading') }}

0 commit comments

Comments
 (0)