Merge pull request #54410 from nextcloud/fix/sharing-status-action-sidebar-promise-return

This commit is contained in:
John Molakvoæ 2025-08-21 11:24:15 +02:00 committed by GitHub
commit d5417d63e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 54 additions and 16 deletions

View file

@ -2,7 +2,6 @@
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { Pinia } from 'pinia'
import { getCSPNonce } from '@nextcloud/auth'
import { PiniaVuePlugin } from 'pinia'
import Vue from 'vue'
@ -16,16 +15,6 @@ import SettingsService from './services/Settings.js'
__webpack_nonce__ = getCSPNonce()
declare global {
interface Window {
OC: Nextcloud.v29.OC
OCP: Nextcloud.v29.OCP
// eslint-disable-next-line @typescript-eslint/no-explicit-any
OCA: Record<string, any>
_nc_files_pinia: Pinia
}
}
// Init private and public Files namespace
window.OCA.Files = window.OCA.Files ?? {}
window.OCP.Files = window.OCP.Files ?? {}

View file

@ -17,6 +17,7 @@ import { action as sidebarAction } from '../../../files/src/actions/sidebarActio
import { generateAvatarSvg } from '../utils/AccountIcon'
import './sharingStatusAction.scss'
import { showError } from '@nextcloud/dialogs'
const isExternal = (node: Node) => {
return node.attributes?.['is-federated'] ?? false
@ -125,15 +126,23 @@ export const action = new FileAction({
return true
}
// You need share permissions to share this file
// and read permissions to see the sidebar
return (node.permissions & Permission.SHARE) !== 0
&& (node.permissions & Permission.READ) !== 0
},
async exec(node: Node, view: View, dir: string) {
// You need read permissions to see the sidebar
if ((node.permissions & Permission.READ) !== 0) {
window.OCA?.Files?.Sidebar?.setActiveTab?.('sharing')
return sidebarAction.exec(node, view, dir)
sidebarAction.exec(node, view, dir)
return null
}
// Should not happen as the enabled check should prevent this
// leaving it here for safety or in case someone calls this action directly
showError(t('files_sharing', 'You do not have enough permissions to share this file.'))
return null
},

View file

@ -92,6 +92,7 @@ $expectedFiles = [
'webpack.common.js',
'webpack.config.js',
'webpack.modules.js',
'window.d.ts',
];
$actualFiles = [];

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

39
window.d.ts vendored Normal file
View file

@ -0,0 +1,39 @@
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type RouterService from './apps/files/src/services/RouterService'
import type Settings from './apps/files/src/services/Settings'
import type Sidebar from './apps/files/src/services/Sidebar'
type SidebarAPI = Sidebar & {
open: (path: string) => Promise<void>
close: () => void
setFullScreenMode: (fullScreen: boolean) => void
setShowTagsDefault: (showTagsDefault: boolean) => void
}
declare global {
interface Window {
OC: Nextcloud.v29.OC
// Private Files namespace
OCA: {
Files: {
Settings: Settings
Sidebar: SidebarAPI
}
} & Record<string, any> // eslint-disable-line @typescript-eslint/no-explicit-any
// Public Files namespace
OCP: {
Files: {
Router: RouterService
}
} & Nextcloud.v29.OCP
// Private global files pinia store
_nc_files_pinia: Pinia
}
}