Skip to content

Commit

Permalink
Merge branch 'release/v0.22.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
stylesuxx committed Jan 27, 2022
2 parents 2d2eea5 + 069ee8e commit e6b2c82
Show file tree
Hide file tree
Showing 92 changed files with 6,324 additions and 7,966 deletions.
54 changes: 24 additions & 30 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
{
"extends": ["eslint:recommended", "plugin:react/all", "plugin:jest/recommended"],
"ignorePatterns": ["service-worker.js"],
"plugins": [
"react"
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module",
"ecmaFeatures": { "jsx": true }
},
"env": {
"es2021": true,
"browser": true,
"node": true
},
"extends": [
"eslint:recommended",
"plugin:react/all",
"plugin:jest/recommended",
"react-app",
"react-app/jest"
],
"ignorePatterns": ["service-worker.js"],
"plugins": ["react", "jest"],
"rules": {
"react/jsx-max-depth": ["warn", { "max": 5 }],
"indent": ["warn", 2, { "SwitchCase": 1 }],
Expand All @@ -13,7 +27,12 @@
"react/no-multi-comp": "off",
"react/no-set-state": "off",
"react/forbid-component-props": "off",
"react-hooks/rules-of-hooks": "warn",
"testing-library/no-container": "warn",
"testing-library/no-node-access": "warn",
"no-unreachable": "off",
"no-lone-blocks": "off",
"no-mixed-operators": "off",
"react/no-array-index-key": "warn",
"react/no-danger": "warn",
"no-unused-vars": "warn",
Expand Down Expand Up @@ -49,30 +68,5 @@
"react": {
"version": "detect"
}
},
"globals": {
"document": false,
"process": false,
"navigator": false,
"console": false,
"fetch": false,
"URL": false,
"window": false,
"setInterval": false,
"clearInterval": false,
"Uint8Array": false,
"ArrayBuffer": false,
"DataView": false,
"setTimeout": false,
"clearTimeout": false,
"Promise": false,
"FileReader": false,
"Blob": false,
"localStorage": false,
"__dirname": false,
"require": false,
"Set": false,
"Event": false
},
"parser": "babel-eslint"
}
}
20 changes: 20 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test

on:
push:
branches: [master, develop]
pull_request:
branches: [master, develop]

jobs:
test:
name: Test
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- run: yarn install --immutable --immutable-cache --check-cache

- run: yarn lint

