Factor down motors.tsx
parent
ef901426c7
commit
d8436b1960
|
@ -8,9 +8,10 @@ jest.mock("../../../../device", () => ({
|
|||
import * as React from "react";
|
||||
import { MotorsProps } from "../../interfaces";
|
||||
import { bot } from "../../../../__test_support__/fake_state/bot";
|
||||
import { Motors, StepsPerMmSettings } from "../motors";
|
||||
import { Motors } from "../motors";
|
||||
import { render, shallow, mount } from "enzyme";
|
||||
import { McuParamName } from "farmbot";
|
||||
import { StepsPerMmSettings } from "../steps_per_mm_settings";
|
||||
|
||||
describe("<Motors/>", () => {
|
||||
beforeEach(function () {
|
||||
|
@ -28,7 +29,7 @@ describe("<Motors/>", () => {
|
|||
};
|
||||
|
||||
it("renders the base case", () => {
|
||||
const el = render(<Motors {...fakeProps() } />);
|
||||
const el = render(<Motors {...fakeProps()} />);
|
||||
const txt = el.text();
|
||||
[ // Not a whole lot to test here....
|
||||
"Enable 2nd X Motor",
|
||||
|
|
|
@ -1,9 +1,46 @@
|
|||
import * as React from "react";
|
||||
import { BotConfigInputBox } from "../bot_config_input_box";
|
||||
import { MotorsProps } from "../interfaces";
|
||||
import { minFwVersionCheck } from "../../../util";
|
||||
import { ToolTips } from "../../../constants";
|
||||
import { NumericMCUInputGroup } from "../numeric_mcu_input_group";
|
||||
import { Row, Col } from "../../../ui";
|
||||
import { SpacePanelToolTip } from "../space_panel_tool_tip";
|
||||
import { t } from "i18next";
|
||||
|
||||
function LegacyStepsPerMm(props: MotorsProps) {
|
||||
const { dispatch, sourceFbosConfig } = props;
|
||||
|
||||
return <Row>
|
||||
<Col xs={6}>
|
||||
<label>
|
||||
{t("Steps per MM")}
|
||||
</label>
|
||||
<SpacePanelToolTip tooltip={ToolTips.STEPS_PER_MM} />
|
||||
</Col>
|
||||
<Col xs={2}>
|
||||
<BotConfigInputBox
|
||||
setting="steps_per_mm_x"
|
||||
sourceFbosConfig={sourceFbosConfig}
|
||||
dispatch={dispatch} />
|
||||
</Col>
|
||||
<Col xs={2}>
|
||||
<BotConfigInputBox
|
||||
setting="steps_per_mm_y"
|
||||
sourceFbosConfig={sourceFbosConfig}
|
||||
dispatch={dispatch} />
|
||||
</Col>
|
||||
<Col xs={2}>
|
||||
<BotConfigInputBox
|
||||
setting="steps_per_mm_z"
|
||||
sourceFbosConfig={sourceFbosConfig}
|
||||
dispatch={dispatch} />
|
||||
</Col>
|
||||
</Row>;
|
||||
}
|
||||
|
||||
export function StepsPerMmSettings(props: MotorsProps) {
|
||||
const { dispatch, bot, sourceFbosConfig } = props;
|
||||
const { dispatch, bot } = props;
|
||||
const { firmware_version } = bot.hardware.informational_settings;
|
||||
if (minFwVersionCheck(firmware_version, "5.0.5")) {
|
||||
return <NumericMCUInputGroup
|
||||
|
@ -15,31 +52,6 @@ export function StepsPerMmSettings(props: MotorsProps) {
|
|||
bot={bot}
|
||||
dispatch={dispatch} />;
|
||||
} else {
|
||||
return <Row>
|
||||
<Col xs={6}>
|
||||
<label>
|
||||
{t("Steps per MM")}
|
||||
</label>
|
||||
<SpacePanelToolTip tooltip={ToolTips.STEPS_PER_MM} />
|
||||
</Col>
|
||||
<Col xs={2}>
|
||||
<BotConfigInputBox
|
||||
setting="steps_per_mm_x"
|
||||
sourceFbosConfig={sourceFbosConfig}
|
||||
dispatch={dispatch} />
|
||||
</Col>
|
||||
<Col xs={2}>
|
||||
<BotConfigInputBox
|
||||
setting="steps_per_mm_y"
|
||||
sourceFbosConfig={sourceFbosConfig}
|
||||
dispatch={dispatch} />
|
||||
</Col>
|
||||
<Col xs={2}>
|
||||
<BotConfigInputBox
|
||||
setting="steps_per_mm_z"
|
||||
sourceFbosConfig={sourceFbosConfig}
|
||||
dispatch={dispatch} />
|
||||
</Col>
|
||||
</Row>;
|
||||
return <LegacyStepsPerMm {...props} />;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue