Merge pull request #45848 from nextcloud/fix/comment-deleting-with-activities

Fix/comment deleting with activities installed
This commit is contained in:
Christoph Wurst 2024-07-15 16:20:21 +02:00 committed by GitHub
commit 8c571dda47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 115 additions and 18 deletions

View file

@ -7,6 +7,10 @@ import Vue from 'vue'
import logger from './logger.js'
import { getComments } from './services/GetComments.js'
import { PiniaVuePlugin, createPinia } from 'pinia'
Vue.use(PiniaVuePlugin)
let ActivityTabPluginView
let ActivityTabPluginInstance
@ -16,9 +20,11 @@ let ActivityTabPluginInstance
export function registerCommentsPlugins() {
window.OCA.Activity.registerSidebarAction({
mount: async (el, { context, fileInfo, reload }) => {
const pinia = createPinia()
if (!ActivityTabPluginView) {
const { default: ActivityCommmentAction } = await import('./views/ActivityCommentAction.vue')
ActivityTabPluginView = Vue.extend(ActivityCommmentAction)
ActivityTabPluginView = ActivityCommmentAction
}
ActivityTabPluginInstance = new ActivityTabPluginView({
parent: context,
@ -26,6 +32,7 @@ export function registerCommentsPlugins() {
reloadCallback: reload,
resourceId: fileInfo.id,
},
pinia,
})
ActivityTabPluginInstance.$mount(el)
logger.info('Comments plugin mounted in Activity sidebar action', { fileInfo })
@ -42,7 +49,7 @@ export function registerCommentsPlugins() {
const { data: comments } = await getComments({ resourceType: 'files', resourceId: fileInfo.id }, { limit, offset })
logger.debug('Loaded comments', { fileInfo, comments })
const { default: CommentView } = await import('./views/ActivityCommentEntry.vue')
const CommentsViewObject = Vue.extend(CommentView)
const CommentsViewObject = CommentView
return comments.map((comment) => ({
timestamp: moment(comment.props.creationDateTime).toDate().getTime(),

View file

@ -4,7 +4,7 @@
-->
<template>
<component :is="tag"
v-show="!deleted"
v-show="!deleted && !isLimbo"
:class="{'comment--loading': loading}"
class="comment">
<!-- Comment header toolbar -->
@ -121,6 +121,8 @@ import IconDelete from 'vue-material-design-icons/Delete.vue'
import IconEdit from 'vue-material-design-icons/Pencil.vue'
import CommentMixin from '../mixins/CommentMixin.js'
import { mapStores } from 'pinia'
import { useDeletedCommentLimbo } from '../store/deletedCommentLimbo.js'
// Dynamic loading
const NcRichContenteditable = () => import('@nextcloud/vue/dist/Components/NcRichContenteditable.js')
@ -193,6 +195,7 @@ export default {
},
computed: {
...mapStores(useDeletedCommentLimbo),
/**
* Is the current user the author of this comment
@ -225,6 +228,10 @@ export default {
timestamp() {
return Date.parse(this.creationDateTime)
},
isLimbo() {
return this.deletedCommentLimboStore.checkForId(this.id)
},
},
watch: {

View file

@ -7,6 +7,8 @@ import { showError, showUndo, TOAST_UNDO_TIMEOUT } from '@nextcloud/dialogs'
import NewComment from '../services/NewComment.js'
import DeleteComment from '../services/DeleteComment.js'
import EditComment from '../services/EditComment.js'
import { mapStores } from 'pinia'
import { useDeletedCommentLimbo } from '../store/deletedCommentLimbo.js'
import logger from '../logger.js'
export default {
@ -37,6 +39,10 @@ export default {
}
},
computed: {
...mapStores(useDeletedCommentLimbo),
},
methods: {
// EDITION
onEdit() {
@ -64,11 +70,14 @@ export default {
// DELETION
onDeleteWithUndo() {
this.$emit('delete')
this.deleted = true
this.deletedCommentLimboStore.addId(this.id)
const timeOutDelete = setTimeout(this.onDelete, TOAST_UNDO_TIMEOUT)
showUndo(t('comments', 'Comment deleted'), () => {
clearTimeout(timeOutDelete)
this.deleted = false
this.deletedCommentLimboStore.removeId(this.id)
})
},
async onDelete() {
@ -80,6 +89,7 @@ export default {
showError(t('comments', 'An error occurred while trying to delete the comment'))
console.error(error)
this.deleted = false
this.deletedCommentLimboStore.removeId(this.id)
}
},

View file

@ -6,9 +6,11 @@
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import { getRequestToken } from '@nextcloud/auth'
import Vue from 'vue'
import { PiniaVuePlugin, createPinia } from 'pinia'
import CommentsApp from '../views/Comments.vue'
import logger from '../logger.js'
Vue.use(PiniaVuePlugin)
// eslint-disable-next-line camelcase
__webpack_nonce__ = btoa(getRequestToken())
@ -34,6 +36,8 @@ export default class CommentInstance {
* @param {object} options the vue options (propsData, parent, el...)
*/
constructor(resourceType = 'files', options = {}) {
const pinia = createPinia()
// Merge options and set `resourceType` property
options = {
...options,
@ -41,6 +45,7 @@ export default class CommentInstance {
...(options.propsData ?? {}),
resourceType,
},
pinia,
}
// Init Comments component
const View = Vue.extend(CommentsApp)

View file

@ -0,0 +1,28 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { defineStore } from 'pinia'
export const useDeletedCommentLimbo = defineStore('deletedCommentLimbo', {
state: () => ({
idsInLimbo: [],
}),
actions: {
addId(id) {
this.idsInLimbo.push(id)
},
removeId(id) {
const index = this.idsInLimbo.indexOf(id)
if (index > -1) {
this.idsInLimbo.splice(index, 1)
}
},
checkForId(id) {
this.idsInLimbo.includes(id)
},
},
})

View file

@ -41,11 +41,13 @@ SPDX-FileCopyrightText: Jacob Clevenger<https://github.com/wheatjs>
SPDX-FileCopyrightText: Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
SPDX-FileCopyrightText: Hypercontext
SPDX-FileCopyrightText: Guillaume Chau <guillaume.b.chau@gmail.com>
SPDX-FileCopyrightText: Guillaume Chau
SPDX-FileCopyrightText: GitHub Inc.
SPDX-FileCopyrightText: Feross Aboukhadijeh
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Eugene Sharygin <eush77@gmail.com>
SPDX-FileCopyrightText: Eric Norris (https://github.com/ericnorris)
SPDX-FileCopyrightText: Eduardo San Martin Morote
SPDX-FileCopyrightText: Dylan Piercey <pierceydylan@gmail.com>
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <mario@cure53.de> (https://cure53.de/)
SPDX-FileCopyrightText: David Clark
@ -96,6 +98,9 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/vue
- version: 8.14.0
- license: AGPL-3.0-or-later
- @vue/devtools-api
- version: 6.6.1
- license: MIT
- @vueuse/components
- version: 10.11.0
- license: MIT
@ -279,6 +284,9 @@ This file is generated from multiple sources. Included packages:
- path
- version: 0.12.7
- license: MIT
- pinia
- version: 2.1.7
- license: MIT
- possible-typed-array-names
- version: 1.0.0
- license: MIT

4
dist/7462-7462.js vendored

File diff suppressed because one or more lines are too long

View file

@ -41,11 +41,13 @@ SPDX-FileCopyrightText: Jacob Clevenger<https://github.com/wheatjs>
SPDX-FileCopyrightText: Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
SPDX-FileCopyrightText: Hypercontext
SPDX-FileCopyrightText: Guillaume Chau <guillaume.b.chau@gmail.com>
SPDX-FileCopyrightText: Guillaume Chau
SPDX-FileCopyrightText: GitHub Inc.
SPDX-FileCopyrightText: Feross Aboukhadijeh
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Eugene Sharygin <eush77@gmail.com>
SPDX-FileCopyrightText: Eric Norris (https://github.com/ericnorris)
SPDX-FileCopyrightText: Eduardo San Martin Morote
SPDX-FileCopyrightText: Dylan Piercey <pierceydylan@gmail.com>
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <mario@cure53.de> (https://cure53.de/)
SPDX-FileCopyrightText: David Clark
@ -96,6 +98,9 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/vue
- version: 8.14.0
- license: AGPL-3.0-or-later
- @vue/devtools-api
- version: 6.6.1
- license: MIT
- @vueuse/components
- version: 10.11.0
- license: MIT
@ -279,6 +284,9 @@ This file is generated from multiple sources. Included packages:
- path
- version: 0.12.7
- license: MIT
- pinia
- version: 2.1.7
- license: MIT
- possible-typed-array-names
- version: 1.0.0
- license: MIT

File diff suppressed because one or more lines are too long

View file

@ -41,11 +41,13 @@ SPDX-FileCopyrightText: Jacob Clevenger<https://github.com/wheatjs>
SPDX-FileCopyrightText: Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
SPDX-FileCopyrightText: Hypercontext
SPDX-FileCopyrightText: Guillaume Chau <guillaume.b.chau@gmail.com>
SPDX-FileCopyrightText: Guillaume Chau
SPDX-FileCopyrightText: GitHub Inc.
SPDX-FileCopyrightText: Feross Aboukhadijeh
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Eugene Sharygin <eush77@gmail.com>
SPDX-FileCopyrightText: Eric Norris (https://github.com/ericnorris)
SPDX-FileCopyrightText: Eduardo San Martin Morote
SPDX-FileCopyrightText: Dylan Piercey <pierceydylan@gmail.com>
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <mario@cure53.de> (https://cure53.de/)
SPDX-FileCopyrightText: David Clark
@ -96,6 +98,9 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/vue
- version: 8.14.0
- license: AGPL-3.0-or-later
- @vue/devtools-api
- version: 6.6.1
- license: MIT
- @vueuse/components
- version: 10.11.0
- license: MIT
@ -279,6 +284,9 @@ This file is generated from multiple sources. Included packages:
- path
- version: 0.12.7
- license: MIT
- pinia
- version: 2.1.7
- license: MIT
- possible-typed-array-names
- version: 1.0.0
- license: MIT

File diff suppressed because one or more lines are too long

View file

@ -41,11 +41,13 @@ SPDX-FileCopyrightText: Jacob Clevenger<https://github.com/wheatjs>
SPDX-FileCopyrightText: Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
SPDX-FileCopyrightText: Hypercontext
SPDX-FileCopyrightText: Guillaume Chau <guillaume.b.chau@gmail.com>
SPDX-FileCopyrightText: Guillaume Chau
SPDX-FileCopyrightText: GitHub Inc.
SPDX-FileCopyrightText: Feross Aboukhadijeh
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Eugene Sharygin <eush77@gmail.com>
SPDX-FileCopyrightText: Eric Norris (https://github.com/ericnorris)
SPDX-FileCopyrightText: Eduardo San Martin Morote
SPDX-FileCopyrightText: Dylan Piercey <pierceydylan@gmail.com>
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <mario@cure53.de> (https://cure53.de/)
SPDX-FileCopyrightText: David Clark
@ -96,6 +98,9 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/vue
- version: 8.14.0
- license: AGPL-3.0-or-later
- @vue/devtools-api
- version: 6.6.1
- license: MIT
- @vueuse/components
- version: 10.11.0
- license: MIT
@ -279,6 +284,9 @@ This file is generated from multiple sources. Included packages:
- path
- version: 0.12.7
- license: MIT
- pinia
- version: 2.1.7
- license: MIT
- possible-typed-array-names
- version: 1.0.0
- license: MIT

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -33,9 +33,11 @@ SPDX-FileCopyrightText: John Hiesey
SPDX-FileCopyrightText: James Halliday
SPDX-FileCopyrightText: Iskren Ivov Chernev <iskren.chernev@gmail.com> (https://github.com/ichernev)
SPDX-FileCopyrightText: Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)
SPDX-FileCopyrightText: Guillaume Chau
SPDX-FileCopyrightText: GitHub Inc.
SPDX-FileCopyrightText: Feross Aboukhadijeh
SPDX-FileCopyrightText: Evan You
SPDX-FileCopyrightText: Eduardo San Martin Morote
SPDX-FileCopyrightText: Dylan Piercey <pierceydylan@gmail.com>
SPDX-FileCopyrightText: Dr.-Ing. Mario Heiderich, Cure53 <mario@cure53.de> (https://cure53.de/)
SPDX-FileCopyrightText: Christoph Wurst
@ -71,6 +73,9 @@ This file is generated from multiple sources. Included packages:
- @nextcloud/router
- version: 3.0.1
- license: GPL-3.0-or-later
- @vue/devtools-api
- version: 6.6.1
- license: MIT
- assert
- version: 2.1.0
- license: MIT
@ -224,6 +229,9 @@ This file is generated from multiple sources. Included packages:
- path-posix
- version: 1.0.0
- license: ISC
- pinia
- version: 2.1.7
- license: MIT
- possible-typed-array-names
- version: 1.0.0
- license: MIT

File diff suppressed because one or more lines are too long

4
dist/core-common.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long