Browse Source

fix: comment delete not working (#8714)

* fix: missing ui acl

* fix: remove unwanted ref fix: wrap condition in template
pull/8718/head
Anbarasu 5 months ago committed by GitHub
parent
commit
88278a77a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 43
      packages/nc-gui/components/smartsheet/expanded-form/Comments.vue
  2. 1
      packages/nc-gui/composables/useExpandedFormStore.ts
  3. 2
      packages/nc-gui/lib/acl.ts

43
packages/nc-gui/components/smartsheet/expanded-form/Comments.vue

@ -30,8 +30,6 @@ const route = useRoute()
const { dashboardUrl } = useDashboard() const { dashboardUrl } = useDashboard()
const editRef = ref<any>()
const { user, appInfo } = useGlobal() const { user, appInfo } = useGlobal()
const isExpandedFormLoading = computed(() => props.loading) const isExpandedFormLoading = computed(() => props.loading)
@ -108,6 +106,9 @@ onKeyStroke('Enter', (event) => {
function editComments(comment: CommentType) { function editComments(comment: CommentType) {
editComment.value = comment editComment.value = comment
isEditing.value = true isEditing.value = true
nextTick(() => {
scrollToComment(comment.id)
})
} }
const value = computed({ const value = computed({
@ -225,6 +226,21 @@ const createdBy = (
return 'Shared source' return 'Shared source'
} }
} }
const getUserRole = (email: string) => {
const user = baseUsers.value.find((user) => user.email === email)
if (!user) return ProjectRoles.NO_ACCESS
return user.roles || ProjectRoles.NO_ACCESS
}
const editedAt = (comment: CommentType) => {
if (comment.updated_at !== comment.created_at && comment.updated_at) {
const str = timeAgo(comment.updated_at).replace(' ', '_')
return `[(edited)](a~~~###~~~Edited_${str}) `
}
return ''
}
</script> </script>
<template> <template>
@ -286,10 +302,8 @@ const createdBy = (
</div> </div>
<div class="flex items-center gap-2"> <div class="flex items-center gap-2">
<NcDropdown <NcDropdown
v-if="(comment.created_by_email === user!.email && !editComment )" v-if="!editCommentValue"
:class="{ class="!hidden !group-hover:block"
'opacity-0 group-hover:opacity-100': comment.created_by_email === user!.email && !editComment,
}"
overlay-class-name="!min-w-[160px]" overlay-class-name="!min-w-[160px]"
placement="bottomRight" placement="bottomRight"
> >
@ -299,6 +313,7 @@ const createdBy = (
<template #overlay> <template #overlay>
<NcMenu> <NcMenu>
<NcMenuItem <NcMenuItem
v-if="user && comment.created_by_email === user.email"
v-e="['c:comment-expand:comment:edit']" v-e="['c:comment-expand:comment:edit']"
class="text-gray-700" class="text-gray-700"
@click="editComments(comment)" @click="editComments(comment)"
@ -308,6 +323,18 @@ const createdBy = (
{{ $t('general.edit') }} {{ $t('general.edit') }}
</div> </div>
</NcMenuItem> </NcMenuItem>
<NcMenuItem
v-e="['c:comment-expand:comment:copy']"
class="text-gray-700"
@click="copyComment(comment)"
>
<div class="flex gap-2 items-center">
<component :is="iconMap.copy" class="cursor-pointer" />
{{ $t('general.copy') }} URL
</div>
</NcMenuItem>
<template v-if="user && comment.created_by_email === user.email">
<NcDivider />
<NcMenuItem <NcMenuItem
v-e="['c:row-expand:comment:delete']" v-e="['c:row-expand:comment:delete']"
class="!text-red-500 !hover:bg-red-50" class="!text-red-500 !hover:bg-red-50"
@ -318,6 +345,7 @@ const createdBy = (
{{ $t('general.delete') }} {{ $t('general.delete') }}
</div> </div>
</NcMenuItem> </NcMenuItem>
</template>
</NcMenu> </NcMenu>
</template> </template>
</NcDropdown> </NcDropdown>
@ -352,8 +380,7 @@ const createdBy = (
</div> </div>
<div class="flex-1 flex flex-col gap-1 mt-1 max-w-[calc(100%)]"> <div class="flex-1 flex flex-col gap-1 mt-1 max-w-[calc(100%)]">
<SmartsheetExpandedFormRichComment <SmartsheetExpandedFormRichComment
v-if="comment.id === editComment?.id" v-if="comment.id === editCommentValue?.id"
ref="editRef"
v-model:value="value" v-model:value="value"
autofocus autofocus
:hide-options="false" :hide-options="false"

1
packages/nc-gui/composables/useExpandedFormStore.ts

@ -214,6 +214,7 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
} }
const resolveComment = async (commentId: string) => { const resolveComment = async (commentId: string) => {
if (!isUIAllowed('commentResolve')) return
const tempC = comments.value.find((c) => c.id === commentId) const tempC = comments.value.find((c) => c.id === commentId)
try { try {

2
packages/nc-gui/lib/acl.ts

@ -98,6 +98,8 @@ const rolePermissions = {
}, },
[ProjectRoles.COMMENTER]: { [ProjectRoles.COMMENTER]: {
include: { include: {
commentDelete: true,
commentResolve: true,
commentEdit: true, commentEdit: true,
commentList: true, commentList: true,
commentCount: true, commentCount: true,

Loading…
Cancel
Save