diff --git a/packages/frontend/src/main/components/comments/CommentListItem.vue b/packages/frontend/src/main/components/comments/CommentListItem.vue index 80fd1e7b5..54df3ea10 100644 --- a/packages/frontend/src/main/components/comments/CommentListItem.vue +++ b/packages/frontend/src/main/components/comments/CommentListItem.vue @@ -29,6 +29,28 @@ Created on {{ new Date(commentDetails.createdAt).toLocaleString() }} +
+ Archive + + + + + mdi-pencil + + Archive Comment Thread + + mdi-close + + + This comment thread will be archived. Are you sure? + + + + Cancel + Archive + + +
@@ -46,16 +68,12 @@ > mdi-cube-outline - mdi-comment-outline - {{ commentDetails.replies.totalCount }} - - {{ - commentDetails.replies.totalCount > 1 || commentDetails.replies.totalCount === 0 - ? 'replies' - : 'reply' - }} - - reply + + + mdi-comment-outline + {{ commentDetails.replies.totalCount }} + reply +
@@ -83,7 +101,8 @@ export default { UserAvatar: () => import('@/main/components/common/UserAvatar') }, props: { - comment: { type: Object, default: () => null } + comment: { type: Object, default: () => null }, + stream: { type: Object, default: () => { return { role: null } } } }, apollo: { commentDetails: { @@ -121,10 +140,16 @@ export default { }, data() { return { - hovered: false + hovered: false, + showArchiveDialog: false } }, computed: { + canArchiveThread() { + if(!this.comment || !this.stream ) return false + if(!this.stream.role) return false + if(this.comment.authorId === this.$userId() || this.stream.role ==='stream:owner') return true + }, link() { if (!this.commentDetails) return let res = this.commentDetails.resources.filter((r) => r.resourceType !== 'stream') @@ -139,6 +164,33 @@ export default { if (!this.commentDetails) return return new Date(this.commentDetails.updatedAt) - new Date(this.commentDetails.viewedAt) > 0 } + }, + methods:{ + async archiveComment() { + try { + await this.$apollo.mutate({ + mutation: gql` + mutation commentArchive($streamId: String!, $commentId: String!) { + commentArchive(streamId: $streamId, commentId: $commentId) + } + `, + variables: { + streamId: this.$route.params.streamId, + commentId: this.comment.id + } + }) + this.showArchiveDialog = false + this.$emit('deleted', this.comment) + this.$mixpanel.track('Comment Action', { type: 'action', name: 'archive' }) + this.$eventHub.$emit('notification', { + text: 'Thread archived.' + }) + } catch (e) { + this.$eventHub.$emit('notification', { + text: e.message + }) + } + } } } diff --git a/packages/frontend/src/main/components/comments/CommentThreadViewer.vue b/packages/frontend/src/main/components/comments/CommentThreadViewer.vue index 07e6c8bc1..e78620971 100644 --- a/packages/frontend/src/main/components/comments/CommentThreadViewer.vue +++ b/packages/frontend/src/main/components/comments/CommentThreadViewer.vue @@ -1,9 +1,9 @@