diff --git a/apps/files/src/main.ts b/apps/files/src/main.ts index 463ecaf6239..b7751839939 100644 --- a/apps/files/src/main.ts +++ b/apps/files/src/main.ts @@ -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 - _nc_files_pinia: Pinia - } -} - // Init private and public Files namespace window.OCA.Files = window.OCA.Files ?? {} window.OCP.Files = window.OCP.Files ?? {} diff --git a/apps/files_sharing/src/files_actions/sharingStatusAction.ts b/apps/files_sharing/src/files_actions/sharingStatusAction.ts index 18fa46d2781..ed562db5953 100644 --- a/apps/files_sharing/src/files_actions/sharingStatusAction.ts +++ b/apps/files_sharing/src/files_actions/sharingStatusAction.ts @@ -132,7 +132,7 @@ export const action = new FileAction({ // 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) + return await sidebarAction.exec(node, view, dir) } return null }, diff --git a/window.d.ts b/window.d.ts new file mode 100644 index 00000000000..d6499577106 --- /dev/null +++ b/window.d.ts @@ -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 + 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 // 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 + } +}