mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #58287 from nextcloud/fix/comments-action
fix(comments): properly handle opening the sidebar when Activity integration is used
This commit is contained in:
commit
202124cd28
12 changed files with 37 additions and 17 deletions
|
|
@ -9,6 +9,7 @@ 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'
|
||||
|
||||
export const action: IFileAction = {
|
||||
id: 'comments-unread',
|
||||
|
|
@ -38,7 +39,13 @@ export const action: IFileAction = {
|
|||
|
||||
try {
|
||||
const sidebar = getSidebar()
|
||||
sidebar.open(nodes[0], 'comments')
|
||||
const sidebarTabId = isUsingActivityIntegration() ? 'activity' : 'comments'
|
||||
if (sidebar.isOpen && sidebar.node?.source === nodes[0].source) {
|
||||
logger.debug('Sidebar already open for this node, just activating comments tab')
|
||||
sidebar.setActiveTab(sidebarTabId)
|
||||
return null
|
||||
}
|
||||
sidebar.open(nodes[0], sidebarTabId)
|
||||
return null
|
||||
} catch (error) {
|
||||
logger.error('Error while opening sidebar', { error })
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/**
|
||||
/*!
|
||||
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
|
@ -6,18 +6,18 @@
|
|||
import MessageReplyText from '@mdi/svg/svg/message-reply-text.svg?raw'
|
||||
import { getCSPNonce } from '@nextcloud/auth'
|
||||
import { registerSidebarTab } from '@nextcloud/files'
|
||||
import { loadState } from '@nextcloud/initial-state'
|
||||
import { t } from '@nextcloud/l10n'
|
||||
import wrap from '@vue/web-component-wrapper'
|
||||
import { createPinia, PiniaVuePlugin } from 'pinia'
|
||||
import Vue 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 (loadState('comments', 'activityEnabled', false) && OCA?.Activity?.registerSidebarAction !== undefined) {
|
||||
if (isUsingActivityIntegration()) {
|
||||
// Do not mount own tab but mount into activity
|
||||
window.addEventListener('DOMContentLoaded', function() {
|
||||
registerCommentsPlugins()
|
||||
|
|
|
|||
13
apps/comments/src/utils/activity.ts
Normal file
13
apps/comments/src/utils/activity.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
/*!
|
||||
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { loadState } from '@nextcloud/initial-state'
|
||||
|
||||
/**
|
||||
* Check if the comments app is using the Activity app integration for the sidebar.
|
||||
*/
|
||||
export function isUsingActivityIntegration() {
|
||||
return loadState('comments', 'activityEnabled', false) && window.OCA?.Activity?.registerSidebarAction !== undefined
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ export async function executeAction(action: IFileAction) {
|
|||
|
||||
let displayName = action.id
|
||||
try {
|
||||
displayName = action.displayName(context)
|
||||
displayName = action.displayName(context) || displayName
|
||||
} catch (error) {
|
||||
logger.error('Error while getting action display name', { action, error })
|
||||
}
|
||||
|
|
|
|||
4
dist/comments-comments-tab.js
vendored
4
dist/comments-comments-tab.js
vendored
File diff suppressed because one or more lines are too long
2
dist/comments-comments-tab.js.map
vendored
2
dist/comments-comments-tab.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/comments-init.js
vendored
4
dist/comments-init.js
vendored
File diff suppressed because one or more lines are too long
2
dist/comments-init.js.map
vendored
2
dist/comments-init.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/files-init.js
vendored
4
dist/files-init.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-init.js.map
vendored
2
dist/files-init.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/files-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue