Skip to content

Commit 282ff04

Browse files
committed
fix(files-app): add null checks to prevent undefined errors in status icon
Signed-off-by: Vitor Mattos <[email protected]>
1 parent a0b77ab commit 282ff04

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/actions/showStatusInlineAction.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,24 @@ const action = new FileAction({
1717

1818
const signedNodeId = node.attributes['signed-node-id']
1919

20-
return !signedNodeId || node.fileid === signedNodeId
21-
? fileStatus.find(status => status.id === node.attributes['signature-status']).label
22-
: t('libresign', 'original file')
20+
if (!signedNodeId || node.fileid === signedNodeId) {
21+
const status = fileStatus.find(status => status.id === node.attributes['signature-status'])
22+
return status?.label ?? ''
23+
}
24+
return t('libresign', 'original file')
2325
},
2426
exec: async () => null,
2527
iconSvgInline: (nodes) => {
2628
const node = nodes[0]
2729

2830
const signedNodeId = node.attributes['signed-node-id']
2931

30-
return !signedNodeId || node.fileid === signedNodeId
31-
? fileStatus.find(status => status.id === node.attributes['signature-status']).icon
32-
: fileStatus.find(status => status.id === SIGN_STATUS.ABLE_TO_SIGN).icon
32+
if (!signedNodeId || node.fileid === signedNodeId) {
33+
const status = fileStatus.find(status => status.id === node.attributes['signature-status'])
34+
return status?.icon ?? ''
35+
}
36+
const ableToSignStatus = fileStatus.find(status => status.id === SIGN_STATUS.ABLE_TO_SIGN)
37+
return ableToSignStatus?.icon ?? ''
3338
},
3439
inline: () => true,
3540
enabled: (nodes) => {

0 commit comments

Comments
 (0)