]> source.dussan.org Git - nextcloud-server.git/commitdiff
Hide version tab for folders
authorLouis Chemineau <louis@chmn.me>
Thu, 10 Nov 2022 09:07:07 +0000 (10:07 +0100)
committerLouis Chemineau <louis@chmn.me>
Mon, 28 Nov 2022 16:31:27 +0000 (17:31 +0100)
Signed-off-by: Louis Chemineau <louis@chmn.me>
apps/files_versions/src/files_versions_tab.js

index b4ab075b7a89926486984f9bfca2d1d486b1f731..28113d49c74782a5cf14fd0109e3b2f396825b43 100644 (file)
@@ -34,31 +34,36 @@ const View = Vue.extend(VersionTab)
 let TabInstance = null
 
 window.addEventListener('DOMContentLoaded', function () {
-       if (OCA.Files && OCA.Files.Sidebar) {
-               OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab({
-                       id: 'version_vue',
-                       name: t('files_versions', 'Version'),
-                       iconSvg: BackupRestore,
+       if (OCA.Files?.Sidebar === undefined) {
+               return
+       }
+
+       OCA.Files.Sidebar.registerTab(new OCA.Files.Sidebar.Tab({
+               id: 'version_vue',
+               name: t('files_versions', 'Version'),
+               iconSvg: BackupRestore,
 
-                       async mount(el, fileInfo, context) {
-                               if (TabInstance) {
-                                       TabInstance.$destroy()
-                               }
-                               TabInstance = new View({
-                                       // Better integration with vue parent component
-                                       parent: context,
-                               })
-                               // Only mount after we have all the info we need
-                               await TabInstance.update(fileInfo)
-                               TabInstance.$mount(el)
-                       },
-                       update(fileInfo) {
-                               TabInstance.update(fileInfo)
-                       },
-                       destroy() {
+               async mount(el, fileInfo, context) {
+                       if (TabInstance) {
                                TabInstance.$destroy()
-                               TabInstance = null
-                       },
-               }))
-       }
+                       }
+                       TabInstance = new View({
+                               // Better integration with vue parent component
+                               parent: context,
+                       })
+                       // Only mount after we have all the info we need
+                       await TabInstance.update(fileInfo)
+                       TabInstance.$mount(el)
+               },
+               update(fileInfo) {
+                       TabInstance.update(fileInfo)
+               },
+               destroy() {
+                       TabInstance.$destroy()
+                       TabInstance = null
+               },
+               enabled(fileInfo) {
+                       return !(fileInfo?.isDirectory() ?? true)
+               },
+       }))
 })