Skip to content

Commit d5417d6

Browse files
authored
Merge pull request nextcloud#54410 from nextcloud/fix/sharing-status-action-sidebar-promise-return
2 parents 2e81653 + 5bfce62 commit d5417d6

File tree

7 files changed

+54
-16
lines changed

7 files changed

+54
-16
lines changed

apps/files/src/main.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5-
import type { Pinia } from 'pinia'
65
import { getCSPNonce } from '@nextcloud/auth'
76
import { PiniaVuePlugin } from 'pinia'
87
import Vue from 'vue'
@@ -16,16 +15,6 @@ import SettingsService from './services/Settings.js'
1615

1716
__webpack_nonce__ = getCSPNonce()
1817

19-
declare global {
20-
interface Window {
21-
OC: Nextcloud.v29.OC
22-
OCP: Nextcloud.v29.OCP
23-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
24-
OCA: Record<string, any>
25-
_nc_files_pinia: Pinia
26-
}
27-
}
28-
2918
// Init private and public Files namespace
3019
window.OCA.Files = window.OCA.Files ?? {}
3120
window.OCP.Files = window.OCP.Files ?? {}

apps/files_sharing/src/files_actions/sharingStatusAction.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { action as sidebarAction } from '../../../files/src/actions/sidebarActio
1717
import { generateAvatarSvg } from '../utils/AccountIcon'
1818

1919
import './sharingStatusAction.scss'
20+
import { showError } from '@nextcloud/dialogs'
2021

2122
const isExternal = (node: Node) => {
2223
return node.attributes?.['is-federated'] ?? false
@@ -125,15 +126,23 @@ export const action = new FileAction({
125126
return true
126127
}
127128

129+
// You need share permissions to share this file
130+
// and read permissions to see the sidebar
128131
return (node.permissions & Permission.SHARE) !== 0
132+
&& (node.permissions & Permission.READ) !== 0
129133
},
130134

131135
async exec(node: Node, view: View, dir: string) {
132136
// You need read permissions to see the sidebar
133137
if ((node.permissions & Permission.READ) !== 0) {
134138
window.OCA?.Files?.Sidebar?.setActiveTab?.('sharing')
135-
return sidebarAction.exec(node, view, dir)
139+
sidebarAction.exec(node, view, dir)
140+
return null
136141
}
142+
143+
// Should not happen as the enabled check should prevent this
144+
// leaving it here for safety or in case someone calls this action directly
145+
showError(t('files_sharing', 'You do not have enough permissions to share this file.'))
137146
return null
138147
},
139148

build/files-checker.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
'webpack.common.js',
9393
'webpack.config.js',
9494
'webpack.modules.js',
95+
'window.d.ts',
9596
];
9697
$actualFiles = [];
9798

dist/files-main.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_sharing-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_sharing-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.

window.d.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
3+
* SPDX-License-Identifier: AGPL-3.0-or-later
4+
*/
5+
6+
import type RouterService from './apps/files/src/services/RouterService'
7+
import type Settings from './apps/files/src/services/Settings'
8+
import type Sidebar from './apps/files/src/services/Sidebar'
9+
10+
type SidebarAPI = Sidebar & {
11+
open: (path: string) => Promise<void>
12+
close: () => void
13+
setFullScreenMode: (fullScreen: boolean) => void
14+
setShowTagsDefault: (showTagsDefault: boolean) => void
15+
}
16+
17+
declare global {
18+
interface Window {
19+
OC: Nextcloud.v29.OC
20+
21+
// Private Files namespace
22+
OCA: {
23+
Files: {
24+
Settings: Settings
25+
Sidebar: SidebarAPI
26+
}
27+
} & Record<string, any> // eslint-disable-line @typescript-eslint/no-explicit-any
28+
29+
// Public Files namespace
30+
OCP: {
31+
Files: {
32+
Router: RouterService
33+
}
34+
} & Nextcloud.v29.OCP
35+
36+
// Private global files pinia store
37+
_nc_files_pinia: Pinia
38+
}
39+
}

0 commit comments

Comments
 (0)