mirror of
https://github.com/chenasraf/nextcloud-forum.git
synced 2026-05-17 17:28:02 +00:00
fix: add/update error notifications across the app
This commit is contained in:
@@ -59,6 +59,7 @@ import NcLoadingIcon from '@nextcloud/vue/components/NcLoadingIcon'
|
||||
import NcTextField from '@nextcloud/vue/components/NcTextField'
|
||||
import NcTextArea from '@nextcloud/vue/components/NcTextArea'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
import { ocs } from '@/axios'
|
||||
import type { CatHeader } from '@/types'
|
||||
|
||||
@@ -177,9 +178,10 @@ export default defineComponent({
|
||||
|
||||
this.$emit('saved', savedHeader)
|
||||
this.$emit('update:open', false)
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to save header', e)
|
||||
// TODO: Show error notification
|
||||
const message = e?.response?.data?.error || e?.response?.data?.message || e?.message || ''
|
||||
showError(t('forum', 'Failed to save header') + (message ? `: ${message}` : ''))
|
||||
} finally {
|
||||
this.submitting = false
|
||||
}
|
||||
|
||||
@@ -160,6 +160,7 @@ import TextBoxIcon from '@icons/TextBox.vue'
|
||||
import ArrowDownIcon from '@icons/ArrowDown.vue'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
import { ocs } from '@/axios'
|
||||
import type { Template } from '@/types'
|
||||
|
||||
@@ -354,8 +355,9 @@ export default defineComponent({
|
||||
this.currentView = 'list'
|
||||
this.editingTemplate = null
|
||||
await this.fetchTemplates()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to save template:', e)
|
||||
showError(t('forum', 'Failed to save template'))
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
@@ -373,8 +375,9 @@ export default defineComponent({
|
||||
if (this.currentPage > this.totalPages) {
|
||||
this.currentPage = this.totalPages
|
||||
}
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to delete template:', e)
|
||||
showError(t('forum', 'Failed to delete template'))
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -988,7 +988,7 @@ export default defineComponent({
|
||||
if (replyForm && typeof replyForm.setSubmitting === 'function') {
|
||||
replyForm.setSubmitting(false)
|
||||
}
|
||||
// TODO: Show error notification
|
||||
showError(t('forum', 'Failed to submit reply'))
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -277,6 +277,7 @@ import PageHeader from '@/components/PageHeader'
|
||||
import AppToolbar from '@/components/AppToolbar'
|
||||
import { ocs } from '@/axios'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
|
||||
interface BBCode {
|
||||
id: number
|
||||
@@ -471,9 +472,9 @@ export default defineComponent({
|
||||
|
||||
this.editDialog.show = false
|
||||
this.refresh()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to save BBCode', e)
|
||||
// TODO: Show error notification
|
||||
showError(t('forum', 'Failed to save BBCode'))
|
||||
} finally {
|
||||
this.editDialog.submitting = false
|
||||
}
|
||||
@@ -485,9 +486,9 @@ export default defineComponent({
|
||||
enabled: !bbcode.enabled,
|
||||
})
|
||||
this.refresh()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to toggle BBCode', e)
|
||||
// TODO: Show error notification
|
||||
showError(t('forum', 'Failed to toggle BBCode'))
|
||||
}
|
||||
},
|
||||
|
||||
@@ -503,9 +504,9 @@ export default defineComponent({
|
||||
await ocs.delete(`/bbcodes/${this.deleteDialog.bbcode.id}`)
|
||||
this.deleteDialog.show = false
|
||||
this.refresh()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to delete BBCode', e)
|
||||
// TODO: Show error notification
|
||||
showError(t('forum', 'Failed to delete BBCode'))
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -239,6 +239,7 @@ import NcTextArea from '@nextcloud/vue/components/NcTextArea'
|
||||
import ArrowLeftIcon from '@icons/ArrowLeft.vue'
|
||||
import { ocs } from '@/axios'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
import { isAdminRole, isModeratorRole, isDefaultRole, isGuestRole } from '@/constants'
|
||||
import { useCategories } from '@/composables/useCategories'
|
||||
import type { Category, CategoryPerm, CatHeader, Role, Team } from '@/types'
|
||||
@@ -796,9 +797,10 @@ export default defineComponent({
|
||||
|
||||
// Navigate back to category list
|
||||
this.$router.push('/admin/categories')
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to save category', e)
|
||||
// TODO: Show error notification
|
||||
const message = e?.response?.data?.error || e?.response?.data?.message || e?.message || ''
|
||||
showError(t('forum', 'Failed to save category') + (message ? `: ${message}` : ''))
|
||||
} finally {
|
||||
this.submitting = false
|
||||
}
|
||||
|
||||
@@ -351,6 +351,7 @@ import DeleteIcon from '@icons/Delete.vue'
|
||||
import InformationIcon from '@icons/Information.vue'
|
||||
import { ocs } from '@/axios'
|
||||
import { t, n } from '@nextcloud/l10n'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
import { useCategories } from '@/composables/useCategories'
|
||||
import type { CategoryHeader, Category, CatHeader } from '@/types'
|
||||
|
||||
@@ -559,9 +560,9 @@ export default defineComponent({
|
||||
|
||||
this.deleteDialog.show = false
|
||||
this.refresh()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to delete category', e)
|
||||
// TODO: Show error notification
|
||||
showError(t('forum', 'Failed to delete category'))
|
||||
}
|
||||
},
|
||||
|
||||
@@ -619,9 +620,9 @@ export default defineComponent({
|
||||
|
||||
this.deleteHeaderDialog.show = false
|
||||
this.refresh()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to delete header', e)
|
||||
// TODO: Show error notification
|
||||
showError(t('forum', 'Failed to delete header'))
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ import SortCalendarDescendingIcon from '@icons/SortCalendarDescending.vue'
|
||||
import SortCalendarAscendingIcon from '@icons/SortCalendarAscending.vue'
|
||||
import { ocs } from '@/axios'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
|
||||
let debounceTimer: ReturnType<typeof setTimeout> | null = null
|
||||
|
||||
@@ -211,8 +212,9 @@ export default defineComponent({
|
||||
this.restoring = id
|
||||
await ocs.post(`/moderation/threads/${id}/restore`)
|
||||
await this.loadData()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to restore thread', e)
|
||||
showError(t('forum', 'Failed to restore thread'))
|
||||
} finally {
|
||||
this.restoring = null
|
||||
}
|
||||
@@ -223,8 +225,9 @@ export default defineComponent({
|
||||
this.restoring = id
|
||||
await ocs.post(`/moderation/replies/${id}/restore`)
|
||||
await this.loadData()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to restore reply', e)
|
||||
showError(t('forum', 'Failed to restore reply'))
|
||||
} finally {
|
||||
this.restoring = null
|
||||
}
|
||||
|
||||
@@ -229,6 +229,7 @@ import CategoryPermissionsTable, {
|
||||
} from '@/components/CategoryPermissionsTable'
|
||||
import { ocs } from '@/axios'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
import { isAdminRole, isGuestRole, isDefaultRole, systemRoleFallbackColors } from '@/constants'
|
||||
import { usePublicSettings } from '@/composables/usePublicSettings'
|
||||
import type { Role, CategoryHeader } from '@/types'
|
||||
@@ -607,9 +608,9 @@ export default defineComponent({
|
||||
|
||||
// Navigate back to role list
|
||||
this.$router.push('/admin/roles')
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to save role', e)
|
||||
// TODO: Show error notification
|
||||
showError(t('forum', 'Failed to save role'))
|
||||
} finally {
|
||||
this.submitting = false
|
||||
}
|
||||
|
||||
@@ -186,6 +186,7 @@ import PageHeader from '@/components/PageHeader'
|
||||
import AppToolbar from '@/components/AppToolbar'
|
||||
import { ocs } from '@/axios'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
import type { Role, Team } from '@/types'
|
||||
|
||||
export default defineComponent({
|
||||
@@ -342,9 +343,9 @@ export default defineComponent({
|
||||
try {
|
||||
await ocs.delete(`/roles/${roleId}`)
|
||||
await this.refresh()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to delete role', e)
|
||||
// TODO: Show error notification
|
||||
showError(t('forum', 'Failed to delete role'))
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -153,6 +153,7 @@ import PageWrapper from '@/components/PageWrapper'
|
||||
import PageHeader from '@/components/PageHeader'
|
||||
import { ocs } from '@/axios'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import { showError } from '@nextcloud/dialogs'
|
||||
import { isGuestRole } from '@/constants'
|
||||
import type { Role } from '@/types'
|
||||
|
||||
@@ -330,9 +331,9 @@ export default defineComponent({
|
||||
}
|
||||
|
||||
this.cancelEdit()
|
||||
} catch (e) {
|
||||
} catch (e: any) {
|
||||
console.error('Failed to save roles', e)
|
||||
// TODO: Show error notification
|
||||
showError(t('forum', 'Failed to save roles'))
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user