[UNSTABLE] Needs testing and QA
This commit is contained in:
parent
0a36e47ecb
commit
f2e0fc9b3a
|
@ -12,6 +12,7 @@ import { SpacePanelHeader } from "./hardware_settings/space_panel_header";
|
|||
import {
|
||||
HomingAndCalibration
|
||||
} from "./hardware_settings/homing_and_calibration";
|
||||
import { SpecialStatus } from "../../resources/tagged_resources";
|
||||
|
||||
export class HardwareSettings extends
|
||||
React.Component<HardwareSettingsProps, {}> {
|
||||
|
@ -26,6 +27,7 @@ export class HardwareSettings extends
|
|||
status={bot.hardware.informational_settings.sync_status}
|
||||
lockOpen={process.env.NODE_ENV !== "production"}>
|
||||
<SaveBtn
|
||||
status={bot.isUpdating ? SpecialStatus.SAVING : undefined}
|
||||
dirtyText={" "}
|
||||
savingText={"Updating..."}
|
||||
savedText={"saved"}
|
||||
|
|
|
@ -26,7 +26,6 @@ describe("<FarmEventForm/>", () => {
|
|||
|
||||
it("sets defaults", () => {
|
||||
expect(context.form.state.fe).toMatchObject({});
|
||||
expect(context.form.state.localCopyDirty).toBeFalsy();
|
||||
});
|
||||
|
||||
it("determines if it is a one time event", () => {
|
||||
|
@ -77,10 +76,8 @@ describe("<FarmEventForm/>", () => {
|
|||
let p = props();
|
||||
let i = instance(p);
|
||||
i.forceUpdate();
|
||||
expect(i.state.localCopyDirty).toBe(false);
|
||||
i.executableSet({ value: "wow", label: "hey", headingId: "Sequence" });
|
||||
i.forceUpdate();
|
||||
expect(i.state.localCopyDirty).toBe(true);
|
||||
expect(i.state.fe.executable_type).toEqual("Sequence");
|
||||
expect(i.state.fe.executable_id).toEqual("wow");
|
||||
});
|
||||
|
@ -99,10 +96,8 @@ describe("<FarmEventForm/>", () => {
|
|||
let p = props();
|
||||
let i = instance(p);
|
||||
i.forceUpdate();
|
||||
expect(i.state.localCopyDirty).toBe(false);
|
||||
i.fieldSet("repeat")(({ currentTarget: { value: "4" } } as any));
|
||||
i.forceUpdate();
|
||||
expect(i.state.localCopyDirty).toBe(true);
|
||||
expect(i.state.fe.repeat).toEqual("4");
|
||||
});
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import * as moment from "moment";
|
|||
import * as _ from "lodash";
|
||||
import { t } from "i18next";
|
||||
import { success, error } from "farmbot-toastr";
|
||||
import { TaggedFarmEvent, SpecialStatus } from "../../resources/tagged_resources";
|
||||
import { TaggedFarmEvent } from "../../resources/tagged_resources";
|
||||
import {
|
||||
TimeUnit,
|
||||
ExecutableQuery,
|
||||
|
@ -100,11 +100,10 @@ interface State {
|
|||
*
|
||||
* Example: Navigating away from the page while editing will discard changes.
|
||||
*/
|
||||
localCopySpecialStatus: SpecialStatus | undefined;
|
||||
}
|
||||
|
||||
export class EditFEForm extends React.Component<EditFEProps, State> {
|
||||
state: State = { fe: {}, localCopySpecialStatus: undefined };
|
||||
state: State = { fe: {} };
|
||||
|
||||
get isOneTime() { return this.fieldGet("timeUnit") === NEVER; }
|
||||
|
||||
|
@ -259,6 +258,7 @@ export class EditFEForm extends React.Component<EditFEProps, State> {
|
|||
endTime={this.fieldGet("endTime")}
|
||||
/>
|
||||
<SaveBtn
|
||||
status={fe.specialStatus}
|
||||
color="magenta"
|
||||
onClick={this.commitViewModel} />
|
||||
<button className="fb-button red"
|
||||
|
|
|
@ -77,7 +77,7 @@ export class GardenMap extends
|
|||
let p: TaggedPlantPointer = {
|
||||
kind: "points",
|
||||
uuid: "--never",
|
||||
dirty: true,
|
||||
specialStatus: undefined,
|
||||
body: Plant({
|
||||
x,
|
||||
y,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import * as React from "react";
|
||||
import { AddRegimenProps } from "../interfaces";
|
||||
import { push } from "../../history";
|
||||
import { TaggedRegimen } from "../../resources/tagged_resources";
|
||||
import { TaggedRegimen, SpecialStatus } from "../../resources/tagged_resources";
|
||||
import { init } from "../../api/crud";
|
||||
|
||||
function emptyRegimen(length: number): TaggedRegimen {
|
||||
return {
|
||||
kind: "regimens",
|
||||
uuid: "NEVER",
|
||||
dirty: true,
|
||||
specialStatus: SpecialStatus.DIRTY,
|
||||
body: {
|
||||
name: ("New regimen " + (length++)),
|
||||
color: "gray",
|
||||
|
|
|
@ -22,7 +22,7 @@ export function RegimenListItem({ regimen, dispatch }: RegimenListItemProps) {
|
|||
className={style.join(" ")}
|
||||
onClick={select(dispatch, regimen)}
|
||||
>
|
||||
{name} {regimen.dirty && ("*")}
|
||||
{name} {regimen.specialStatus && ("*")}
|
||||
</button>
|
||||
</Link>;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ const TOOL_ID = 99;
|
|||
const SLOT_ID = 100;
|
||||
const fakeTool: TaggedTool = {
|
||||
kind: "tools",
|
||||
specialStatus: undefined,
|
||||
uuid: generateUuid(TOOL_ID, "tools"),
|
||||
body: {
|
||||
name: "yadda yadda",
|
||||
|
@ -17,6 +18,7 @@ const fakeTool: TaggedTool = {
|
|||
};
|
||||
const fakeSlot: TaggedToolSlotPointer = {
|
||||
kind: "points",
|
||||
specialStatus: undefined,
|
||||
uuid: generateUuid(SLOT_ID, "points"),
|
||||
body: {
|
||||
tool_id: TOOL_ID,
|
||||
|
|
|
@ -6,6 +6,7 @@ describe("maybeTagSteps()", () => {
|
|||
const UNTAGGED_SEQUENCE: TaggedSequence = {
|
||||
"kind": "sequences",
|
||||
"uuid": "whatever",
|
||||
"specialStatus": undefined,
|
||||
"body": {
|
||||
"id": 8,
|
||||
"name": "Goto 0, 0, 0",
|
||||
|
|
|
@ -8,6 +8,7 @@ import { maybeTagSteps } from "../../resources/sequence_tagging";
|
|||
describe("<AllSteps/>", () => {
|
||||
const TEST_CASE = {
|
||||
"kind": "sequences",
|
||||
"specialStatus": undefined,
|
||||
"body": {
|
||||
"id": 8,
|
||||
"name": "Goto 0, 0, 0",
|
||||
|
|
|
@ -24,7 +24,7 @@ let sequenceList = (dispatch: Function) =>
|
|||
];
|
||||
lastUrlChunk() === urlFriendly(ts.body.name) && css.push("active");
|
||||
let click = () => dispatch(selectSequence(ts.uuid));
|
||||
let name = ts.body.name + (ts.dirty ? "*" : "");
|
||||
let name = ts.body.name + (ts.specialStatus ? "*" : "");
|
||||
let { uuid } = ts;
|
||||
return <Link
|
||||
to={`/app/sequences/${urlFriendly(ts.body.name) || ""}`}
|
||||
|
@ -65,6 +65,7 @@ export class SequencesList extends
|
|||
return {
|
||||
kind: "sequences",
|
||||
uuid: "REDUCER_MUST_CHANGE_THIS",
|
||||
specialStatus: undefined,
|
||||
body: {
|
||||
name: "new sequence " + (this.props.sequences.length),
|
||||
args: { version: -999 },
|
||||
|
|
|
@ -10,7 +10,7 @@ import {
|
|||
BlurableInput,
|
||||
SaveBtn
|
||||
} from "../../ui";
|
||||
import { TaggedTool } from "../../resources/tagged_resources";
|
||||
import { TaggedTool, getArrayStatus } from "../../resources/tagged_resources";
|
||||
import { edit, destroy, init, saveAll } from "../../api/crud";
|
||||
import { ToolTips } from "../../constants";
|
||||
|
||||
|
@ -18,6 +18,7 @@ export class ToolForm extends React.Component<ToolFormProps, {}> {
|
|||
emptyTool = (): TaggedTool => {
|
||||
return {
|
||||
uuid: "ERROR: GENERATED BY REDUCER - UUID SHOULD BE UNSEEN",
|
||||
specialStatus: undefined,
|
||||
kind: "tools",
|
||||
body: { name: "Tool " + (this.props.tools.length + 1) }
|
||||
};
|
||||
|
@ -26,25 +27,20 @@ export class ToolForm extends React.Component<ToolFormProps, {}> {
|
|||
render() {
|
||||
let toggle = () => this.props.toggle();
|
||||
let { dispatch, tools } = this.props;
|
||||
|
||||
let isSaving = tools && tools.filter(x => x.saving).length !== 0;
|
||||
let isDirty = tools && tools.filter(x => x.dirty).length !== 0;
|
||||
let isSaved = !isSaving && !isDirty;
|
||||
|
||||
let specialStatus = getArrayStatus(tools);
|
||||
return <Widget>
|
||||
<WidgetHeader helpText={ToolTips.TOOL_LIST} title="Tools">
|
||||
<button
|
||||
className="fb-button gray"
|
||||
onClick={() => { toggle(); }}
|
||||
hidden={!isSaved}>
|
||||
hidden={!!specialStatus}>
|
||||
{t("Back")}
|
||||
</button>
|
||||
<SaveBtn
|
||||
isDirty={isDirty}
|
||||
isSaving={isSaving}
|
||||
isSaved={isSaved}
|
||||
onClick={() => { dispatch(saveAll(tools, () => { toggle(); })) }}
|
||||
/>
|
||||
status={specialStatus}
|
||||
onClick={() => {
|
||||
dispatch(saveAll(tools, () => { toggle(); }));
|
||||
}} />
|
||||
<button
|
||||
className="fb-button green"
|
||||
onClick={() => { dispatch(init(this.emptyTool())); }}>
|
||||
|
|
Loading…
Reference in a new issue