aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src/files_headers/noteToRecipient.ts
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-07-30 18:52:59 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-07-31 15:05:15 +0200
commitd6518196cc9c855e11535e9cb3cb48156741b5de (patch)
treed59b2c309e8eb722908294cfcb29d7f2fe4177a1 /apps/files_sharing/src/files_headers/noteToRecipient.ts
parent6a0edef4dab3029d49ce5fbf03103ba2e01c8d2d (diff)
downloadnextcloud-server-d6518196cc9c855e11535e9cb3cb48156741b5de.tar.gz
nextcloud-server-d6518196cc9c855e11535e9cb3cb48156741b5de.zip
fix(files_sharing): Add missing "note to recipient"
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files_sharing/src/files_headers/noteToRecipient.ts')
-rw-r--r--apps/files_sharing/src/files_headers/noteToRecipient.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/apps/files_sharing/src/files_headers/noteToRecipient.ts b/apps/files_sharing/src/files_headers/noteToRecipient.ts
new file mode 100644
index 00000000000..31e383d3634
--- /dev/null
+++ b/apps/files_sharing/src/files_headers/noteToRecipient.ts
@@ -0,0 +1,38 @@
+/**
+ * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+import type { ComponentPublicInstance, VueConstructor } from 'vue'
+
+import { Folder, Header, registerFileListHeaders } from '@nextcloud/files'
+import Vue from 'vue'
+
+type IFilesHeaderNoteToRecipient = ComponentPublicInstance & { updateFolder: (folder: Folder) => void }
+
+/**
+ * Register the "note to recipient" as a files list header
+ */
+export default function registerNoteToRecipient() {
+ let FilesHeaderNoteToRecipient: VueConstructor
+ let instance: IFilesHeaderNoteToRecipient
+
+ registerFileListHeaders(new Header({
+ id: 'note-to-recipient',
+ order: 0,
+ // Always if there is a note
+ enabled: (folder: Folder) => Boolean(folder.attributes.note),
+ // Update the root folder if needed
+ updated: (folder: Folder) => {
+ instance.updateFolder(folder)
+ },
+ // render simply spawns the component
+ render: async (el: HTMLElement, folder: Folder) => {
+ if (FilesHeaderNoteToRecipient === undefined) {
+ const { default: component } = await import('../views/FilesHeaderNoteToRecipient.vue')
+ FilesHeaderNoteToRecipient = Vue.extend(component)
+ }
+ instance = new FilesHeaderNoteToRecipient().$mount(el) as unknown as IFilesHeaderNoteToRecipient
+ instance.updateFolder(folder)
+ },
+ }))
+}