Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove bluetooth status #499

Merged
merged 6 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
21 changes: 9 additions & 12 deletions src/api/keymap/db/wireless.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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",
Expand All @@ -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.",
},
},
],
Expand All @@ -49,7 +46,7 @@ const Energy = {
groupName: "Energy",
keys: [
{
code: 54111,
code: EnergyCodes.STATUS,
labels: {
top: "ENERGY",
primary: "STATUS",
Expand All @@ -61,7 +58,7 @@ const RF = {
groupName: "RF",
keys: [
{
code: 54112,
code: RFCodes.STATUS,
labels: {
top: "RF",
primary: "STATUS",
Expand Down
3 changes: 3 additions & 0 deletions src/hw/battery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum BatteryCodes {
STATUS = 54108,
}
3 changes: 3 additions & 0 deletions src/hw/bluetooth.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum BluetoothCodes {
PAIRING = 54109,
}
3 changes: 3 additions & 0 deletions src/hw/energy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum EnergyCodes {
STATUS = 54111,
}
3 changes: 3 additions & 0 deletions src/hw/rf.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export enum RFCodes {
STATUS = 54112,
}
4 changes: 2 additions & 2 deletions src/main/utils/udev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fault que se me ha colado del otro branch, ignorar este file para este cambio

return false;
}
return true;
}
} catch (err) {
console.error(err);
return false;
}
return false;
};

const installUdev = (mainWindow: BrowserWindow) => {
Expand Down
54 changes: 25 additions & 29 deletions src/renderer/component/Select/SelectWirelessDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
Expand Down Expand Up @@ -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<WirelessButton> = [
{ 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);
Expand All @@ -169,29 +175,17 @@ function SelectWirelessDropdown(props: SelectWirelessDropdownProps) {
</div>
<div className="dropdown-group-buttons">
<Dropdown.Item
eventKey={String(WirelessButtons[0].keynum)}
key={`wirelessButtons-${0}`}
disabled={WirelessButtons[0].keynum === -1}
className={`
${WirelessButtons[0].keynum === keyCode.base + keyCode.modified ? "active" : ""} dropdown-config-button`}
>
<div className="dropdownItem">{WirelessButtons[0].name}</div>
</Dropdown.Item>
</div>
</div>
<div className="dropdown-group wirelessSaving">
<div className="dropdownHeader">
Bluetooth <span>{i18n.wireless.bluetooth.StatusTitle}</span>
</div>
<div className="dropdown-group-buttons">
<Dropdown.Item
eventKey={String(WirelessButtons[1].keynum)}
key={`wirelessButtons-${1}`}
disabled={WirelessButtons[1].keynum === -1}
eventKey={String(WirelessButtons[WirelessButtonOrder.BATTERY_LEVEL].keynum)}
Copy link
Contributor Author

@javierguzman javierguzman Aug 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexDygma @thiagohernandez No he mirado como hacemos los dropdown menus en Bazecor pero si es necesario estaría bueno en el futuro poner los dropdown values como string si se puede porque así no tenemos que rely on an array order como en este fichero. Quizás me ánimo y lo hago en otro PR

key={`wirelessButtons-${WirelessButtonOrder.BATTERY_LEVEL}`}
disabled={WirelessButtons[WirelessButtonOrder.BATTERY_LEVEL].keynum === -1}
className={`
${WirelessButtons[1].keynum === keyCode.base + keyCode.modified ? "active" : ""} dropdown-config-button`}
${
WirelessButtons[WirelessButtonOrder.BATTERY_LEVEL].keynum === keyCode.base + keyCode.modified
? "active"
: ""
} dropdown-config-button`}
>
<div className="dropdownItem">{WirelessButtons[1].name}</div>
<div className="dropdownItem">{WirelessButtons[WirelessButtonOrder.BATTERY_LEVEL].name}</div>
</Dropdown.Item>
</div>
</div>
Expand All @@ -201,13 +195,15 @@ function SelectWirelessDropdown(props: SelectWirelessDropdownProps) {
</div>
<div className="dropdown-group-buttons">
<Dropdown.Item
eventKey={String(WirelessButtons[2].keynum)}
key={`wirelessButtons-${2}`}
disabled={WirelessButtons[2].keynum === -1}
eventKey={String(WirelessButtons[WirelessButtonOrder.PAIRING_MODE].keynum)}
key={`wirelessButtons-${WirelessButtonOrder.PAIRING_MODE}`}
disabled={WirelessButtons[WirelessButtonOrder.PAIRING_MODE].keynum === -1}
className={`
${WirelessButtons[2].keynum === keyCode.base + keyCode.modified ? "active" : ""} dropdown-config-button`}
${
WirelessButtons[WirelessButtonOrder.PAIRING_MODE].keynum === keyCode.base + keyCode.modified ? "active" : ""
} dropdown-config-button`}
>
<div className="dropdownItem">{WirelessButtons[2].name}</div>
<div className="dropdownItem">{WirelessButtons[WirelessButtonOrder.PAIRING_MODE].name}</div>
</Dropdown.Item>
</div>
</div>
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
31 changes: 6 additions & 25 deletions src/renderer/modules/KeysTabs/WirelessTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
Expand Down Expand Up @@ -48,30 +50,9 @@ function WirelessTab(props: TabLayoutEditorProps) {
<ButtonConfig
buttonText={i18n.editor.standardView.wireless.batteryLevel}
onClick={() => {
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}
/>
</div>
<div className="keysButtonsList">
<Title text={i18n.wireless.energyManagement.savingMode} headingLevel={4} />
<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}
Expand All @@ -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}
Expand Down
Empty file added src/renderer/types/energy.ts
Empty file.