diff --git a/apps/comments/lib/Listener/LoadSidebarScripts.php b/apps/comments/lib/Listener/LoadSidebarScripts.php
index 906fe40fed250..8629883ba04d8 100644
--- a/apps/comments/lib/Listener/LoadSidebarScripts.php
+++ b/apps/comments/lib/Listener/LoadSidebarScripts.php
@@ -34,7 +34,8 @@ public function handle(Event $event): void {
$this->commentsManager->load();
$this->initialState->provideInitialState('activityEnabled', $this->appManager->isEnabledForUser('activity'));
- // Add comments sidebar tab script
+ // Add comments sidebar tab script/style
+ Util::addStyle(Application::APP_ID, 'comments-tab');
Util::addScript(Application::APP_ID, 'comments-tab', 'files');
}
}
diff --git a/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts b/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts
index 699c53f849d48..2cd2e9d16a066 100644
--- a/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts
+++ b/apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts
@@ -7,7 +7,7 @@ import type { IFolder, IView } from '@nextcloud/files'
import { File, Permission } from '@nextcloud/files'
import { describe, expect, test, vi } from 'vitest'
-import logger from '../logger.js'
+import logger from '../logger.ts'
import { action } from './inlineUnreadCommentsAction.ts'
const view = {
diff --git a/apps/comments/src/actions/inlineUnreadCommentsAction.ts b/apps/comments/src/actions/inlineUnreadCommentsAction.ts
index 4f77a66244c2c..c871a1d474660 100644
--- a/apps/comments/src/actions/inlineUnreadCommentsAction.ts
+++ b/apps/comments/src/actions/inlineUnreadCommentsAction.ts
@@ -8,8 +8,8 @@ import type { IFileAction } from '@nextcloud/files'
import CommentProcessingSvg from '@mdi/svg/svg/comment-processing.svg?raw'
import { getSidebar } from '@nextcloud/files'
import { n, t } from '@nextcloud/l10n'
-import logger from '../logger.js'
-import { isUsingActivityIntegration } from '../utils/activity.js'
+import logger from '../logger.ts'
+import { isUsingActivityIntegration } from '../utils/activity.ts'
export const action: IFileAction = {
id: 'comments-unread',
diff --git a/apps/comments/src/comments-activity-tab.ts b/apps/comments/src/comments-activity-tab.ts
index c368236052f86..af2b648ad7fc9 100644
--- a/apps/comments/src/comments-activity-tab.ts
+++ b/apps/comments/src/comments-activity-tab.ts
@@ -6,44 +6,38 @@
import type { INode } from '@nextcloud/files'
import moment from '@nextcloud/moment'
-import { createPinia, PiniaVuePlugin } from 'pinia'
-import Vue, { type ComponentPublicInstance } from 'vue'
-import logger from './logger.js'
-import { getComments } from './services/GetComments.js'
-
-Vue.use(PiniaVuePlugin)
-
-let ActivityTabPluginView
-let ActivityTabPluginInstance
+import { createPinia } from 'pinia'
+import { type ComponentPublicInstance, createApp } from 'vue'
+import logger from './logger.ts'
+import { getComments } from './services/GetComments.ts'
/**
* 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()
},
})
@@ -57,8 +51,6 @@ export function registerCommentsPlugins() {
)
logger.debug('Loaded comments', { node, comments })
const { default: CommentView } = await import('./views/ActivityCommentEntry.vue')
- // @ts-expect-error Types are broken for Vue2
- const CommentsViewObject = Vue.extend(CommentView)
return comments.map((comment) => ({
_CommentsViewInstance: undefined as ComponentPublicInstance | undefined,
@@ -66,17 +58,18 @@ export function registerCommentsPlugins() {
timestamp: moment(comment.props?.creationDateTime).toDate().getTime(),
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()
},
}))
})
diff --git a/apps/comments/src/comments-app.js b/apps/comments/src/comments-app.ts
similarity index 79%
rename from apps/comments/src/comments-app.js
rename to apps/comments/src/comments-app.ts
index ea99517e2807c..4b4fd54c55a65 100644
--- a/apps/comments/src/comments-app.js
+++ b/apps/comments/src/comments-app.ts
@@ -3,8 +3,8 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import logger from './logger.js'
-import CommentsInstance from './services/CommentsInstance.js'
+import logger from './logger.ts'
+import CommentsInstance from './services/CommentsInstance.ts'
// Init Comments
if (window.OCA && !window.OCA.Comments) {
diff --git a/apps/comments/src/components/Comment.vue b/apps/comments/src/components/Comment.vue
index 9e700fbf919d6..7b7fc4cdd4643 100644
--- a/apps/comments/src/components/Comment.vue
+++ b/apps/comments/src/components/Comment.vue
@@ -75,7 +75,7 @@
:model-value="localMessage"
:user-data="userData"
aria-describedby="tab-comments__editor-description"
- @update:value="updateLocalMessage"
+ @update:model-value="updateLocalMessage"
@submit="onSubmit" />
@@ -125,8 +125,8 @@ import IconArrowRight from 'vue-material-design-icons/ArrowRight.vue'
import IconClose from 'vue-material-design-icons/Close.vue'
import IconPencilOutline from 'vue-material-design-icons/PencilOutline.vue'
import IconTrashCanOutline from 'vue-material-design-icons/TrashCanOutline.vue'
-import CommentMixin from '../mixins/CommentMixin.js'
-import { useDeletedCommentLimbo } from '../store/deletedCommentLimbo.js'
+import CommentMixin from '../mixins/CommentMixin.ts'
+import { useDeletedCommentLimbo } from '../store/deletedCommentLimbo.ts'
// Dynamic loading
const NcRichContenteditable = () => import('@nextcloud/vue/components/NcRichContenteditable')
diff --git a/apps/comments/src/files-sidebar.ts b/apps/comments/src/files-sidebar.ts
index 1a39291c48d42..999708a840ef1 100644
--- a/apps/comments/src/files-sidebar.ts
+++ b/apps/comments/src/files-sidebar.ts
@@ -4,17 +4,13 @@
*/
import MessageReplyText from '@mdi/svg/svg/message-reply-text.svg?raw'
-import { getCSPNonce } from '@nextcloud/auth'
import { registerSidebarTab } from '@nextcloud/files'
import { t } from '@nextcloud/l10n'
-import wrap from '@vue/web-component-wrapper'
-import { createPinia, PiniaVuePlugin } from 'pinia'
-import Vue from 'vue'
+import { createPinia } from 'pinia'
+import { defineCustomElement } from 'vue'
import { registerCommentsPlugins } from './comments-activity-tab.ts'
import { isUsingActivityIntegration } from './utils/activity.ts'
-__webpack_nonce__ = getCSPNonce()
-
const tagName = 'comments_files-sidebar-tab'
if (isUsingActivityIntegration()) {
@@ -32,17 +28,15 @@ if (isUsingActivityIntegration()) {
async onInit() {
const { default: FilesSidebarTab } = await import('./views/FilesSidebarTab.vue')
- Vue.use(PiniaVuePlugin)
- Vue.mixin({ pinia: createPinia() })
- const webComponent = wrap(Vue, FilesSidebarTab)
- // In Vue 2, wrap doesn't support disabling shadow. Disable with a hack
- Object.defineProperty(webComponent.prototype, 'attachShadow', {
- value() { return this },
- })
- Object.defineProperty(webComponent.prototype, 'shadowRoot', {
- get() { return this },
+ const FilesSidebarTabElement = defineCustomElement(FilesSidebarTab, {
+ configureApp(app) {
+ const pinia = createPinia()
+ app.use(pinia)
+ },
+ shadowRoot: false,
})
- window.customElements.define(tagName, webComponent)
+
+ window.customElements.define(tagName, FilesSidebarTabElement)
},
})
}
diff --git a/apps/comments/src/logger.js b/apps/comments/src/logger.ts
similarity index 100%
rename from apps/comments/src/logger.js
rename to apps/comments/src/logger.ts
diff --git a/apps/comments/src/mixins/CommentMixin.js b/apps/comments/src/mixins/CommentMixin.ts
similarity index 93%
rename from apps/comments/src/mixins/CommentMixin.js
rename to apps/comments/src/mixins/CommentMixin.ts
index 92fd3b17acf9b..36e79eb429706 100644
--- a/apps/comments/src/mixins/CommentMixin.js
+++ b/apps/comments/src/mixins/CommentMixin.ts
@@ -5,11 +5,11 @@
import { showError, showUndo, TOAST_UNDO_TIMEOUT } from '@nextcloud/dialogs'
import { mapStores } from 'pinia'
-import logger from '../logger.js'
-import DeleteComment from '../services/DeleteComment.js'
-import EditComment from '../services/EditComment.js'
-import NewComment from '../services/NewComment.js'
-import { useDeletedCommentLimbo } from '../store/deletedCommentLimbo.js'
+import logger from '../logger.ts'
+import DeleteComment from '../services/DeleteComment.ts'
+import EditComment from '../services/EditComment.ts'
+import NewComment from '../services/NewComment.ts'
+import { useDeletedCommentLimbo } from '../store/deletedCommentLimbo.ts'
export default {
props: {
diff --git a/apps/comments/src/services/CommentsInstance.js b/apps/comments/src/services/CommentsInstance.js
deleted file mode 100644
index a768da1c652a2..0000000000000
--- a/apps/comments/src/services/CommentsInstance.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
- * SPDX-License-Identifier: AGPL-3.0-or-later
- */
-
-import { getCSPNonce } from '@nextcloud/auth'
-import { n, t } from '@nextcloud/l10n'
-import { createPinia, PiniaVuePlugin } from 'pinia'
-import Vue from 'vue'
-import CommentsApp from '../views/Comments.vue'
-import logger from '../logger.js'
-
-Vue.use(PiniaVuePlugin)
-
-__webpack_nonce__ = getCSPNonce()
-
-// Add translates functions
-Vue.mixin({
- data() {
- return {
- logger,
- }
- },
- methods: {
- t,
- n,
- },
-})
-
-export default class CommentInstance {
- /**
- * Initialize a new Comments instance for the desired type
- *
- * @param {string} resourceType the comments endpoint type
- * @param {object} options the vue options (propsData, parent, el...)
- */
- constructor(resourceType = 'files', options = {}) {
- const pinia = createPinia()
-
- // Merge options and set `resourceType` property
- options = {
- ...options,
- propsData: {
- ...(options.propsData ?? {}),
- resourceType,
- },
- pinia,
- }
- // Init Comments component
- const View = Vue.extend(CommentsApp)
- return new View(options)
- }
-}
diff --git a/apps/comments/src/services/CommentsInstance.ts b/apps/comments/src/services/CommentsInstance.ts
new file mode 100644
index 0000000000000..32a8ed3eeae86
--- /dev/null
+++ b/apps/comments/src/services/CommentsInstance.ts
@@ -0,0 +1,47 @@
+/**
+ * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import { n, t } from '@nextcloud/l10n'
+import { createPinia } from 'pinia'
+import { createApp } from 'vue'
+import CommentsApp from '../views/Comments.vue'
+import logger from '../logger.ts'
+
+export default class CommentInstance {
+ /**
+ * Initialize a new Comments instance for the desired type
+ *
+ * @param {string} resourceType the comments endpoint type
+ * @param {object} options the vue options (propsData, parent, el...)
+ */
+ constructor(resourceType = 'files', options = {}) {
+ const pinia = createPinia()
+
+ const app = createApp(
+ CommentsApp,
+ {
+ ...(options.propsData ?? {}),
+ resourceType,
+ },
+ )
+
+ // Add translates functions
+ app.mixin({
+ data() {
+ return {
+ logger,
+ }
+ },
+ methods: {
+ t,
+ n,
+ },
+ })
+
+ app.use(pinia)
+ // app.mount(options.el)
+ return app
+ }
+}
diff --git a/apps/comments/src/services/DavClient.js b/apps/comments/src/services/DavClient.ts
similarity index 93%
rename from apps/comments/src/services/DavClient.js
rename to apps/comments/src/services/DavClient.ts
index 6287b47cf309f..b1832b0f715ab 100644
--- a/apps/comments/src/services/DavClient.js
+++ b/apps/comments/src/services/DavClient.ts
@@ -5,7 +5,7 @@
import { getRequestToken, onRequestTokenUpdate } from '@nextcloud/auth'
import { createClient } from 'webdav'
-import { getRootPath } from '../utils/davUtils.js'
+import { getRootPath } from '../utils/davUtils.ts'
// init webdav client
const client = createClient(getRootPath())
diff --git a/apps/comments/src/services/DeleteComment.js b/apps/comments/src/services/DeleteComment.ts
similarity index 93%
rename from apps/comments/src/services/DeleteComment.js
rename to apps/comments/src/services/DeleteComment.ts
index 1ed63d7836a54..46f46a483ffb1 100644
--- a/apps/comments/src/services/DeleteComment.js
+++ b/apps/comments/src/services/DeleteComment.ts
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import client from './DavClient.js'
+import client from './DavClient.ts'
/**
* Delete a comment
diff --git a/apps/comments/src/services/EditComment.js b/apps/comments/src/services/EditComment.ts
similarity index 95%
rename from apps/comments/src/services/EditComment.js
rename to apps/comments/src/services/EditComment.ts
index cd8e5a977047a..c5f7679013b7f 100644
--- a/apps/comments/src/services/EditComment.js
+++ b/apps/comments/src/services/EditComment.ts
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-import client from './DavClient.js'
+import client from './DavClient.ts'
/**
* Edit an existing comment
diff --git a/apps/comments/src/services/GetComments.ts b/apps/comments/src/services/GetComments.ts
index 07c22bef4293c..884b66b77d25c 100644
--- a/apps/comments/src/services/GetComments.ts
+++ b/apps/comments/src/services/GetComments.ts
@@ -8,7 +8,7 @@ import type { DAVResult, FileStat, ResponseDataDetailed } from 'webdav'
import { parseXML } from 'webdav'
import { processResponsePayload } from 'webdav/dist/node/response.js'
import { prepareFileFromProps } from 'webdav/dist/node/tools/dav.js'
-import client from './DavClient.js'
+import client from './DavClient.ts'
export const DEFAULT_LIMIT = 20
diff --git a/apps/comments/src/services/NewComment.js b/apps/comments/src/services/NewComment.ts
similarity index 94%
rename from apps/comments/src/services/NewComment.js
rename to apps/comments/src/services/NewComment.ts
index a283b2068307f..32e452e2c20f0 100644
--- a/apps/comments/src/services/NewComment.js
+++ b/apps/comments/src/services/NewComment.ts
@@ -5,9 +5,9 @@
import { getCurrentUser } from '@nextcloud/auth'
import axios from '@nextcloud/axios'
-import { getRootPath } from '../utils/davUtils.js'
-import { decodeHtmlEntities } from '../utils/decodeHtmlEntities.js'
-import client from './DavClient.js'
+import { getRootPath } from '../utils/davUtils.ts'
+import { decodeHtmlEntities } from '../utils/decodeHtmlEntities.ts'
+import client from './DavClient.ts'
/**
* Retrieve the comments list
diff --git a/apps/comments/src/services/ReadComments.ts b/apps/comments/src/services/ReadComments.ts
index 69bf72bb22f2c..873b186700d59 100644
--- a/apps/comments/src/services/ReadComments.ts
+++ b/apps/comments/src/services/ReadComments.ts
@@ -5,7 +5,7 @@
import type { Response } from 'webdav'
-import client from './DavClient.js'
+import client from './DavClient.ts'
/**
* Mark comments older than the date timestamp as read
diff --git a/apps/comments/src/store/deletedCommentLimbo.js b/apps/comments/src/store/deletedCommentLimbo.ts
similarity index 100%
rename from apps/comments/src/store/deletedCommentLimbo.js
rename to apps/comments/src/store/deletedCommentLimbo.ts
diff --git a/apps/comments/src/utils/cancelableRequest.js b/apps/comments/src/utils/cancelableRequest.ts
similarity index 100%
rename from apps/comments/src/utils/cancelableRequest.js
rename to apps/comments/src/utils/cancelableRequest.ts
diff --git a/apps/comments/src/utils/davUtils.js b/apps/comments/src/utils/davUtils.ts
similarity index 100%
rename from apps/comments/src/utils/davUtils.js
rename to apps/comments/src/utils/davUtils.ts
diff --git a/apps/comments/src/utils/decodeHtmlEntities.js b/apps/comments/src/utils/decodeHtmlEntities.ts
similarity index 100%
rename from apps/comments/src/utils/decodeHtmlEntities.js
rename to apps/comments/src/utils/decodeHtmlEntities.ts
diff --git a/apps/comments/src/views/ActivityCommentAction.vue b/apps/comments/src/views/ActivityCommentAction.vue
index e715a231b56a0..c2e21142008cf 100644
--- a/apps/comments/src/views/ActivityCommentAction.vue
+++ b/apps/comments/src/views/ActivityCommentAction.vue
@@ -20,8 +20,8 @@ import { showError } from '@nextcloud/dialogs'
import { t } from '@nextcloud/l10n'
import { defineComponent } from 'vue'
import Comment from '../components/Comment.vue'
-import logger from '../logger.js'
-import CommentView from '../mixins/CommentView.js'
+import logger from '../logger.ts'
+import CommentView from '../mixins/CommentView.ts'
export default defineComponent({
components: {
diff --git a/apps/comments/src/views/Comments.vue b/apps/comments/src/views/Comments.vue
index 456dedf81d8ef..cdd9621ae1914 100644
--- a/apps/comments/src/views/Comments.vue
+++ b/apps/comments/src/views/Comments.vue
@@ -33,11 +33,11 @@