@@ -14,6 +14,7 @@ import styled from '../../../design/lib/styled'
14
14
import { inputStyle } from '../../../design/lib/styled/styleFunctions'
15
15
import cc from 'classcat'
16
16
import { useToast } from '../../../design/lib/stores/toast'
17
+ import { useElectron } from '../../lib/stores/electron'
17
18
18
19
const invalidShortcutInputs = [ ' ' ]
19
20
const rejectedShortcutInputs = [ ' ' , 'control' , 'alt' , 'shift' , 'meta' ]
@@ -28,6 +29,7 @@ interface KeymapItemSectionProps {
28
29
) => Promise < void >
29
30
removeKeymap : ( key : string ) => void
30
31
description : string
32
+ desktopOnly : boolean
31
33
}
32
34
33
35
const KeymapItemSection = ( {
@@ -36,6 +38,7 @@ const KeymapItemSection = ({
36
38
updateKeymap,
37
39
removeKeymap,
38
40
description,
41
+ desktopOnly,
39
42
} : KeymapItemSectionProps ) => {
40
43
const [ inputError , setInputError ] = useState < boolean > ( false )
41
44
const [ shortcutInputValue , setShortcutInputValue ] = useState < string > ( '' )
@@ -53,6 +56,7 @@ const KeymapItemSection = ({
53
56
const shortcutInputRef = useRef < HTMLInputElement > ( null )
54
57
55
58
const { pushMessage } = useToast ( )
59
+ const { usingElectron } = useElectron ( )
56
60
57
61
const fetchInputShortcuts : KeyboardEventHandler < HTMLInputElement > = (
58
62
event
@@ -137,6 +141,9 @@ const KeymapItemSection = ({
137
141
? getGenericShortcutString ( currentKeymapItem )
138
142
: ''
139
143
} , [ currentKeymapItem , currentShortcut ] )
144
+
145
+ const isEditableKeymap = ! desktopOnly || ( desktopOnly && usingElectron )
146
+
140
147
return (
141
148
< KeymapItemSectionContainer >
142
149
< div > { description } </ div >
@@ -155,18 +162,22 @@ const KeymapItemSection = ({
155
162
onKeyDown = { fetchInputShortcuts }
156
163
/>
157
164
) }
158
- < Button variant = { 'primary' } onClick = { toggleChangingShortcut } >
159
- { currentShortcut == null
160
- ? 'Assign'
161
- : changingShortcut
162
- ? 'Apply'
163
- : 'Change' }
164
- </ Button >
165
- { changingShortcut && (
165
+ { ! isEditableKeymap ? (
166
+ < div > Desktop App Only</ div >
167
+ ) : (
168
+ < Button variant = { 'primary' } onClick = { toggleChangingShortcut } >
169
+ { currentShortcut == null
170
+ ? 'Assign'
171
+ : changingShortcut
172
+ ? 'Apply'
173
+ : 'Change' }
174
+ </ Button >
175
+ ) }
176
+ { isEditableKeymap && changingShortcut && (
166
177
< Button onClick = { handleCancelKeymapChange } > Cancel</ Button >
167
178
) }
168
179
169
- { currentShortcut != null && ! changingShortcut && (
180
+ { isEditableKeymap && currentShortcut != null && ! changingShortcut && (
170
181
< Button onClick = { handleRemoveKeymap } > Un-assign</ Button >
171
182
) }
172
183
</ KeymapItemInputSection >
0 commit comments