|
|
|
|
@ -4,45 +4,40 @@ |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
import type { INode } from '@nextcloud/files' |
|
|
|
|
import type { ComponentPublicInstance } from 'vue' |
|
|
|
|
|
|
|
|
|
import { createPinia, PiniaVuePlugin } from 'pinia' |
|
|
|
|
import Vue, { type ComponentPublicInstance } from 'vue' |
|
|
|
|
import { createPinia } from 'pinia' |
|
|
|
|
import { createApp } from 'vue' |
|
|
|
|
import logger from './logger.ts' |
|
|
|
|
import { getComments } from './services/GetComments.ts' |
|
|
|
|
|
|
|
|
|
Vue.use(PiniaVuePlugin) |
|
|
|
|
|
|
|
|
|
let ActivityTabPluginView |
|
|
|
|
let ActivityTabPluginInstance |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Register the comments plugins for the Activity sidebar |
|
|
|
|
*/ |
|
|
|
|
export function registerCommentsPlugins() { |
|
|
|
|
let app |
|
|
|
|
|
|
|
|
|
window.OCA.Activity.registerSidebarAction({ |
|
|
|
|
mount: async (el: HTMLElement, { node, reload }: { node: INode, reload: () => void }) => { |
|
|
|
|
const pinia = createPinia() |
|
|
|
|
|
|
|
|
|
if (!ActivityTabPluginView) { |
|
|
|
|
if (!app) { |
|
|
|
|
const { default: ActivityCommentAction } = await import('./views/ActivityCommentAction.vue') |
|
|
|
|
// @ts-expect-error Types are broken for Vue2
|
|
|
|
|
ActivityTabPluginView = Vue.extend(ActivityCommentAction) |
|
|
|
|
app = createApp( |
|
|
|
|
ActivityCommentAction, |
|
|
|
|
{ |
|
|
|
|
reloadCallback: reload, |
|
|
|
|
resourceId: node.fileid, |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
ActivityTabPluginInstance = new ActivityTabPluginView({ |
|
|
|
|
el, |
|
|
|
|
pinia, |
|
|
|
|
propsData: { |
|
|
|
|
reloadCallback: reload, |
|
|
|
|
resourceId: node.fileid, |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
app.use(pinia) |
|
|
|
|
app.mount(el) |
|
|
|
|
logger.info('Comments plugin mounted in Activity sidebar action', { node }) |
|
|
|
|
}, |
|
|
|
|
unmount: () => { |
|
|
|
|
// destroy previous instance if available
|
|
|
|
|
if (ActivityTabPluginInstance) { |
|
|
|
|
ActivityTabPluginInstance.$destroy() |
|
|
|
|
} |
|
|
|
|
app?.unmount() |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
@ -56,7 +51,6 @@ export function registerCommentsPlugins() { |
|
|
|
|
) |
|
|
|
|
logger.debug('Loaded comments', { node, comments }) |
|
|
|
|
const { default: CommentView } = await import('./views/ActivityCommentEntry.vue') |
|
|
|
|
const CommentsViewObject = Vue.extend(CommentView) |
|
|
|
|
|
|
|
|
|
return comments.map((comment) => ({ |
|
|
|
|
_CommentsViewInstance: undefined as ComponentPublicInstance | undefined, |
|
|
|
|
@ -64,17 +58,18 @@ export function registerCommentsPlugins() { |
|
|
|
|
timestamp: Date.parse(comment.props?.creationDateTime as string | undefined ?? ''), |
|
|
|
|
|
|
|
|
|
mount(element: HTMLElement, { reload }) { |
|
|
|
|
this._CommentsViewInstance = new CommentsViewObject({ |
|
|
|
|
el: element, |
|
|
|
|
propsData: { |
|
|
|
|
this._CommentsViewInstance = createApp( |
|
|
|
|
CommentView, |
|
|
|
|
{ |
|
|
|
|
comment, |
|
|
|
|
resourceId: node.fileid, |
|
|
|
|
reloadCallback: reload, |
|
|
|
|
}, |
|
|
|
|
}) |
|
|
|
|
) |
|
|
|
|
this._CommentsViewInstance.mount(el) |
|
|
|
|
}, |
|
|
|
|
unmount() { |
|
|
|
|
this._CommentsViewInstance?.$destroy() |
|
|
|
|
this._CommentsViewInstance?.unmount() |
|
|
|
|
}, |
|
|
|
|
})) |
|
|
|
|
}) |
|
|
|
|
|