diff --git a/.eslintrc.js b/.eslintrc.js index 413dc33ce..b3164ad1d 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -51,6 +51,7 @@ module.exports = { "no-underscore-dangle": "off", // we should not use _ in variables in any case "react/require-default-props": "off", "react/function-component-definition": "off", + "import/prefer-default-export": "off", }, ignorePatterns: ["/*", "!/src"], // we only care about linting src folder }; diff --git a/src/api/keymap/db/wireless.js b/src/api/keymap/db/wireless.js index add811c70..43921cbd8 100644 --- a/src/api/keymap/db/wireless.js +++ b/src/api/keymap/db/wireless.js @@ -13,12 +13,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +import { BatteryCodes } from "../../../hw/battery"; +import { RFCodes } from "../../../hw/rf"; +import { BluetoothCodes } from "../../../hw/bluetooth"; +import { EnergyCodes } from "../../../hw/energy"; const Battery = { groupName: "Battery", keys: [ { - code: 54108, + code: BatteryCodes.STATUS, labels: { top: "BATT.", primary: "LEVEL", @@ -30,17 +34,10 @@ const Bluetooth = { groupName: "Bluetooth", keys: [ { - code: 54109, + code: BluetoothCodes.PAIRING, labels: { top: "BLUET.", - primary: "STAT.", - }, - }, - { - code: 54110, - labels: { - top: "BLUET.", - primary: "DISC.", + primary: "PAIR.", }, }, ], @@ -49,7 +46,7 @@ const Energy = { groupName: "Energy", keys: [ { - code: 54111, + code: EnergyCodes.STATUS, labels: { top: "ENERGY", primary: "STATUS", @@ -61,7 +58,7 @@ const RF = { groupName: "RF", keys: [ { - code: 54112, + code: RFCodes.STATUS, labels: { top: "RF", primary: "STATUS", diff --git a/src/hw/battery.ts b/src/hw/battery.ts new file mode 100644 index 000000000..2b6f83937 --- /dev/null +++ b/src/hw/battery.ts @@ -0,0 +1,3 @@ +export enum BatteryCodes { + STATUS = 54108, +} diff --git a/src/hw/bluetooth.ts b/src/hw/bluetooth.ts new file mode 100644 index 000000000..97beece99 --- /dev/null +++ b/src/hw/bluetooth.ts @@ -0,0 +1,3 @@ +export enum BluetoothCodes { + PAIRING = 54109, +} diff --git a/src/hw/energy.ts b/src/hw/energy.ts new file mode 100644 index 000000000..52573791e --- /dev/null +++ b/src/hw/energy.ts @@ -0,0 +1,3 @@ +export enum EnergyCodes { + STATUS = 54111, +} diff --git a/src/hw/rf.ts b/src/hw/rf.ts new file mode 100644 index 000000000..78bd1956a --- /dev/null +++ b/src/hw/rf.ts @@ -0,0 +1,3 @@ +export enum RFCodes { + STATUS = 54112, +} diff --git a/src/main/utils/udev.ts b/src/main/utils/udev.ts index 8a4993174..bcac81108 100644 --- a/src/main/utils/udev.ts +++ b/src/main/utils/udev.ts @@ -11,15 +11,15 @@ const checkUdev = () => { try { if (fs.existsSync(filename)) { const currentUdevRules = fs.readFileSync(filename, "utf-8"); - if (currentUdevRules !== udevRulesToWrite) { + if (currentUdevRules.trim() !== udevRulesToWrite.trim()) { return false; } return true; } } catch (err) { console.error(err); - return false; } + return false; }; const installUdev = (mainWindow: BrowserWindow) => { diff --git a/src/renderer/component/Select/SelectWirelessDropdown.tsx b/src/renderer/component/Select/SelectWirelessDropdown.tsx index 38418fefc..ade2a2b36 100644 --- a/src/renderer/component/Select/SelectWirelessDropdown.tsx +++ b/src/renderer/component/Select/SelectWirelessDropdown.tsx @@ -4,6 +4,8 @@ import Dropdown from "react-bootstrap/Dropdown"; import i18n from "@Renderer/i18n"; import { SelectWirelessDropdownProps, WirelessButton } from "@Renderer/types/wireless"; +import { BluetoothCodes } from "@Renderer/../hw/bluetooth"; +import { BatteryCodes } from "@Renderer/../hw/battery"; const Style = Styled.div` width: 100%; @@ -137,12 +139,16 @@ width: 100%; } `; +enum WirelessButtonOrder { + BATTERY_LEVEL = 0, + PAIRING_MODE = 1, +} + function SelectWirelessDropdown(props: SelectWirelessDropdownProps) { const { keyCode, onKeySelect } = props; const WirelessButtons: Array = [ - { name: i18n.editor.standardView.wireless.batteryLevel, keynum: 54108 }, - { name: i18n.wireless.bluetooth.StatusButton, keynum: 54109 }, - { name: i18n.wireless.bluetooth.pairingModeButton, keynum: 54110 }, + { name: i18n.editor.standardView.wireless.batteryLevel, keynum: BatteryCodes.STATUS }, + { name: i18n.wireless.bluetooth.pairingModeButton, keynum: BluetoothCodes.PAIRING }, ]; const KC: number = keyCode.base + keyCode.modified; // const verifiedKC = WirelessButtons.findIndex((param: WirelessButton) => param.keynum === KC); @@ -169,29 +175,17 @@ function SelectWirelessDropdown(props: SelectWirelessDropdownProps) {
-
{WirelessButtons[0].name}
-
-
- -
-
- Bluetooth {i18n.wireless.bluetooth.StatusTitle} -
-
- -
{WirelessButtons[1].name}
+
{WirelessButtons[WirelessButtonOrder.BATTERY_LEVEL].name}
@@ -201,13 +195,15 @@ function SelectWirelessDropdown(props: SelectWirelessDropdownProps) {
-
{WirelessButtons[2].name}
+
{WirelessButtons[WirelessButtonOrder.PAIRING_MODE].name}
diff --git a/src/renderer/i18n/en.js b/src/renderer/i18n/en.js index 619c37412..6fae94bd1 100644 --- a/src/renderer/i18n/en.js +++ b/src/renderer/i18n/en.js @@ -478,8 +478,6 @@ const English = { wireless: { title: "Wireless", bluetooth: { - StatusTitle: "Status", - StatusButton: "Bluetooth Status", pairingMode: "Pairing mode", pairingModeButton: "Bluetooth Pairing Mode", pairingModeDescription: "Activate Pairing Mode for easy device connection.", diff --git a/src/renderer/modules/KeysTabs/WirelessTab.tsx b/src/renderer/modules/KeysTabs/WirelessTab.tsx index e52aef6ca..1f78800f1 100644 --- a/src/renderer/modules/KeysTabs/WirelessTab.tsx +++ b/src/renderer/modules/KeysTabs/WirelessTab.tsx @@ -8,6 +8,8 @@ import i18n from "@Renderer/i18n"; import Title from "@Renderer/component/Title"; import Callout from "@Renderer/component/Callout"; import { ButtonConfig } from "@Renderer/component/Button"; +import { BatteryCodes } from "@Renderer/../hw/battery"; +import { BluetoothCodes } from "@Renderer/../hw/bluetooth"; const Styles = Styled.div` width: 100%; @@ -48,30 +50,9 @@ function WirelessTab(props: TabLayoutEditorProps) { { - onKeySelect(54108); + onKeySelect(BatteryCodes.STATUS); }} - selected={isStandardView ? keyCode === 54108 : false} - size={undefined} - tooltip={undefined} - tooltipPlacement={undefined} - tooltipClassName={undefined} - variation={undefined} - icoSVG={undefined} - icoPosition={undefined} - tooltipDelay={undefined} - disabled={undefined} - dataAnimate={undefined} - /> - -
- - <p className="description">{i18n.editor.standardView.wireless.savingModeDescription}</p> - <ButtonConfig - buttonText={i18n.general.onOff} - onClick={() => { - onKeySelect(54109); - }} - selected={isStandardView ? keyCode === 54109 : false} + selected={isStandardView ? keyCode === BatteryCodes.STATUS : false} size={undefined} tooltip={undefined} tooltipPlacement={undefined} @@ -90,9 +71,9 @@ function WirelessTab(props: TabLayoutEditorProps) { <ButtonConfig buttonText={i18n.wireless.bluetooth.pair} onClick={() => { - onKeySelect(54110); + onKeySelect(BluetoothCodes.PAIRING); }} - selected={isStandardView ? keyCode === 54110 : false} + selected={isStandardView ? keyCode === BluetoothCodes.PAIRING : false} size={undefined} tooltip={undefined} tooltipPlacement={undefined} diff --git a/src/renderer/types/energy.ts b/src/renderer/types/energy.ts new file mode 100644 index 000000000..e69de29bb