Skip to content

Commit 202124c

Browse files
authored
Merge pull request #58287 from nextcloud/fix/comments-action
fix(comments): properly handle opening the sidebar when Activity integration is used
2 parents 8c5fb9c + eb07c52 commit 202124c

File tree

12 files changed

+37
-17
lines changed

12 files changed

+37
-17
lines changed

apps/comments/src/actions/inlineUnreadCommentsAction.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import CommentProcessingSvg from '@mdi/svg/svg/comment-processing.svg?raw'
99
import { getSidebar } from '@nextcloud/files'
1010
import { n, t } from '@nextcloud/l10n'
1111
import logger from '../logger.js'
12+
import { isUsingActivityIntegration } from '../utils/activity.js'
1213

1314
export const action: IFileAction = {
1415
id: 'comments-unread',
@@ -38,7 +39,13 @@ export const action: IFileAction = {
3839

3940
try {
4041
const sidebar = getSidebar()
41-
sidebar.open(nodes[0], 'comments')
42+
const sidebarTabId = isUsingActivityIntegration() ? 'activity' : 'comments'
43+
if (sidebar.isOpen && sidebar.node?.source === nodes[0].source) {
44+
logger.debug('Sidebar already open for this node, just activating comments tab')
45+
sidebar.setActiveTab(sidebarTabId)
46+
return null
47+
}
48+
sidebar.open(nodes[0], sidebarTabId)
4249
return null
4350
} catch (error) {
4451
logger.error('Error while opening sidebar', { error })

apps/comments/src/files-sidebar.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
/**
1+
/*!
22
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

66
import MessageReplyText from '@mdi/svg/svg/message-reply-text.svg?raw'
77
import { getCSPNonce } from '@nextcloud/auth'
88
import { registerSidebarTab } from '@nextcloud/files'
9-
import { loadState } from '@nextcloud/initial-state'
109
import { t } from '@nextcloud/l10n'
1110
import wrap from '@vue/web-component-wrapper'
1211
import { createPinia, PiniaVuePlugin } from 'pinia'
1312
import Vue from 'vue'
1413
import { registerCommentsPlugins } from './comments-activity-tab.ts'
14+
import { isUsingActivityIntegration } from './utils/activity.ts'
1515

1616
__webpack_nonce__ = getCSPNonce()
1717

1818
const tagName = 'comments_files-sidebar-tab'
1919

20-
if (loadState('comments', 'activityEnabled', false) && OCA?.Activity?.registerSidebarAction !== undefined) {
20+
if (isUsingActivityIntegration()) {
2121
// Do not mount own tab but mount into activity
2222
window.addEventListener('DOMContentLoaded', function() {
2323
registerCommentsPlugins()
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/*!
2+
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import { loadState } from '@nextcloud/initial-state'
7+
8+
/**
9+
* Check if the comments app is using the Activity app integration for the sidebar.
10+
*/
11+
export function isUsingActivityIntegration() {
12+
return loadState('comments', 'activityEnabled', false) && window.OCA?.Activity?.registerSidebarAction !== undefined
13+
}

apps/files/src/utils/actionUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export async function executeAction(action: IFileAction) {
4848

4949
let displayName = action.id
5050
try {
51-
displayName = action.displayName(context)
51+
displayName = action.displayName(context) || displayName
5252
} catch (error) {
5353
logger.error('Error while getting action display name', { action, error })
5454
}

dist/comments-comments-tab.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/comments-comments-tab.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/comments-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/comments-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)