Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions apps/files/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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 ?? {}
Expand Down
11 changes: 10 additions & 1 deletion apps/files_sharing/src/files_actions/sharingStatusAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO its better to await it here so that we can trust all work is done and not pending branches exist

Suggested change
sidebarAction.exec(node, view, dir)
await sidebarAction.exec(node, view, dir)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought about it, I kinda thought I would be confortable awaiting for the sidebar when we'll have it properly re-written with the right api and Node usage 🙈

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
},

Expand Down
1 change: 1 addition & 0 deletions build/files-checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
'webpack.common.js',
'webpack.config.js',
'webpack.modules.js',
'window.d.ts',
];
$actualFiles = [];

Expand Down
2 changes: 1 addition & 1 deletion dist/files-main.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files_sharing-init.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files_sharing-init.js.map

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions window.d.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Needs to be added to the release script

Original file line number Diff line number Diff line change
@@ -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
}
}
Loading