- run: yarn test
76 changes: 41 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
{
"name": "esc-configurator",
"version": "0.21.0",
"version": "0.22.0",
"private": false,
"license": "AGPL-3.0",
"dependencies": {
"@babel/plugin-transform-react-jsx": "^7.16.7",
"@palmabit/react-cookie-law": "^0.6.2",
"autoprefixer": "^10.4.2",
"bluejay-rtttl-parse": "^2.0.2",
"compare-versions": "^3.6.0",
"dateformat": "^4.5.1",
"i18next": "^19.9.0",
"compare-versions": "^4.1.3",
"dateformat": "^5.0.2",
"draft-js": "^0.11.7",
"i18next": "^21.6.7",
"prop-types": "^15.8.1",
"rc-slider": "^9.7.2",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-gtm-module": "^2.0.11",
"react-highlight-within-textarea": "^1.0.1",
"react-highlight-within-textarea": "^2.1.3",
"react-i18next": "^11.8.8",
"react-input-range": "^1.3.0",
"react-scripts": "4.0.3",
"react-toastify": "^7.0.3",
"react-tooltip": "=4.2.8",
"scheduler": "0.14.0",
"react-scripts": "^5.0.0",
"react-toastify": "^8.1.0",
"react-tooltip": "^4.2.21",
"scheduler": "^0.20.2",
"sleep": "^6.3.0",
"ua-parser-js": "^1.0.2",
"web-serial-polyfill": "stylesuxx/web-serial-polyfill#temporary-fix",
"web-vitals": "^0.2.4",
"workbox-background-sync": "^5.1.3",
"workbox-broadcast-update": "^5.1.3",
"workbox-cacheable-response": "^5.1.3",
"workbox-core": "^5.1.3",
"workbox-expiration": "^5.1.3",
"workbox-google-analytics": "^5.1.3",
"workbox-navigation-preload": "^5.1.3",
"workbox-precaching": "^5.1.3",
"workbox-range-requests": "^5.1.3",
"workbox-routing": "^5.1.3",
"workbox-strategies": "^5.1.3",
"workbox-streams": "^5.1.3"
"web-vitals": "^2.1.4",
"workbox-background-sync": "^6.4.2",
"workbox-broadcast-update": "^6.4.2",
"workbox-cacheable-response": "^6.4.2",
"workbox-core": "^6.4.2",
"workbox-expiration": "^6.4.2",
"workbox-google-analytics": "^6.4.2",
"workbox-navigation-preload": "^6.4.2",
"workbox-precaching": "^6.4.2",
"workbox-range-requests": "^6.4.2",
"workbox-routing": "^6.4.2",
"workbox-strategies": "^6.4.2",
"workbox-streams": "^6.4.2"
},
"scripts": {
"start": "react-scripts start",
Expand Down Expand Up @@ -66,24 +71,25 @@
]
},
"devDependencies": {
"@babel/core": "^7.16.10",
"@babel/plugin-syntax-flow": "^7.16.7",
"@babel/preset-react": "^7.16.7",
"@testing-library/dom": "^8.11.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@typescript-eslint/eslint-plugin": "^4.0.0",
"@typescript-eslint/parser": "^4.0.0",
"babel-eslint": "^10.0.0",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"@typescript-eslint/eslint-plugin": "^5.10.0",
"@typescript-eslint/parser": "^5.10.0",
"codecov": "^3.8.3",
"eslint": "^7.5.0",
"eslint-config-react-app": "^6.0.0",
"eslint-plugin-flowtype": "^5.2.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^24.3.2",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.8",
"eslint": "^8.7.0",
"eslint-config-react-app": "^7.0.0",
"eslint-plugin-jest": "^25.7.0",
"eslint-plugin-react": "^7.28.0",
"postcss": "^8.4.5",
"pre-commit": "^1.2.2",
"pre-push": "^0.1.1",
"sass": "^1.32.8",
"typescript": "^4.5.5",
"with-staged": "^1.0.2"
},
"jest": {
Expand Down
3 changes: 3 additions & 0 deletions src/Components/App/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function App({
melodies,
msp,
onAllMotorSpeed,
onClearLog,
onCookieAccept,
onSaveLog,
onSingleMotorSpeed,
Expand Down Expand Up @@ -88,6 +89,7 @@ function App({
mspFeatures={msp.features}
onAllMotorSpeed={onAllMotorSpeed}
onCancelFirmwareSelection={escs.actions.handleCancelFirmwareSelection}
onClearLog={onClearLog}
onCommonSettingsUpdate={escs.actions.handleCommonSettingsUpdate}
onFirmwareDump={escs.actions.handleFirmwareDump}
onFlashUrl={escs.actions.handleFlashUrl}
Expand Down Expand Up @@ -208,6 +210,7 @@ App.propTypes = {
}).isRequired,
msp: PropTypes.shape({ features: PropTypes.shape({}).isRequired }).isRequired,
onAllMotorSpeed: PropTypes.func.isRequired,
onClearLog: PropTypes.func.isRequired,
onCookieAccept: PropTypes.func.isRequired,
onSaveLog: PropTypes.func.isRequired,
onSingleMotorSpeed: PropTypes.func.isRequired,
Expand Down
6 changes: 3 additions & 3 deletions src/Components/AppSettings/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTranslation } from 'react-i18next';
import PropTypes from 'prop-types';
import React from 'react';
import React, { useCallback } from 'react';

import Checkbox from '../Input/Checkbox';
import Overlay from '../Overlay';
Expand All @@ -14,12 +14,12 @@ function AppSettings({
}) {
const { t } = useTranslation('settings');

function handleCheckboxChange(e) {
const handleCheckboxChange = useCallback((e) => {
const name = e.target.name;
const value = e.target.checked;

onUpdate(name, value);
}
}, [onUpdate]);

const settingKeys = Object.keys(settings);
const settingElements = settingKeys.map((key) => {
Expand Down
7 changes: 7 additions & 0 deletions src/Components/Buttonbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import GenericButton from './GenericButton';
import './style.scss';

function Buttonbar({
onClearLog,
onOpenMelodyEditor,
onReadSetup,
onWriteSetup,
Expand Down Expand Up @@ -38,6 +39,11 @@ function Buttonbar({
text={t('escButtonSaveLog')}
/>

<GenericButton
onClick={onClearLog}
text={t('escButtonClearLog')}
/>

<div className="mobile-show">
<GenericButton
disabled={!canResetDefaults}
Expand Down Expand Up @@ -88,6 +94,7 @@ Buttonbar.propTypes = {
canRead: PropTypes.bool.isRequired,
canResetDefaults: PropTypes.bool.isRequired,
canWrite: PropTypes.bool.isRequired,
onClearLog: PropTypes.func.isRequired,
onOpenMelodyEditor: PropTypes.func.isRequired,
onReadSetup: PropTypes.func.isRequired,
onResetDefaults: PropTypes.func.isRequired,
Expand Down
9 changes: 6 additions & 3 deletions src/Components/Changelog/index.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { useTranslation } from 'react-i18next';
import PropTypes from 'prop-types';
import React, { useState } from 'react';
import React, {
useState,
useCallback,
} from 'react';

import Content from './Content';

Expand All @@ -14,13 +17,13 @@ function Changelog({ entries }) {
title: t('defaultChangelogTitle'),
});

function toggleExpanded() {
const toggleExpanded = useCallback(() => {
const newExpanded = !state.expanded;
setState({
expanded: newExpanded,
title: newExpanded ? t('changelogClose') : t('defaultChangelogTitle'),
});
}
}, [state.expanded]);

return (
<div className={`changelog ${state.expanded ? "expanded" : ""}`}>
Expand Down
31 changes: 29 additions & 2 deletions src/Components/FirmwareSelector/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ let FirmwareSelector;

jest.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key) => key }) }));

const mockJsonResponse = (content) =>
new window.Response(content, {
status: 200,
headers: {
'Content-Type': 'application/json',
'Time-Cached': Date.now().toString(),
},
});

describe('FirmwareSelector', () => {
beforeAll(async () => {
/**
Expand Down Expand Up @@ -54,6 +63,15 @@ describe('FirmwareSelector', () => {
});

it('should allow changing firmware options for BLHeli_S', async() => {
const json = `[{ "tag_name": "v0.10", "assets": [{}] }]`;
global.caches = {
open: jest.fn().mockImplementation(() =>
new Promise((resolve) => {
resolve({ match: () => new Promise((resolve) => resolve(mockJsonResponse(json))) });
})
),
};

const configs = {
versions: {},
escs: {},
Expand Down Expand Up @@ -143,7 +161,7 @@ describe('FirmwareSelector', () => {

fireEvent.change(screen.getByRole(/combobox/i, { name: 'Version' }), {
target: {
value: 'https://github.com/mathiasvr/bluejay/releases/download/v0.10/{0}_v0.10.hex',
value: 'https://github.com/mathiasvr/bluejay/releases/download/v0.10/',
name: 'Version',
},
});
Expand All @@ -167,6 +185,15 @@ describe('FirmwareSelector', () => {
});

it('should allow changing firmware options for AM32', async() => {
const json = `[{ "tag_name": "v1.65", "assets": [{}] }]`;
global.caches = {
open: jest.fn().mockImplementation(() =>
new Promise((resolve) => {
resolve({ match: () => new Promise((resolve) => resolve(mockJsonResponse(json))) });
})
),
};

const configs = {
versions: {},
escs: {},
Expand Down Expand Up @@ -216,7 +243,7 @@ describe('FirmwareSelector', () => {

fireEvent.change(screen.getByRole(/combobox/i, { name: 'Version' }), {
target: {
value: 'https://github.com/AlkaMotors/AM32-MultiRotor-ESC-firmware/releases/download/v1.65/{0}_1.65.hex',
value: 'https://github.com/AlkaMotors/AM32-MultiRotor-ESC-firmware/releases/download/v1.65/',
name: 'Version',
},
});
Expand Down
Loading

0 comments on commit e6b2c82

Please sign in to comment.