Skip to content

Commit

Permalink
Merge branch 'release/v0.12.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
stylesuxx committed Apr 10, 2021
2 parents 17845d4 + 13dba50 commit ab17160
Show file tree
Hide file tree
Showing 38 changed files with 1,480 additions and 538 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "esc-configurator",
"version": "0.11.0",
"version": "0.12.0",
"private": true,
"license": "AGPL-3.0",
"dependencies": {
"@palmabit/react-cookie-law": "^0.6.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"bluejay-rtttl-parse": "^2.0.1",
"bluejay-rtttl-parse": "^2.0.2",
"compare-versions": "^3.6.0",
"dateformat": "^4.5.1",
"i18next": "^19.9.0",
Expand Down
24 changes: 12 additions & 12 deletions src/Components/App/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function App({
melodies,
escs,
language,
msp,
onAllMotorSpeed,
onCookieAccept,
onSaveLog,
Expand All @@ -34,18 +35,6 @@ function App({
const { t } = useTranslation('common');
const statusbarRef = useRef();

/* istanbul ignore next */
useInterval(async() => {
if(serial.open && !actions.isReading && !serial.fourWay) {
if(serial.port.getBatteryState) {
const batteryState = await serial.port.getBatteryState();
statusbarRef.current.updateBatteryState(batteryState);
}
} else {
statusbarRef.current.updateBatteryState(null);
}
}, 1000);

/* istanbul ignore next */
useInterval(async() => {
if(serial.port && serial.port.getUtilization) {
Expand Down Expand Up @@ -139,6 +128,7 @@ function App({
escs={escs.individual}
flashTargets={escs.targets}
fourWay={serial.fourWay}
mspFeatures={msp.features}
onAllMotorSpeed={onAllMotorSpeed}
onCancelFirmwareSelection={escs.actions.handleCancelFirmwareSelection}
onFlashUrl={escs.actions.handleFlashUrl}
Expand All @@ -154,6 +144,7 @@ function App({
onSingleMotorSpeed={onSingleMotorSpeed}
onWriteSetup={escs.actions.handleWriteSetup}
open={serial.open}
port={serial.port}
progress={escs.progress}
settings={escs.master}
/>
Expand All @@ -173,10 +164,14 @@ function App({

{melodies.show &&
<MelodyEditor
customMelodies={melodies.customMelodies}
defaultMelodies={melodies.defaultMelodies}
dummy={melodies.dummy}
melodies={melodies.escs}
onClose={melodies.actions.handleClose}
onDelete={melodies.actions.handleDelete}
onSave={melodies.actions.handleSave}
onWrite={melodies.actions.handleWrite}
writing={actions.isWriting}
/>}

Expand Down Expand Up @@ -237,12 +232,17 @@ App.propTypes = {
actions: PropTypes.shape({
handleSave: PropTypes.func.isRequired,
handleOpen: PropTypes.func.isRequired,
handleWrite: PropTypes.func.isRequired,
handleClose: PropTypes.func.isRequired,
handleDelete: PropTypes.func.isRequired,
}),
customMelodies: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
defaultMelodies: PropTypes.arrayOf(PropTypes.shape({})).isRequired,
dummy: PropTypes.bool.isRequired,
escs: PropTypes.arrayOf(PropTypes.string).isRequired,
show: PropTypes.bool.isRequired,
}).isRequired,
msp: PropTypes.shape({ features: PropTypes.shape({}).isRequired }).isRequired,
onAllMotorSpeed: PropTypes.func.isRequired,
onCookieAccept: PropTypes.func.isRequired,
onSaveLog: PropTypes.func.isRequired,
Expand Down
9 changes: 7 additions & 2 deletions src/Components/App/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ body {
background-size: contain;
margin-left: 23px;
margin-top: 10px;

@media only screen and (max-width: 600px) {
margin-left: 15px;
}
}

.hidden {
Expand Down Expand Up @@ -215,7 +219,7 @@ body {
text-shadow: none;
border: 1px solid #ccc;
color: #ccc;
cursor: aliasdefault;
cursor: default;
}

button:active,
Expand All @@ -238,12 +242,13 @@ body {
margin-bottom: 50px;

@media only screen and (max-width: 600px) {
margin-bottom: 90px;
margin-bottom: 120px;
}

@media screen and (max-width: 768px) {
padding-left: 10px;
padding-right: 10px;
padding-top: 13px;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Components/Buttonbar/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ test('loads and displays Buttonbar', () => {
expect(screen.getByText(/escButtonWrite/i)).toBeInTheDocument();
expect(screen.getByText(/escButtonFlashAll/i)).toBeInTheDocument();
expect(screen.getByText(/escButtonSaveLog/i)).toBeInTheDocument();
expect(screen.getByText(/escButtonOpenMelodyEditor/i)).toBeInTheDocument();
expect(screen.getAllByText(/escButtonOpenMelodyEditor/i).length).toEqual(2);
});

test('trigger onSaveLog', () => {
Expand Down
26 changes: 16 additions & 10 deletions src/Components/Buttonbar/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,13 @@ function Buttonbar({
function MelodyEditorButton() {
if(showMelodyEditor) {
return (
<div className="btn">
<button
disabled={!canRead}
onClick={onOpenMelodyEditor}
type="button"
>
{t('escButtonOpenMelodyEditor')}
</button>
</div>
<button
disabled={!canRead}
onClick={onOpenMelodyEditor}
type="button"
>
{t('escButtonOpenMelodyEditor')}
</button>
);
}

Expand All @@ -51,6 +49,12 @@ function Buttonbar({

return (
<div id="button-bar">
<div className="buttons-bottom mobile-show">
<div className="btn">
<MelodyEditorButton />
</div>
</div>

<div className="buttons-left">
<div className="btn log">
<button
Expand Down Expand Up @@ -101,7 +105,9 @@ function Buttonbar({
<ResetDefaultButton />
</div>

<MelodyEditorButton />
<div className="mobile-hide btn">
<MelodyEditorButton />
</div>
</div>
</div>
);
Expand Down
16 changes: 9 additions & 7 deletions src/Components/Buttonbar/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
flex-direction: row;
justify-content: space-between;

@media only screen and (max-width: 600px) {
padding-bottom: 0px;
padding-top: 8px;
}

& > div {
display: flex;

Expand All @@ -37,25 +42,22 @@
& > div {
justify-content: flex-start;

&.buttons-bottom,
&.buttons-left,
&.buttons-right {
margin-bottom: 10px;
margin-bottom: 8px;
margin-left: 5px;
margin-right: 5px;

.btn {
flex: 1;
margin-left: 5px;
margin-right: 5px;
margin-left: 2px;
margin-right: 2px;
button {
width: 100%;
}
}
}

&.buttons-left {
margin-bottom: 0px;
}
}
}

Expand Down
104 changes: 102 additions & 2 deletions src/Components/Flash/__tests__/index.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,114 @@ test('loads and displays unsupported CustomSettings', () => {
<Flash
availableSettings={availableSettings}
canFlash={false}
escCount={1}
escs={escs}
onFlash={onFlash}
onSettingsUpdate={onSettingsUpdate}
/>
);

expect(screen.getByText(/commonParameters/i)).toBeInTheDocument();
expect(screen.getByText(/commonParameters/i)).toBeInTheDocument();
});


test('displays missing ESC warning', () => {
const availableSettings = {
LAYOUT_REVISION: 203,
MAIN_REVISION: 1,
NAME: 'FW name',
SUB_REVISION: 100,
};

const escs = [
{
index: 0,
meta: { available: true },
settings: { MODE: 0 },
make: 'make 1234',
settingsDescriptions: {
base: [
{
name: 'MOTOR_DIRECTION',
type: 'enum',
label: 'escMotorDirection',
options: [
{
value: '1',
label: 'Normal',
},
{
value: '2',
label: 'Reversed',
},
{
value: '3',
label: 'Bidirectional',
},
{
value: '4',
label: 'Bidirectional Reversed',
},
],
},
{
name: '_PPM_MIN_THROTTLE',
type: 'number',
min: 1000,
max: 1500,
step: 4,
label: 'escPPMMinThrottle',
offset: 1000,
factor: 4,
suffix: ' μs',
},
{
name: 'STARTUP_BEEP',
type: 'bool',
label: 'escStartupBeep',
},
{
name: 'IVALID',
type: 'IVALID',
label: 'invalid',
},
{
name: '_PPM_CENTER_THROTTLE',
type: 'number',
min: 1000,
max: 2020,
step: 4,
label: 'escPPMCenterThrottle',
offset: 1000,
factor: 4,
suffix: ' μs',
visibleIf: (settings) => [3, 4].includes(settings.MOTOR_DIRECTION),
},
],
},
individualSettings: {
MAIN_REVISION: 0,
SUB_REVISION: 201,
NAME: 'Bluejay (Beta)',
},
},
];

const onFlash = jest.fn();
const onSettingsUpdate = jest.fn();

render(
<Flash
availableSettings={availableSettings}
canFlash={false}
escCount={4}
escs={escs}
onFlash={onFlash}
onSettingsUpdate={onSettingsUpdate}
/>
);

expect(screen.getByText(/notePropsOff/i)).toBeInTheDocument();
expect(screen.getByText(/noteConnectPower/i)).toBeInTheDocument();
expect(screen.getByText(/commonParameters/i)).toBeInTheDocument();
expect(screen.getByText(/commonParameters/i)).toBeInTheDocument();
});
Loading

0 comments on commit ab17160

Please sign in to comment.