interface cleanup

pull/1255/head
gabrielburnworth 2019-07-01 09:43:03 -07:00
parent 83c06b8dad
commit bec7cc208f
16 changed files with 26 additions and 80 deletions

View File

@ -1,4 +1,4 @@
import { User } from "../auth/interfaces";
import { User } from "farmbot/dist/resources/api_resources";
import { TaggedUser, SpecialStatus } from "farmbot";
export let user: User = {

View File

@ -45,7 +45,7 @@ describe("<ControlsPopup />", () => {
expect(button.props().title).toBe("move x axis (100)");
button.simulate("click");
expect(mockDevice.moveRelative)
.toHaveBeenCalledWith({ speed: 100, x: 100, y: 0, z: 0 });
.toHaveBeenCalledWith({ x: 100, y: 0, z: 0 });
});
it("y axis is not inverted", () => {
@ -53,7 +53,7 @@ describe("<ControlsPopup />", () => {
expect(button.props().title).toBe("move y axis (100)");
button.simulate("click");
expect(mockDevice.moveRelative)
.toHaveBeenCalledWith({ speed: 100, x: 0, y: 100, z: 0 });
.toHaveBeenCalledWith({ x: 0, y: 100, z: 0 });
});
it("disabled when closed", () => {
@ -72,7 +72,7 @@ describe("<ControlsPopup />", () => {
expect(button.props().title).toBe("move x axis (100)");
button.simulate("click");
expect(mockDevice.moveRelative)
.toHaveBeenCalledWith({ speed: 100, x: 100, y: 0, z: 0 });
.toHaveBeenCalledWith({ x: 100, y: 0, z: 0 });
});
it("takes photo", () => {

View File

@ -6,7 +6,7 @@ import {
import { Props } from "./interfaces";
import { Page, Row, Col } from "../ui";
import { mapStateToProps } from "./state_to_props";
import { User } from "../auth/interfaces";
import { User } from "farmbot/dist/resources/api_resources";
import { edit, save } from "../api/crud";
import { updateNO } from "../resources/actions";
import { deleteUser, resetAccount } from "./actions";

View File

@ -1,4 +1,3 @@
import { User } from "../auth/interfaces";
import { TaggedUser } from "farmbot";
import { GetWebAppConfigValue } from "../config_storage/actions";
import { Thunk } from "../redux/interfaces";
@ -9,14 +8,6 @@ export interface Props {
getConfigValue: GetWebAppConfigValue;
}
/** JSON form that gets POSTed to the API when user updates their info. */
export interface UserInfo extends Record<keyof User, string> {
password: string;
new_password: string;
new_password_confirmation: string;
password_deletion_confirmation: string;
}
export interface DeletionRequest {
password: string;
}

View File

@ -1,4 +1,4 @@
export interface Token {
interface Token {
unencoded: UnencodedToken;
encoded: string;
}
@ -7,7 +7,7 @@ export interface AuthState {
token: Token;
}
export interface UnencodedToken {
interface UnencodedToken {
/** ISSUER - Where token came from (API URL). */
iss: string;
/** Where to download RPi software */
@ -17,11 +17,3 @@ export interface UnencodedToken {
/** JSON Token Identifier- auto sync needs this to hear its echo on MQTT */
jti: string;
}
export interface User {
id: number;
name: string;
email: string;
created_at?: string;
updated_at?: string;
}

View File

@ -1,4 +1,4 @@
import { DeviceAccountSettings } from "../devices/interfaces";
import { DeviceAccountSettings } from "farmbot/dist/resources/api_resources";
/** Determines if the device was forced to wait due to log flooding. */
export const deviceIsThrottled =

View File

@ -54,7 +54,7 @@ describe("<DirectionButton/>", function () {
const btn = mount(<DirectionButton {...buttonProps} />);
btn.simulate("click");
expect(mockDevice.moveRelative)
.toHaveBeenCalledWith({ speed: 100, x: 0, y: 1000, z: 0 });
.toHaveBeenCalledWith({ x: 0, y: 1000, z: 0 });
});
});

View File

@ -77,7 +77,7 @@ describe("<JogButtons/>", function () {
expect(button.props().title).toBe("move x axis (100)");
button.simulate("click");
expect(mockDevice.moveRelative)
.toHaveBeenCalledWith({ speed: 100, x: 100, y: 0, z: 0 });
.toHaveBeenCalledWith({ x: 100, y: 0, z: 0 });
});
it("has swapped xy jog buttons", () => {
@ -89,6 +89,6 @@ describe("<JogButtons/>", function () {
expect(button.props().title).toBe("move y axis (100)");
button.simulate("click");
expect(mockDevice.moveRelative)
.toHaveBeenCalledWith({ speed: 100, x: 0, y: 100, z: 0 });
.toHaveBeenCalledWith({ x: 0, y: 100, z: 0 });
});
});

View File

@ -1,8 +1,8 @@
import * as React from "react";
import { moveRelative } from "../../devices/actions";
import { DirectionButtonProps, Payl } from "./interfaces";
import { CONFIG_DEFAULTS } from "farmbot/dist/config";
import { DirectionButtonProps } from "./interfaces";
import { t } from "../../i18next_wrapper";
import { MoveRelProps } from "../../devices/interfaces";
export function directionDisabled(props: DirectionButtonProps): boolean {
const {
@ -41,7 +41,7 @@ export function calculateDistance(props: DirectionButtonProps) {
export class DirectionButton extends React.Component<DirectionButtonProps, {}> {
sendCommand = () => {
const payload: Payl = { speed: CONFIG_DEFAULTS.speed, x: 0, y: 0, z: 0 };
const payload: MoveRelProps = { x: 0, y: 0, z: 0 };
payload[this.props.axis] = calculateDistance(this.props);
moveRelative(payload);
}

View File

@ -31,13 +31,6 @@ export interface DirectionButtonProps {
disabled: boolean | undefined;
}
export interface Payl {
speed: number;
x: number;
y: number;
z: number;
}
export interface StepSizeSelectorProps {
choices: number[];
selected: number;

View File

@ -33,6 +33,14 @@ describe("<PinNumberDropdown />", () => {
it("renders undefined", () => {
const wrapper = mount(<PinNumberDropdown {...fakeProps()} />);
expect(wrapper.text()).toEqual("Select a pin");
expect(wrapper.find(FBSelect).props().extraClass).toEqual("");
});
it("renders when inconsistent", () => {
const p = fakeProps();
p.sourceFwConfig = () => ({ value: 0, consistent: false });
const wrapper = mount(<PinNumberDropdown {...p} />);
expect(wrapper.find(FBSelect).props().extraClass).toEqual("dim");
});
it("renders pin label", () => {

View File

@ -31,6 +31,7 @@ export const PinNumberDropdown = (props: PinNumberDropdownProps) => {
const peripheralIds = peripheralDictionary(resources);
const pinNumberNode = pinNumOrNamedPin(pinNumberValue, peripheralIds);
return <FBSelect
extraClass={props.sourceFwConfig(pinNumKey).consistent ? "" : "dim"}
selectedItem={pinNumberValue
? celery2DropDown(pinNumberNode, resources)
: undefined}

View File

@ -87,21 +87,6 @@ export enum Feature {
/** Object fetched from FEATURE_MIN_VERSIONS_URL. */
export type MinOsFeatureLookup = Partial<Record<Feature, string>>;
/** How the device is stored in the API side.
* This is what comes back from the API as JSON.
*/
export interface DeviceAccountSettings {
id: number;
name: string;
timezone?: string | undefined;
tz_offset_hrs: number;
throttled_until?: string;
throttled_at?: string;
fbos_version?: string | undefined;
last_saw_api?: string | undefined;
last_saw_mq?: string | undefined;
}
export interface BotState {
/** The browser optimistically overwrites FBOS sync status to "syncing..."
* to reduce UI latency. When AJAX/sync operations fail, we need
@ -160,11 +145,6 @@ export type BotLocationData = Record<LocationName, BotPosition>;
export type StepsPerMmXY = Record<"x" | "y", (number | undefined)>;
export interface CalibrationButtonProps {
disabled: boolean;
axis: Axis;
}
export type UserEnv = Record<string, string | undefined>;
export interface FarmbotOsProps {

View File

@ -1,6 +1,6 @@
import { Regimen } from "../../../regimens/interfaces";
import { Sequence } from "../../../sequences/interfaces";
import { ExecutableType, FarmEvent } from "farmbot/dist/resources/api_resources";
import { FarmEvent } from "farmbot/dist/resources/api_resources";
/** Would it be better to make a fully formed farm event? Join regimen, sequence, etc. */
@ -22,14 +22,4 @@ export interface FarmEventWithRegimen extends FarmEvent {
}
/** STEP 2: Once all the resource queries are done, create data that looks
* like this: */
export interface NewCalendarItem {
dayOfMonth: number;
month: string;
executable_id: number;
executable_type: ExecutableType;
farm_event_id: number;
label: string;
sortKey: number;
timeStr: string;
}
* like `CalendarDay`. */

View File

@ -269,8 +269,3 @@ export interface CurrentPointPayl {
r: number;
color?: string;
}
export interface SavedGarden {
id?: number;
name?: string;
}

View File

@ -24,10 +24,6 @@ export interface PlantLayerProps {
animate: boolean;
}
export interface CropSpreadDict {
[key: string]: number | undefined;
}
export interface GardenMapLegendProps {
zoom: (value: number) => () => void;
toggle: (property: keyof State) => () => void;
@ -76,7 +72,7 @@ export interface GardenPointProps {
point: TaggedGenericPointer;
}
export interface DragHelpersBaseProps {
interface DragHelpersBaseProps {
dragging: boolean;
mapTransformProps: MapTransformProps;
zoomLvl: number;