@@ -58,6 +58,28 @@ const switchLock = async (node: Node) => {
58
58
}
59
59
}
60
60
61
+ const getLockStateIcon = ( node : Node ) => {
62
+ const state = getLockStateFromAttributes ( node )
63
+
64
+ if ( ! state . isLocked ) {
65
+ return ''
66
+ }
67
+
68
+ if ( state . lockOwnerType === LockType . Token ) {
69
+ return LockMonitorSvg
70
+ }
71
+
72
+ if ( state . lockOwnerType === LockType . App ) {
73
+ return LockEditSvg
74
+ }
75
+
76
+ if ( state . lockOwner !== getCurrentUser ( ) ?. uid ) {
77
+ return LockAccountSvg
78
+ }
79
+
80
+ return LockSvg
81
+ }
82
+
61
83
const inlineAction = new FileAction ( {
62
84
id : 'lock_inline' ,
63
85
title : ( nodes : Node [ ] ) => nodes . length === 1 ? getInfoLabel ( nodes [ 0 ] ) : '' ,
@@ -68,44 +90,43 @@ const inlineAction = new FileAction({
68
90
69
91
iconSvgInline ( nodes : Node [ ] ) {
70
92
const node = nodes [ 0 ]
93
+ return getLockStateIcon ( node )
94
+ } ,
71
95
72
- const state = getLockStateFromAttributes ( node )
73
-
74
- if ( ! state . isLocked ) {
75
- return ''
76
- }
77
-
78
- if ( state . lockOwnerType === LockType . Token ) {
79
- return LockMonitorSvg
80
- }
81
-
82
- if ( state . lockOwnerType === LockType . App ) {
83
- return LockEditSvg
96
+ enabled ( nodes : Node [ ] ) {
97
+ // Only works on single node
98
+ if ( nodes . length !== 1 ) {
99
+ return false
84
100
}
85
101
86
- if ( state . lockOwner !== getCurrentUser ( ) ?. uid ) {
87
- return LockAccountSvg
88
- }
102
+ const node = nodes [ 0 ]
103
+ const state = getLockStateFromAttributes ( node )
89
104
90
- return LockSvg
105
+ return state . isLocked
91
106
} ,
107
+ } )
92
108
109
+ const menuInfo = new FileAction ( {
110
+ id : 'lock_info' ,
111
+ order : 25 ,
112
+ displayName : ( nodes : Node [ ] ) => getInfoLabel ( nodes [ 0 ] ) ,
113
+ iconSvgInline : ( nodes : Node [ ] ) => {
114
+ const node = nodes [ 0 ]
115
+ return getLockStateIcon ( node )
116
+ } ,
93
117
enabled ( nodes : Node [ ] ) {
94
118
// Only works on single node
95
119
if ( nodes . length !== 1 ) {
96
120
return false
97
121
}
98
-
99
122
const node = nodes [ 0 ]
100
123
const state = getLockStateFromAttributes ( node )
101
-
102
124
return state . isLocked
103
125
} ,
126
+ async exec ( ) { } ,
104
127
} )
105
-
106
128
const menuAction = new FileAction ( {
107
129
id : 'lock' ,
108
- title : ( nodes : Node [ ] ) => getInfoLabel ( nodes [ 0 ] ) ,
109
130
order : 25 ,
110
131
111
132
iconSvgInline ( nodes : Node [ ] ) {
@@ -166,4 +187,5 @@ const menuAction = new FileAction({
166
187
} )
167
188
168
189
registerFileAction ( inlineAction )
190
+ registerFileAction ( menuInfo )
169
191
registerFileAction ( menuAction )
0 commit comments