Skip to content
Draft
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
24 changes: 0 additions & 24 deletions apps/files_sharing/src/collaborationresourceshandler.js

This file was deleted.

28 changes: 28 additions & 0 deletions apps/files_sharing/src/collaborationresourceshandler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import { getCSPNonce } from '@nextcloud/auth'
import { FilePickerType, getFilePickerBuilder } from '@nextcloud/dialogs'
import { t } from '@nextcloud/l10n'

__webpack_nonce__ = getCSPNonce()

window.OCP.Collaboration.registerType('file', {
typeString: t('files_sharing', 'Link to a file'),
typeIconClass: 'icon-files-dark',
async action() {
const filePicker = getFilePickerBuilder(t('files_sharing', 'Link to a file'))
.setType(FilePickerType.Choose)
.allowDirectories(true)
.build()

try {
const [node] = await filePicker.pickNodes()
return node!.fileid
} catch {
throw new Error('Cannot get fileinfo')
}
},
})
32 changes: 26 additions & 6 deletions apps/files_sharing/src/services/FileInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import type { Attribute, INode } from '@nextcloud/files'

import { Permission } from '@nextcloud/files'

interface RawLegacyFileInfo {
id: number
path: string
Expand Down Expand Up @@ -57,13 +59,31 @@ export default function(node: INode): LegacyFileInfo {
attributes: node.attributes,
}

const fileInfo = new OC.Files.FileInfo(rawFileInfo)

// TODO remove when no more legacy backbone is used
fileInfo.get = (key) => fileInfo[key]
fileInfo.isDirectory = () => fileInfo.mimetype === 'httpd/unix-directory'
fileInfo.canEdit = () => Boolean(fileInfo.permissions & OC.PERMISSION_UPDATE)
fileInfo.node = node
const fileInfo: LegacyFileInfo = {
...rawFileInfo,
node,

get(key) {
return this[key]
},
isDirectory() {
return this.mimetype === 'httpd/unix-directory'
},
canEdit() {
return Boolean(this.permissions & Permission.UPDATE)
},
canDownload() {
for (const i in this.shareAttributes) {
const attr = this.shareAttributes[i]
if (attr.scope === 'permissions' && attr.key === 'download') {
return attr.value === true
}
}

return true
},
}

return fileInfo
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
/** @template-implements IEventListener<LoadSettingsScriptsEvent> */
class LoadAdditionalSettingsScriptsListener implements IEventListener {
public function handle(Event $event): void {
Util::addScript('core', 'files_fileinfo');
Util::addScript('core', 'files_client');
Util::addScript('core', 'systemtags');
Util::addScript(Application::APP_ID, 'workflowengine');
}
Expand Down
8 changes: 0 additions & 8 deletions build/eslint-baseline-legacy.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@
"count": 1
}
},
"core/src/OC/dialogs.js": {
"camelcase": {
"count": 33
},
"no-undef": {
"count": 1
}
},
"core/src/views/Login.vue": {
"vue/multi-word-component-names": {
"count": 1
Expand Down
Loading
Loading