Skip to content

Commit 8cb30d6

Browse files
committed
refactor: use getSidebar() API in file upload handler
Update init.js file upload handler to use @nextcloud/files v4 sidebar API: - Import getSidebar() from @nextcloud/files - Replace window.OCA.Files.Sidebar with getSidebar() proxy - Use sidebar.setActiveTab() to activate LibreSign tab after upload - Add proper availability checks and error logging Signed-off-by: Vitor Mattos <[email protected]>
1 parent 48ef27a commit 8cb30d6

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/init.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import Vue from 'vue'
77

88
import axios from '@nextcloud/axios'
9-
import { addNewFileMenuEntry, Permission } from '@nextcloud/files'
9+
import { addNewFileMenuEntry, Permission, getSidebar } from '@nextcloud/files'
1010
import { registerDavProperty } from '@nextcloud/files/dav'
1111
import { translate, translatePlural } from '@nextcloud/l10n'
1212
import { generateOcsUrl } from '@nextcloud/router'
@@ -34,7 +34,7 @@ addNewFileMenuEntry({
3434
enabled() {
3535
return Permission.CREATE !== 0
3636
},
37-
async handler(context, content) {
37+
async handler(context, content) {s
3838
const input = document.createElement('input')
3939
input.accept = 'application/pdf'
4040
input.type = 'file'
@@ -54,9 +54,10 @@ addNewFileMenuEntry({
5454
name: upload.file.name,
5555
})
5656
.then(async ({ data }) => {
57-
await window.OCA.Files.Sidebar.open(path)
58-
OCA.Files.Sidebar.setActiveTab('libresign')
57+
sidebar.open({ path }, 'libresign')
58+
sidebar.setActiveTab('libresign')
5959
})
60+
.catch((error) => logger.error('Error uploading file:', error))
6061
})
6162
this.uploadManager
6263
.upload(file.name, file)

0 commit comments

Comments
 (0)