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

View file

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