Skip to content

Commit a869bb8

Browse files
authored
Merge pull request #6297 from LibreSign/fix/nextcloud-33-file-action-api
fix: nextcloud 33 file action api
2 parents d889270 + 55fa2cc commit a869bb8

2 files changed

Lines changed: 24 additions & 27 deletions

File tree

src/actions/openInLibreSignAction.js

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,17 @@ export const action = new FileAction({
1515
displayName: () => t('libresign', 'Open in LibreSign'),
1616
iconSvgInline: () => SvgIcon,
1717

18-
enabled(nodes) {
19-
return loadState('libresign', 'certificate_ok')
20-
&& nodes.length > 0 && nodes
21-
.map(node => node.mime)
22-
.every(mime => mime === 'application/pdf')
18+
enabled({ nodes }) {
19+
const certificateOk = loadState('libresign', 'certificate_ok')
20+
const allPdf = nodes?.length > 0 && nodes.every(node => node.mime === 'application/pdf')
21+
return certificateOk && allPdf
2322
},
2423

25-
async exec(node) {
26-
try {
27-
await window.OCA.Files.Sidebar.open(node.path)
28-
OCA.Files.Sidebar.setActiveTab('libresign')
29-
return null
30-
} catch (error) {
31-
logger.error('Error while opening sidebar', { error })
32-
return false
33-
}
24+
async exec({ nodes }) {
25+
const node = nodes[0]
26+
await window.OCA.Files.Sidebar.open(node.path)
27+
window.OCA.Files.Sidebar.setActiveTab('libresign')
28+
return null
3429
},
3530

3631
order: -1000,

src/actions/showStatusInlineAction.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import { fileStatus } from '../helpers/fileStatus.js'
1212
const action = new FileAction({
1313
id: 'show-status-inline',
1414
displayName: () => '',
15-
title: (nodes) => {
16-
const node = nodes[0]
15+
title: ({ nodes }) => {
16+
const node = nodes?.[0]
17+
if (!node) return ''
1718

1819
const signedNodeId = node.attributes['libresign-signed-node-id']
1920

@@ -23,13 +24,15 @@ const action = new FileAction({
2324
}
2425
return t('libresign', 'original file')
2526
},
26-
exec: async (node) => {
27+
exec: async ({ nodes }) => {
28+
const node = nodes[0]
2729
await window.OCA.Files.Sidebar.open(node.path)
28-
OCA.Files.Sidebar.setActiveTab('libresign')
30+
window.OCA.Files.Sidebar.setActiveTab('libresign')
2931
return null
3032
},
31-
iconSvgInline: (nodes) => {
32-
const node = nodes[0]
33+
iconSvgInline: ({ nodes }) => {
34+
const node = nodes?.[0]
35+
if (!node) return ''
3336

3437
const signedNodeId = node.attributes['libresign-signed-node-id']
3538

@@ -41,13 +44,12 @@ const action = new FileAction({
4144
return ableToSignStatus?.icon ?? ''
4245
},
4346
inline: () => true,
44-
enabled: (nodes) => {
45-
return loadState('libresign', 'certificate_ok')
46-
&& nodes.length > 0
47-
&& nodes
48-
.map(node => node.mime)
49-
.every(mime => mime === 'application/pdf')
50-
&& nodes.every(node => node.attributes['libresign-signature-status'])
47+
enabled: ({ nodes }) => {
48+
const certificateOk = loadState('libresign', 'certificate_ok')
49+
const allPdf = nodes?.length > 0 && nodes.every(node => node.mime === 'application/pdf')
50+
const allHaveStatus = nodes?.every(node => node.attributes['libresign-signature-status'])
51+
52+
return certificateOk && allPdf && allHaveStatus
5153
},
5254
order: -1,
5355
})

0 commit comments

Comments
 (0)