@@ -25,41 +25,69 @@ import {
25
25
import SdkConfig from "../../../../../SdkConfig" ;
26
26
import { _t } from "../../../../../languageHandler" ;
27
27
import {
28
- getKeyboardShortcutDisplayName , getKeyboardShortcutValue ,
28
+ getKeyboardShortcutDisplayName ,
29
+ getKeyboardShortcutHideEditUI ,
30
+ getKeyboardShortcutValue ,
29
31
} from "../../../../../accessibility/KeyboardShortcutUtils" ;
30
32
import { KeyboardShortcut } from "../../KeyboardShortcut" ;
33
+ import AccessibleButton from "../../../elements/AccessibleButton" ;
34
+ import SettingsStore from "../../../../../settings/SettingsStore" ;
35
+ import { SettingLevel } from "../../../../../settings/SettingLevel" ;
31
36
32
37
interface IKeyboardShortcutRowProps {
33
38
name : string ;
39
+ allowCustomization : boolean ;
34
40
}
35
41
36
42
// Filter out the labs section if labs aren't enabled.
37
43
const visibleCategories = Object . entries ( CATEGORIES ) . filter ( ( [ categoryName ] ) =>
38
44
categoryName !== CategoryName . LABS || SdkConfig . get ( ) [ 'showLabsSettings' ] ) ;
39
45
40
- const KeyboardShortcutRow : React . FC < IKeyboardShortcutRowProps > = ( { name } ) => {
46
+ const KeyboardShortcutRow : React . FC < IKeyboardShortcutRowProps > = ( { name, allowCustomization } ) => {
41
47
const displayName = getKeyboardShortcutDisplayName ( name ) ;
48
+ const hideEditUI = getKeyboardShortcutHideEditUI ( name ) ;
42
49
const value = getKeyboardShortcutValue ( name ) ;
43
50
if ( ! displayName || ! value ) return null ;
44
51
52
+ const onEditClick = ( ) : void => {
53
+
54
+ } ;
55
+
56
+ const onResetClick = ( ) : void => {
57
+ SettingsStore . setValue ( name , null , SettingLevel . DEVICE , SettingsStore . getDefaultValue ( name ) ) ;
58
+ } ;
59
+
45
60
return < div className = "mx_KeyboardShortcut_shortcutRow" >
46
- { displayName }
61
+ < div className = "mx_KeyboardShortcut_shortcutRow_displayName" >
62
+ { displayName }
63
+ </ div >
47
64
< KeyboardShortcut value = { value } />
65
+ { allowCustomization && < React . Fragment >
66
+ < AccessibleButton kind = "primary_outline" disabled = { hideEditUI } onClick = { onEditClick } > { _t ( "Edit" ) } </ AccessibleButton >
67
+ < AccessibleButton kind = "primary_outline" disabled = { hideEditUI } onClick = { onResetClick } > { _t ( "Reset" ) } </ AccessibleButton >
68
+ </ React . Fragment > }
48
69
</ div > ;
49
70
} ;
50
71
51
72
interface IKeyboardShortcutSectionProps {
52
73
categoryName : CategoryName ;
53
74
category : ICategory ;
75
+ allowCustomization : boolean ;
54
76
}
55
77
56
- const KeyboardShortcutSection : React . FC < IKeyboardShortcutSectionProps > = ( { categoryName, category } ) => {
78
+ const KeyboardShortcutSection : React . FC < IKeyboardShortcutSectionProps > = (
79
+ { categoryName, category, allowCustomization } ,
80
+ ) => {
57
81
if ( ! category . categoryLabel ) return null ;
58
82
59
83
return < div className = "mx_SettingsTab_section" key = { categoryName } >
60
84
< div className = "mx_SettingsTab_subheading" > { _t ( category . categoryLabel ) } </ div >
61
85
< div > { category . settingNames . map ( ( shortcutName ) => {
62
- return < KeyboardShortcutRow key = { shortcutName } name = { shortcutName } /> ;
86
+ return < KeyboardShortcutRow
87
+ key = { shortcutName }
88
+ name = { shortcutName }
89
+ allowCustomization = { allowCustomization }
90
+ /> ;
63
91
} ) } </ div >
64
92
</ div > ;
65
93
} ;
@@ -68,7 +96,12 @@ const KeyboardUserSettingsTab: React.FC = () => {
68
96
return < div className = "mx_SettingsTab mx_KeyboardUserSettingsTab" >
69
97
< div className = "mx_SettingsTab_heading" > { _t ( "Keyboard" ) } </ div >
70
98
{ visibleCategories . map ( ( [ categoryName , category ] : [ CategoryName , ICategory ] ) => {
71
- return < KeyboardShortcutSection key = { categoryName } categoryName = { categoryName } category = { category } /> ;
99
+ return < KeyboardShortcutSection
100
+ key = { categoryName }
101
+ categoryName = { categoryName }
102
+ category = { category }
103
+ allowCustomization = { SettingsStore . getValue ( "feature_customizable_keybindings" ) }
104
+ /> ;
72
105
} ) }
73
106
</ div > ;
74
107
} ;
0 commit comments