aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src/new/newFileRequest.ts
blob: b7e5b3f2144bd230843c1e4bd1e0bb2ce8fec19c (plain)
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
/**
 * SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
import type { Entry, Folder, Node } from '@nextcloud/files'

import { translate as t } from '@nextcloud/l10n'
import Vue, { defineAsyncComponent } from 'vue'
import FileUploadSvg from '@mdi/svg/svg/file-upload.svg?raw'

const NewFileRequestDialogVue = defineAsyncComponent(() => import('../components/NewFileRequestDialog.vue'))

export const entry = {
	id: 'file-request',
	displayName: t('files', 'Create new file request'),
	iconSvgInline: FileUploadSvg,
	order: 30,
	enabled(): boolean {
		// TODO: determine requirements
		// 1. user can share the root folder
		// 2. OR user can create subfolders ?
		return true
	},
	async handler(context: Folder, content: Node[]) {
		// Create document root
		const mountingPoint = document.createElement('div')
		mountingPoint.id = 'file-request-dialog'
		document.body.appendChild(mountingPoint)

		// Init vue app
		const NewFileRequestDialog = new Vue({
			name: 'NewFileRequestDialogRoot',
			render: (h) => h(
				NewFileRequestDialogVue,
				{
					props: {
						context,
						content,
					},
					on: {
						close: () => {
							NewFileRequestDialog.$destroy()
						},
					},
				},
			),
			el: mountingPoint,
		})
	},
} as Entry