Skip to content

Commit 46c2498

Browse files
authored
Merge pull request #6312 from LibreSign/feat/upgrade-nextcloud-files-v4
feat: upgrade nextcloud files v4
2 parents a5cb872 + 8cb30d6 commit 46c2498

6 files changed

Lines changed: 277 additions & 90 deletions

File tree

package-lock.json

Lines changed: 147 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"@nextcloud/capabilities": "^1.2.1",
3131
"@nextcloud/dialogs": "^6.4.1",
3232
"@nextcloud/event-bus": "^3.3.3",
33-
"@nextcloud/files": "^3.12.0",
33+
"@nextcloud/files": "^4.0.0-beta.8",
3434
"@nextcloud/initial-state": "^2.2.0",
3535
"@nextcloud/l10n": "^3.4.1",
3636
"@nextcloud/logger": "^3.0.2",

src/actions/openInLibreSignAction.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* SPDX-FileCopyrightText: 2020-2024 LibreCode coop and contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5-
import { registerFileAction, FileAction } from '@nextcloud/files'
5+
import { registerFileAction, FileAction, getSidebar } from '@nextcloud/files'
66
import { getCapabilities } from '@nextcloud/capabilities'
77
import { loadState } from '@nextcloud/initial-state'
88
import { translate as t } from '@nextcloud/l10n'
@@ -71,10 +71,9 @@ export const action = new FileAction({
7171
* Single file: open in sidebar
7272
*/
7373
async exec({ nodes }) {
74-
window.OCA.Files.Sidebar.close()
7574
const node = nodes[0]
76-
await window.OCA.Files.Sidebar.open(node.path)
77-
window.OCA.Files.Sidebar.setActiveTab('libresign')
75+
await sidebar.open(node, 'libresign')
76+
sidebar.setActiveTab('libresign')
7877
return null
7978
},
8079

@@ -103,16 +102,15 @@ export const action = new FileAction({
103102
settings: {
104103
path: envelopePath,
105104
},
106-
}).then((response) => {
105+
}).then(async (response) => {
107106
const envelopeData = response.data?.ocs?.data
108107

109108
window.OCA.Libresign.pendingEnvelope = envelopeData
110109

111-
window.OCA.Files.Sidebar.close()
112-
113-
window.OCA.Files.Sidebar.setActiveTab('libresign')
110+
const sidebar = getSidebar()
114111
const firstNode = nodes[0]
115-
window.OCA.Files.Sidebar.open(firstNode.path)
112+
await sidebar.open(firstNode, 'libresign')
113+
sidebar.setActiveTab('libresign')
116114

117115
return new Array(nodes.length).fill(null)
118116
}).catch((error) => {

src/actions/showStatusInlineAction.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* SPDX-FileCopyrightText: 2025 LibreCode coop and contributors
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
5-
import { FileAction, registerFileAction } from '@nextcloud/files'
5+
import { FileAction, registerFileAction, getSidebar } from '@nextcloud/files'
66
import { loadState } from '@nextcloud/initial-state'
77
import { t } from '@nextcloud/l10n'
88

@@ -26,8 +26,8 @@ const action = new FileAction({
2626
},
2727
exec: async ({ nodes }) => {
2828
const node = nodes[0]
29-
await window.OCA.Files.Sidebar.open(node.path)
30-
window.OCA.Files.Sidebar.setActiveTab('libresign')
29+
sidebar.open(node, 'libresign')
30+
sidebar.setActiveTab('libresign')
3131
return null
3232
},
3333
iconSvgInline: ({ nodes }) => {
@@ -48,7 +48,7 @@ const action = new FileAction({
4848
const certificateOk = loadState('libresign', 'certificate_ok')
4949
const allPdf = nodes?.length > 0 && nodes.every(node => node.mime === 'application/pdf')
5050
const allHaveStatus = nodes?.every(node => node.attributes['libresign-signature-status'])
51-
51+
5252
return certificateOk && allPdf && allHaveStatus
5353
},
5454
order: -1,

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)