@@ -12,8 +12,9 @@ import { fileStatus } from '../helpers/fileStatus.js'
1212const 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