Dead code removal.

pull/1498/head
Rick Carlino 2019-10-10 09:34:06 -05:00
parent 26a98f486a
commit 2f5dd155c1
5 changed files with 12 additions and 49 deletions

View File

@ -21,7 +21,7 @@ describe("mapStateToPropsAddEdit()", () => {
describe("handleTime()", () => {
const { handleTime } = mapStateToPropsAddEdit(fakeState());
it("start_time", () => {
it("handles an element with name `start_time`", () => {
const e = {
currentTarget: { value: "10:54", name: "start_time" }
} as React.SyntheticEvent<HTMLInputElement>;
@ -29,13 +29,21 @@ describe("mapStateToPropsAddEdit()", () => {
expect(result).toContain("54");
});
it("end_time", () => {
it("handles an element with name `end_time`", () => {
const e = {
currentTarget: { value: "10:53", name: "end_time" }
} as React.SyntheticEvent<HTMLInputElement>;
const result = handleTime(e, "2017-05-21T22:00:00.000");
expect(result).toContain("53");
});
it("crashes on other names", () => {
const e = {
currentTarget: { value: "10:52", name: "other" }
} as React.SyntheticEvent<HTMLInputElement>;
const boom = () => handleTime(e, "2017-05-21T22:00:00.000");
expect(boom).toThrowError("Expected a name attribute from time field.");
});
});
describe("executableOptions()", () => {

View File

@ -134,7 +134,6 @@ export function mapStateToPropsAddEdit(props: Everything): AddEditFarmEventProps
switch (kind) {
case "Sequence": return findSequenceById(props.resources.index, id);
case "Regimen": return findRegimenById(props.resources.index, id);
default: throw new Error("GOT A BAD `KIND` STRING");
}
};
const dev = getDeviceAccountSettings(props.resources.index);

View File

@ -15,7 +15,6 @@ import {
fakePointGroup, fakePlant
} from "../../../__test_support__/fake_state/resources";
import { save, edit } from "../../../api/crud";
import { DEFAULT_ICON } from "../../../open_farm/icons";
import { SpecialStatus } from "farmbot";
describe("<GroupDetailActive/>", () => {
@ -45,19 +44,6 @@ describe("<GroupDetailActive/>", () => {
expect(el.find("input").prop("defaultValue")).toContain("XYZ");
});
it("provides the DEFAULT_ICON when OF has no icon to provide", () => {
const plant = fakePlant();
const comp = new GroupDetailActive(fakeProps());
comp.state = {
[plant.uuid]: {
slug: plant.uuid,
svg_icon: undefined
}
};
const result = comp.findIcon(plant);
expect(result).toEqual(DEFAULT_ICON);
});
it("changes group name", () => {
const NEW_NAME = "new group name";
const wrapper = shallow(<GroupDetailActive {...fakeProps()} />);

View File

@ -8,10 +8,9 @@ import {
} from "../plants/designer_panel";
import { TaggedPointGroup } from "farmbot";
import { DeleteButton } from "../../controls/pin_form_fields";
import { svgToUrl, DEFAULT_ICON } from "../../open_farm/icons";
import { save, edit } from "../../api/crud";
import { Dictionary } from "lodash";
import { cachedCrop, OFIcon } from "../../open_farm/cached_crop";
import { OFIcon } from "../../open_farm/cached_crop";
import { TaggedPlant } from "../map/interfaces";
import { PointGroupSortSelector, sortGroupBy } from "./point_group_sort_selector";
import { PointGroupSortType } from "farmbot/dist/resources/api_resources";
@ -33,33 +32,6 @@ export class GroupDetailActive
this.props.dispatch(edit(this.props.group, { name: currentTarget.value }));
};
handleIcon =
(uuid: string) =>
(icon: Readonly<OFIcon>) =>
this.setState({ [uuid]: icon });
performLookup = (plant: TaggedPlant) => {
cachedCrop(plant.body.openfarm_slug).then(this.handleIcon(plant.uuid));
return DEFAULT_ICON;
}
findIcon = (plant: TaggedPlant) => {
const svg = this.state[plant.uuid];
if (svg) {
if (svg.svg_icon) {
return svgToUrl(svg.svg_icon);
}
return DEFAULT_ICON;
}
return this.performLookup(plant);
}
get name() {
const { group } = this.props;
return group ? group.body.name : "Group Not found";
}
get icons() {
const plants = sortGroupBy(this.props.group.body.sort_type,
this.props.plants);
@ -102,7 +74,7 @@ export class GroupDetailActive
panelName={"groups"}>
<label>{t("GROUP NAME")}{this.saved ? "" : "*"}</label>
<input
defaultValue={this.name}
defaultValue={this.props.group.body.name}
onChange={this.update}
onBlur={this.saveGroup} />
<PointGroupSortSelector

View File

@ -144,8 +144,6 @@ export function determineInstalledOsVersion(
return fromBotState === "" ? undefined : fromBotState;
case SemverResult.RIGHT_IS_GREATER:
return fromAPI === "" ? undefined : fromAPI;
default:
return undefined;
}
}