feat: don't try to load task comments if they are disabled

This commit is contained in:
kolaente 2021-09-26 13:44:13 +02:00
parent 75f1a5a97f
commit e918b82cfa
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
2 changed files with 18 additions and 10 deletions

View file

@ -1,5 +1,5 @@
<template> <template>
<div class="content details"> <div class="content details" v-if="enabled">
<h3 v-if="canWrite || comments.length > 0"> <h3 v-if="canWrite || comments.length > 0">
<span class="icon is-grey"> <span class="icon is-grey">
<icon :icon="['far', 'comments']"/> <icon :icon="['far', 'comments']"/>
@ -141,8 +141,10 @@
<template #header><span>{{ $t('task.comment.delete') }}</span></template> <template #header><span>{{ $t('task.comment.delete') }}</span></template>
<template #text> <template #text>
<p>{{ $t('task.comment.deleteText1') }}<br/> <p>
<strong>{{ $t('task.comment.deleteText2') }}</strong></p> {{ $t('task.comment.deleteText1') }}<br/>
<strong>{{ $t('task.comment.deleteText2') }}</strong>
</p>
</template> </template>
</modal> </modal>
</transition> </transition>
@ -154,7 +156,8 @@ import TaskCommentService from '../../../services/taskComment'
import TaskCommentModel from '../../../models/taskComment' import TaskCommentModel from '../../../models/taskComment'
import LoadingComponent from '../../misc/loading' import LoadingComponent from '../../misc/loading'
import ErrorComponent from '../../misc/error' import ErrorComponent from '../../misc/error'
import { uploadFile } from '@/helpers/attachments' import {uploadFile} from '@/helpers/attachments'
import {mapState} from 'vuex'
export default { export default {
name: 'comments', name: 'comments',
@ -198,6 +201,10 @@ export default {
watch: { watch: {
taskId: { taskId: {
handler(taskId) { handler(taskId) {
if (!this.enabled) {
return
}
this.loadComments() this.loadComments()
this.newComment.taskId = taskId this.newComment.taskId = taskId
this.commentEdit.taskId = taskId this.commentEdit.taskId = taskId
@ -209,11 +216,10 @@ export default {
this.makeActions() this.makeActions()
}, },
}, },
computed: { computed: mapState({
userAvatar() { userAvatar: state => state.auth.info.getAvatarUrl(48),
return this.$store.state.auth.info.getAvatarUrl(48) enabled: state => state.config.taskCommentsEnabled,
}, }),
},
methods: { methods: {
attachmentUpload(...args) { attachmentUpload(...args) {
return uploadFile(this.taskId, ...args) return uploadFile(this.taskId, ...args)

View file

@ -25,6 +25,7 @@ export default {
}, },
caldavEnabled: false, caldavEnabled: false,
userDeletionEnabled: true, userDeletionEnabled: true,
taskCommentsEnabled: true,
auth: { auth: {
local: { local: {
enabled: true, enabled: true,
@ -52,6 +53,7 @@ export default {
state.legal.privacyPolicyUrl = config.legal.privacy_policy_url state.legal.privacyPolicyUrl = config.legal.privacy_policy_url
state.caldavEnabled = config.caldav_enabled state.caldavEnabled = config.caldav_enabled
state.userDeletionEnabled = config.user_deletion_enabled state.userDeletionEnabled = config.user_deletion_enabled
state.taskCommentsEnabled = config.task_comments_enabled
const auth = objectToCamelCase(config.auth) const auth = objectToCamelCase(config.auth)
state.auth.local.enabled = auth.local.enabled state.auth.local.enabled = auth.local.enabled
state.auth.openidConnect.enabled = auth.openidConnect.enabled state.auth.openidConnect.enabled = auth.openidConnect.enabled