@@ -14,6 +14,7 @@ import styled from '../../../design/lib/styled'
1414import { inputStyle } from '../../../design/lib/styled/styleFunctions'
1515import cc from 'classcat'
1616import { useToast } from '../../../design/lib/stores/toast'
17+ import { useElectron } from '../../lib/stores/electron'
1718
1819const invalidShortcutInputs = [ ' ' ]
1920const rejectedShortcutInputs = [ ' ' , 'control' , 'alt' , 'shift' , 'meta' ]
@@ -28,6 +29,7 @@ interface KeymapItemSectionProps {
2829 ) => Promise < void >
2930 removeKeymap : ( key : string ) => void
3031 description : string
32+ desktopOnly : boolean
3133}
3234
3335const KeymapItemSection = ( {
@@ -36,6 +38,7 @@ const KeymapItemSection = ({
3638 updateKeymap,
3739 removeKeymap,
3840 description,
41+ desktopOnly,
3942} : KeymapItemSectionProps ) => {
4043 const [ inputError , setInputError ] = useState < boolean > ( false )
4144 const [ shortcutInputValue , setShortcutInputValue ] = useState < string > ( '' )
@@ -53,6 +56,7 @@ const KeymapItemSection = ({
5356 const shortcutInputRef = useRef < HTMLInputElement > ( null )
5457
5558 const { pushMessage } = useToast ( )
59+ const { usingElectron } = useElectron ( )
5660
5761 const fetchInputShortcuts : KeyboardEventHandler < HTMLInputElement > = (
5862 event
@@ -137,6 +141,9 @@ const KeymapItemSection = ({
137141 ? getGenericShortcutString ( currentKeymapItem )
138142 : ''
139143 } , [ currentKeymapItem , currentShortcut ] )
144+
145+ const isEditableKeymap = ! desktopOnly || ( desktopOnly && usingElectron )
146+
140147 return (
141148 < KeymapItemSectionContainer >
142149 < div > { description } </ div >
@@ -155,18 +162,22 @@ const KeymapItemSection = ({
155162 onKeyDown = { fetchInputShortcuts }
156163 />
157164 ) }
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 && (
166177 < Button onClick = { handleCancelKeymapChange } > Cancel</ Button >
167178 ) }
168179
169- { currentShortcut != null && ! changingShortcut && (
180+ { isEditableKeymap && currentShortcut != null && ! changingShortcut && (
170181 < Button onClick = { handleRemoveKeymap } > Un-assign</ Button >
171182 ) }
172183 </ KeymapItemInputSection >
0 commit comments