Work towards unifying KeyboardShortcuts and KeyBindingsDefaults #1 (#7651)

This commit is contained in:
Šimon Brandner 2022-01-27 12:37:53 +01:00 committed by GitHub
parent f2249b3e37
commit 57a5647079
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 237 additions and 139 deletions

View file

@ -18,7 +18,7 @@ limitations under the License.
import React from "react";
import {
KEYBOARD_SHORTCUTS,
getKeyboardShortcuts,
ALTERNATE_KEY_NAME,
KEY_ICON,
ICategory,
@ -29,6 +29,15 @@ import SdkConfig from "../../../../../SdkConfig";
import { isMac, Key } from "../../../../../Keyboard";
import { _t } from "../../../../../languageHandler";
// TODO: This should return KeyCombo but it has ctrlOrCmd instead of ctrlOrCmdKey
const getKeyboardShortcutValue = (name: string) => {
return getKeyboardShortcuts()[name]?.default;
};
const getKeyboardShortcutDisplayName = (name: string): string => {
return getKeyboardShortcuts()[name]?.displayName as string;
};
interface IKeyboardKeyProps {
name: string;
last?: boolean;
@ -49,7 +58,7 @@ interface IKeyboardShortcutProps {
}
export const KeyboardShortcut: React.FC<IKeyboardShortcutProps> = ({ name }) => {
const value = KEYBOARD_SHORTCUTS[name]?.default;
const value = getKeyboardShortcutValue(name);
if (!value) return null;
const modifiersElement = [];
@ -83,7 +92,7 @@ const visibleCategories = Object.entries(CATEGORIES).filter(([categoryName]) =>
const KeyboardShortcutRow: React.FC<IKeyboardShortcutRowProps> = ({ name }) => {
return <div className="mx_KeyboardShortcut_shortcutRow">
{ KEYBOARD_SHORTCUTS[name].displayName }
{ getKeyboardShortcutDisplayName(name) }
<KeyboardShortcut name={name} />
</div>;
};