1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { VueConstructor } from 'vue'
import { Folder, Permission, View, davRemoteURL, davRootPath, getNavigation } from '@nextcloud/files'
import { loadState } from '@nextcloud/initial-state'
import { translate as t } from '@nextcloud/l10n'
import svgCloudUpload from '@mdi/svg/svg/cloud-upload.svg?raw'
import Vue from 'vue'
export default () => {
const foldername = loadState<string>('files_sharing', 'filename')
let FilesViewFileDropEmptyContent: VueConstructor
let fileDropEmptyContentInstance: Vue
const view = new View({
id: 'public-file-drop',
name: t('files_sharing', 'File drop'),
caption: t('files_sharing', 'Upload files to {foldername}', { foldername }),
icon: svgCloudUpload,
order: 1,
emptyView: async (div: HTMLDivElement) => {
if (FilesViewFileDropEmptyContent === undefined) {
const { default: component } = await import('../views/FilesViewFileDropEmptyContent.vue')
FilesViewFileDropEmptyContent = Vue.extend(component)
}
if (fileDropEmptyContentInstance) {
fileDropEmptyContentInstance.$destroy()
}
fileDropEmptyContentInstance = new FilesViewFileDropEmptyContent({
propsData: {
foldername,
},
})
fileDropEmptyContentInstance.$mount(div)
},
getContents: async () => {
return {
contents: [],
// Fake a writeonly folder as root
folder: new Folder({
id: 0,
source: `${davRemoteURL}${davRootPath}`,
root: davRootPath,
owner: null,
permissions: Permission.CREATE,
}),
}
},
})
const Navigation = getNavigation()
Navigation.register(view)
}
|