Remove all `let` exports in favor of `const` exports.
parent
f0dcbcd54f
commit
92869beb32
|
@ -1,6 +1,6 @@
|
|||
import { Everything } from "../../interfaces";
|
||||
|
||||
export let bot: Everything["bot"] = {
|
||||
export const bot: Everything["bot"] = {
|
||||
"consistent": true,
|
||||
"stepSize": 100,
|
||||
"controlPanelState": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { Everything } from "../../interfaces";
|
||||
|
||||
export let config: Everything["config"] = {
|
||||
export const config: Everything["config"] = {
|
||||
"host": "localhost",
|
||||
"port": "3000"
|
||||
};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Everything } from "../../interfaces";
|
||||
|
||||
export let draggable: Everything["draggable"] = {
|
||||
export const draggable: Everything["draggable"] = {
|
||||
"dataTransfer": {}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { TaggedImage, SpecialStatus } from "farmbot";
|
||||
|
||||
export let fakeImages: TaggedImage[] = [
|
||||
export const fakeImages: TaggedImage[] = [
|
||||
{
|
||||
"kind": "Image",
|
||||
"specialStatus": SpecialStatus.SAVED,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Everything } from "../../interfaces";
|
||||
|
||||
export let peripherals: Everything["Peripheral"] = {
|
||||
export const peripherals: Everything["Peripheral"] = {
|
||||
"isEditing": true
|
||||
};
|
||||
|
|
|
@ -34,7 +34,7 @@ import {
|
|||
import { FirmwareConfig } from "farmbot/dist/resources/configs/firmware";
|
||||
import { MessageType } from "../../sequences/interfaces";
|
||||
|
||||
export let resources: Everything["resources"] = buildResourceIndex();
|
||||
export const resources: Everything["resources"] = buildResourceIndex();
|
||||
let idCounter = 1;
|
||||
|
||||
export function fakeSequence(): TaggedSequence {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { AuthState } from "../../auth/interfaces";
|
||||
|
||||
export let auth: AuthState = {
|
||||
export const auth: AuthState = {
|
||||
"token": {
|
||||
"unencoded": {
|
||||
"jti": "xyz",
|
||||
|
|
|
@ -12,7 +12,7 @@ export const TIME = {
|
|||
SATURDAY: moment("2017-06-24T06:30:00.000-05:00")
|
||||
};
|
||||
|
||||
export let fakeFarmEventWithExecutable = (): FarmEventWithExecutable => {
|
||||
export const fakeFarmEventWithExecutable = (): FarmEventWithExecutable => {
|
||||
return {
|
||||
id: 1,
|
||||
start_time: "---",
|
||||
|
@ -29,7 +29,7 @@ export let fakeFarmEventWithExecutable = (): FarmEventWithExecutable => {
|
|||
};
|
||||
};
|
||||
|
||||
export let calendarRows = [
|
||||
export const calendarRows = [
|
||||
{
|
||||
"sortKey": 1500922800,
|
||||
"year": 17,
|
||||
|
|
|
@ -328,7 +328,7 @@ const log: TaggedLog = {
|
|||
uuid: "Log.1091396.70"
|
||||
};
|
||||
|
||||
export let FAKE_RESOURCES: TaggedResource[] = [
|
||||
export const FAKE_RESOURCES: TaggedResource[] = [
|
||||
tr1,
|
||||
fakeDevice(),
|
||||
tr2,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { User } from "farmbot/dist/resources/api_resources";
|
||||
import { TaggedUser, SpecialStatus } from "farmbot";
|
||||
|
||||
export let user: User = {
|
||||
export const user: User = {
|
||||
created_at: "2016-10-05T03:02:58.000Z",
|
||||
email: "farmbot1@farmbot.io",
|
||||
id: 2,
|
||||
|
@ -9,7 +9,7 @@ export let user: User = {
|
|||
updated_at: "2017-08-04T19:53:29.724Z"
|
||||
};
|
||||
|
||||
export let taggedUser: TaggedUser = {
|
||||
export const taggedUser: TaggedUser = {
|
||||
kind: "User",
|
||||
uuid: "1234-5678",
|
||||
specialStatus: SpecialStatus.SAVED,
|
||||
|
|
|
@ -2,7 +2,7 @@ import { AuthState } from "./interfaces";
|
|||
import { generateReducer } from "../redux/generate_reducer";
|
||||
import { Actions } from "../constants";
|
||||
|
||||
export let authReducer = generateReducer<AuthState | undefined>(undefined)
|
||||
export const authReducer = generateReducer<AuthState | undefined>(undefined)
|
||||
.add<AuthState>(Actions.REPLACE_TOKEN, (_, { payload }) => {
|
||||
return payload;
|
||||
});
|
||||
|
|
|
@ -10,7 +10,7 @@ const initialState: ConfigState = {
|
|||
port: API.inferPort()
|
||||
};
|
||||
|
||||
export let configReducer = generateReducer<ConfigState>(initialState)
|
||||
export const configReducer = generateReducer<ConfigState>(initialState)
|
||||
.add<ChangeApiPort>(Actions.CHANGE_API_PORT, (s, { payload }) => {
|
||||
s.port = payload.port.replace(/\D/g, "");
|
||||
return s;
|
||||
|
|
|
@ -14,4 +14,4 @@ const change = (state: "up" | "down") =>
|
|||
|
||||
export const networkUp = change("up");
|
||||
|
||||
export let networkDown = change("down");
|
||||
export const networkDown = change("down");
|
||||
|
|
|
@ -202,6 +202,6 @@ export const attachEventListeners =
|
|||
};
|
||||
|
||||
/** Connect to MQTT and attach all relevant event handlers. */
|
||||
export let connectDevice = (token: AuthState) =>
|
||||
export const connectDevice = (token: AuthState) =>
|
||||
(dispatch: Function, getState: GetState) => fetchNewDevice(token)
|
||||
.then(bot => attachEventListeners(bot, dispatch, getState), onOffline);
|
||||
|
|
|
@ -37,13 +37,13 @@ export const dispatchQosStart = (id: string) => {
|
|||
});
|
||||
};
|
||||
|
||||
export let dispatchNetworkUp = (edge: Edge, at: number) => {
|
||||
export const dispatchNetworkUp = (edge: Edge, at: number) => {
|
||||
if (shouldThrottle(edge, at)) { return; }
|
||||
store.dispatch(networkUp(edge, at));
|
||||
bumpThrottle(edge, at);
|
||||
};
|
||||
|
||||
export let dispatchNetworkDown = (edge: Edge, at: number) => {
|
||||
export const dispatchNetworkDown = (edge: Edge, at: number) => {
|
||||
if (shouldThrottle(edge, at)) { return; }
|
||||
store.dispatch(networkDown(edge, at));
|
||||
bumpThrottle(edge, at);
|
||||
|
|
|
@ -17,7 +17,7 @@ export const DEFAULT_STATE: ConnectionState = {
|
|||
};
|
||||
export type PingResultPayload = { id: string, at: number };
|
||||
|
||||
export let connectivityReducer =
|
||||
export const connectivityReducer =
|
||||
generateReducer<ConnectionState>(DEFAULT_STATE)
|
||||
.add<{ id: string }>(Actions.PING_START, (s, { payload }) => {
|
||||
return { ...s, pings: startPing(s.pings, payload.id) };
|
||||
|
|
|
@ -8,7 +8,7 @@ const Axis = ({ val }: { val: number | undefined }) => <Col xs={3}>
|
|||
<input disabled value={isNumber(val) ? val : "---"} />
|
||||
</Col>;
|
||||
|
||||
export let AxisDisplayGroup = ({ position, label }: AxisDisplayGroupProps) => {
|
||||
export const AxisDisplayGroup = ({ position, label }: AxisDisplayGroupProps) => {
|
||||
const { x, y, z } = position;
|
||||
return <Row>
|
||||
<Axis val={x} />
|
||||
|
|
|
@ -3,7 +3,7 @@ import { AxisInputBoxProps } from "./interfaces";
|
|||
import { Col, BlurableInput } from "../ui/index";
|
||||
import { isUndefined } from "lodash";
|
||||
|
||||
export let AxisInputBox = ({ onChange, value, axis }: AxisInputBoxProps) => {
|
||||
export const AxisInputBox = ({ onChange, value, axis }: AxisInputBoxProps) => {
|
||||
return <Col xs={3}>
|
||||
<BlurableInput
|
||||
value={(isUndefined(value) ? "" : value)}
|
||||
|
|
|
@ -245,7 +245,7 @@ function validMinOsFeatureLookup(x: MinOsFeatureLookup): boolean {
|
|||
* Fetch and save minimum FBOS version data for UI feature display.
|
||||
* @param url location of data
|
||||
*/
|
||||
export let fetchMinOsFeatureData = (url: string) =>
|
||||
export const fetchMinOsFeatureData = (url: string) =>
|
||||
(dispatch: Function) => {
|
||||
axios
|
||||
.get<MinOsFeatureLookup>(url)
|
||||
|
|
|
@ -10,7 +10,7 @@ interface Props {
|
|||
expanded: boolean;
|
||||
}
|
||||
|
||||
export let Header = (props: Props) => {
|
||||
export const Header = (props: Props) => {
|
||||
const { dispatch, name, title, expanded } = props;
|
||||
return <ExpandableHeader
|
||||
expanded={expanded}
|
||||
|
|
|
@ -18,7 +18,7 @@ const afterEach = (state: BotState, a: ReduxAction<{}>) => {
|
|||
return state;
|
||||
};
|
||||
|
||||
export let initialState = (): BotState => ({
|
||||
export const initialState = (): BotState => ({
|
||||
consistent: true,
|
||||
stepSize: 100,
|
||||
controlPanelState: {
|
||||
|
@ -81,7 +81,7 @@ export let initialState = (): BotState => ({
|
|||
}
|
||||
});
|
||||
|
||||
export let botReducer = generateReducer<BotState>(initialState())
|
||||
export const botReducer = generateReducer<BotState>(initialState())
|
||||
.afterEach(afterEach)
|
||||
.add<boolean>(Actions.SET_CONSISTENCY, (s, a) => {
|
||||
s.consistent = a.payload;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
export let list = ["Africa/Abidjan",
|
||||
export const list = ["Africa/Abidjan",
|
||||
"Africa/Accra",
|
||||
"Africa/Addis_Ababa",
|
||||
"Africa/Algiers",
|
||||
|
|
|
@ -6,7 +6,7 @@ const INITIAL_STATE: DraggableState = {
|
|||
dataTransfer: {}
|
||||
};
|
||||
|
||||
export let draggableReducer = generateReducer<DraggableState>(INITIAL_STATE)
|
||||
export const draggableReducer = generateReducer<DraggableState>(INITIAL_STATE)
|
||||
.add<DataXfer>(Actions.PUT_DATA_XFER, (s, { payload }) => {
|
||||
s.dataTransfer[payload.uuid] = payload;
|
||||
return s;
|
||||
|
|
|
@ -18,7 +18,7 @@ export const NULL_DRAGGER_ID = 0xCAFEF00D;
|
|||
* Drag this!
|
||||
* </button>
|
||||
* */
|
||||
export let stepDragEventHandler = (dispatch: Function,
|
||||
export const stepDragEventHandler = (dispatch: Function,
|
||||
step: Step,
|
||||
intent: DataXferIntent,
|
||||
draggerId: number) => {
|
||||
|
|
|
@ -161,4 +161,4 @@ export class PureFarmEvents
|
|||
* It avoids mocking `connect` in unit tests.
|
||||
* See testing pattern noted here: https://github.com/airbnb/enzyme/issues/98
|
||||
*/
|
||||
export let FarmEvents = connect(mapStateToProps)(PureFarmEvents);
|
||||
export const FarmEvents = connect(mapStateToProps)(PureFarmEvents);
|
||||
|
|
|
@ -65,7 +65,7 @@ export const nextRegItemTimes =
|
|||
&& time.isSameOrAfter(moment(startTime)));
|
||||
};
|
||||
|
||||
export let regimenCalendarAdder = (
|
||||
export const regimenCalendarAdder = (
|
||||
index: ResourceIndex, timeSettings: TimeSettings) =>
|
||||
(f: FarmEventWithRegimen, c: Calendar, now = moment()) => {
|
||||
const { regimen_items } = f.executable;
|
||||
|
@ -96,7 +96,7 @@ export let regimenCalendarAdder = (
|
|||
}
|
||||
};
|
||||
|
||||
export let addSequenceToCalendar =
|
||||
export const addSequenceToCalendar =
|
||||
(f: FarmEventWithSequence, c: Calendar, timeSettings: TimeSettings,
|
||||
now = moment()) => {
|
||||
const schedule = scheduleForFarmEvent(f, now);
|
||||
|
|
|
@ -36,17 +36,17 @@ import { getFbosConfig } from "../../resources/getters";
|
|||
import { t } from "../../i18next_wrapper";
|
||||
import { DevSettings } from "../../account/dev/dev_support";
|
||||
|
||||
export let formatTime = (input: string, timeSettings: TimeSettings) => {
|
||||
export const formatTime = (input: string, timeSettings: TimeSettings) => {
|
||||
const iso = new Date(input).toISOString();
|
||||
return moment(iso).utcOffset(timeSettings.utcOffset).format("HH:mm");
|
||||
};
|
||||
|
||||
export let formatDate = (input: string, timeSettings: TimeSettings) => {
|
||||
export const formatDate = (input: string, timeSettings: TimeSettings) => {
|
||||
const iso = new Date(input).toISOString();
|
||||
return moment(iso).utcOffset(timeSettings.utcOffset).format("YYYY-MM-DD");
|
||||
};
|
||||
|
||||
export let repeatOptions = [
|
||||
export const repeatOptions = [
|
||||
{ label: t("Minutes"), value: "minutely", name: "time_unit" },
|
||||
{ label: t("Hours"), value: "hourly", name: "time_unit" },
|
||||
{ label: t("Days"), value: "daily", name: "time_unit" },
|
||||
|
|
|
@ -68,8 +68,8 @@ export namespace OpenFarm {
|
|||
attributes: ImageAttrs;
|
||||
}
|
||||
|
||||
export let cropUrl = "https://openfarm.cc/api/v1/crops";
|
||||
export let browsingCropUrl = "https://openfarm.cc/crops/";
|
||||
export const cropUrl = "https://openfarm.cc/api/v1/crops";
|
||||
export const browsingCropUrl = "https://openfarm.cc/crops/";
|
||||
}
|
||||
/** Returned by https://openfarm.cc/api/v1/crops?filter=q */
|
||||
export interface CropSearchResult {
|
||||
|
|
|
@ -7,7 +7,7 @@ import { Actions } from "../constants";
|
|||
import { BotPosition } from "../devices/interfaces";
|
||||
import { PointGroupSortType } from "farmbot/dist/resources/api_resources";
|
||||
|
||||
export let initialState: DesignerState = {
|
||||
export const initialState: DesignerState = {
|
||||
selectedPlants: undefined,
|
||||
hoveredPlant: {
|
||||
plantUUID: undefined,
|
||||
|
@ -24,7 +24,7 @@ export let initialState: DesignerState = {
|
|||
tryGroupSortType: undefined,
|
||||
};
|
||||
|
||||
export let designer = generateReducer<DesignerState>(initialState)
|
||||
export const designer = generateReducer<DesignerState>(initialState)
|
||||
.add<string>(Actions.SEARCH_QUERY_CHANGE, (s, { payload }) => {
|
||||
s.cropSearchInProgress = true;
|
||||
const state = cloneDeep(s);
|
||||
|
|
|
@ -15,7 +15,7 @@ interface IdURL {
|
|||
}
|
||||
|
||||
const FALLBACK: OpenFarm.Included[] = [];
|
||||
export let OFSearch = (searchTerm: string) =>
|
||||
export const OFSearch = (searchTerm: string) =>
|
||||
(dispatch: Function) => {
|
||||
dispatch({ type: Actions.OF_SEARCH_RESULTS_START, payload: undefined });
|
||||
openFarmSearchQuery(searchTerm)
|
||||
|
|
|
@ -3,14 +3,14 @@ import { FarmwareState } from "./interfaces";
|
|||
import { TaggedResource } from "farmbot";
|
||||
import { Actions } from "../constants";
|
||||
|
||||
export let farmwareState: FarmwareState = {
|
||||
export const farmwareState: FarmwareState = {
|
||||
currentFarmware: undefined,
|
||||
currentImage: undefined,
|
||||
firstPartyFarmwareNames: [],
|
||||
infoOpen: false,
|
||||
};
|
||||
|
||||
export let farmwareReducer = generateReducer<FarmwareState>(farmwareState)
|
||||
export const farmwareReducer = generateReducer<FarmwareState>(farmwareState)
|
||||
.add<TaggedResource>(Actions.INIT_RESOURCE, (s, { payload }) => {
|
||||
if (payload.kind === "Image") {
|
||||
s.currentImage = payload.uuid;
|
||||
|
|
|
@ -5,14 +5,14 @@ import { envGet } from "./remote_env/selectors";
|
|||
|
||||
/** Convert values like SPECIAL_VALUES.TRUE to drop down items with friendly
|
||||
* label/value pairs. */
|
||||
export let translateSpecialValue = (input: number): DropDownItem => {
|
||||
export const translateSpecialValue = (input: number): DropDownItem => {
|
||||
return SPECIAL_VALUE_DDI[input] || NULL_CHOICE;
|
||||
};
|
||||
|
||||
/** Generates a lookup function to convert WeedDetector ENV items to
|
||||
* DropDownItems. Used to display currently selected options within dropdown
|
||||
* menus. */
|
||||
export let getDropdownSelection = (env: Partial<WD_ENV>) =>
|
||||
export const getDropdownSelection = (env: Partial<WD_ENV>) =>
|
||||
(key: keyof WD_ENV): DropDownItem => {
|
||||
return translateSpecialValue(envGet(key, env));
|
||||
};
|
||||
|
|
|
@ -5,11 +5,11 @@ export interface HelpState {
|
|||
currentTour: string | undefined;
|
||||
}
|
||||
|
||||
export let initialState: HelpState = {
|
||||
export const initialState: HelpState = {
|
||||
currentTour: undefined,
|
||||
};
|
||||
|
||||
export let helpReducer = generateReducer<HelpState>(initialState)
|
||||
export const helpReducer = generateReducer<HelpState>(initialState)
|
||||
.add<string>(Actions.START_TOUR, (s, { payload }) => {
|
||||
s.currentTour = payload;
|
||||
return s;
|
||||
|
|
|
@ -2,13 +2,13 @@ import { DataChangeType, Dictionary } from "farmbot/dist";
|
|||
import { box } from "boxed_value";
|
||||
import { isNumber, isNaN } from "lodash";
|
||||
|
||||
export let METHOD_MAP: Dictionary<DataChangeType> = {
|
||||
export const METHOD_MAP: Dictionary<DataChangeType> = {
|
||||
"post": "add",
|
||||
"put": "update",
|
||||
"patch": "update",
|
||||
"delete": "remove"
|
||||
};
|
||||
export let METHODS = ["post", "put", "patch", "delete"];
|
||||
export const METHODS = ["post", "put", "patch", "delete"];
|
||||
|
||||
/** More nasty hacks until we have time to implement proper API push state
|
||||
* notifications. */
|
||||
|
|
|
@ -5,7 +5,7 @@ import { MobileMenuProps } from "./interfaces";
|
|||
|
||||
const classes = [Classes.CARD, Classes.ELEVATION_4, "mobile-menu"];
|
||||
|
||||
export let MobileMenu = (props: MobileMenuProps) => {
|
||||
export const MobileMenu = (props: MobileMenuProps) => {
|
||||
const isActive = props.mobileMenuOpen ? "active" : "inactive";
|
||||
const { alertCount } = props;
|
||||
return <div>
|
||||
|
|
|
@ -72,7 +72,7 @@ const Ticker = (log: TaggedLog, timeSettings: TimeSettings) => {
|
|||
};
|
||||
|
||||
/** The logs ticker, with closed/open views, and a link to the Logs page. */
|
||||
export let TickerList = (props: TickerListProps) => {
|
||||
export const TickerList = (props: TickerListProps) => {
|
||||
return <ErrorBoundary>
|
||||
<div className="ticker-list" onClick={props.toggle("tickerListOpen")}>
|
||||
<div className="first-ticker">
|
||||
|
|
|
@ -21,7 +21,7 @@ export interface OFCropResponse {
|
|||
}
|
||||
|
||||
export namespace OpenFarmAPI {
|
||||
export let OFBaseURL = BASE;
|
||||
export const OFBaseURL = BASE;
|
||||
}
|
||||
|
||||
export function svgToUrl(xml: string | undefined): string {
|
||||
|
|
|
@ -20,7 +20,7 @@ export interface MiddlewareConfig { fn: MW; env: EnvName; }
|
|||
|
||||
/** To make it easier to manage all things watching the state tree,
|
||||
* we keep subscriber functions in this array. */
|
||||
export let mwConfig: MiddlewareConfig[] = [
|
||||
export const mwConfig: MiddlewareConfig[] = [
|
||||
{ env: "*", fn: thunk },
|
||||
{ env: "development", fn: require("redux-immutable-state-invariant").default() },
|
||||
stateFetchMiddlewareConfig,
|
||||
|
|
|
@ -17,7 +17,7 @@ const reducerRecord = {
|
|||
resources: resourceReducer,
|
||||
};
|
||||
|
||||
export let reducers = combineReducers(reducerRecord);
|
||||
export const reducers = combineReducers(reducerRecord);
|
||||
|
||||
Object.keys(reducerRecord).map((x: keyof typeof reducerRecord) => {
|
||||
if (!reducerRecord[x]) {
|
||||
|
|
|
@ -6,10 +6,9 @@ import { getMiddleware } from "./middlewares";
|
|||
import { set } from "lodash";
|
||||
|
||||
function dev(): Store {
|
||||
store = createStore(rootReducer,
|
||||
return createStore(rootReducer,
|
||||
maybeFetchOldState(),
|
||||
getMiddleware("development"));
|
||||
return store;
|
||||
}
|
||||
|
||||
function prod(): Store {
|
||||
|
@ -26,7 +25,7 @@ export function configureStore() {
|
|||
return store2;
|
||||
}
|
||||
|
||||
export let store = configureStore();
|
||||
export const store = configureStore();
|
||||
|
||||
/** Tries to fetch previous state from `sessionStorage`.
|
||||
* Returns {} if nothing is found. Used mostly for hot reloading. */
|
||||
|
|
|
@ -52,7 +52,7 @@ export interface Subscription { fn: (state: Everything) => void; env: EnvName; }
|
|||
|
||||
/** To make it easier to manage all things watching the state tree,
|
||||
* we keep subscriber functions in this array. */
|
||||
export let subscriptions: Subscription[] = [{ env: "*", fn: unsavedCheck }];
|
||||
export const subscriptions: Subscription[] = [{ env: "*", fn: unsavedCheck }];
|
||||
|
||||
export function registerSubscribers(store: Store) {
|
||||
const ENV_LIST = [process.env.NODE_ENV, "*"];
|
||||
|
|
|
@ -11,7 +11,7 @@ const ok = (x: AxiosResponse<AuthState>) => {
|
|||
|
||||
/** Grab a new token from the API (won't extend token's exp. date).
|
||||
* Redirect to home page on failure. */
|
||||
export let maybeRefreshToken
|
||||
export const maybeRefreshToken
|
||||
= (old: AuthState): Promise<AuthState | undefined> => {
|
||||
API.setBaseUrl(old.token.unencoded.iss);
|
||||
setToken(old); // Precaution: The Axios interceptors might not be set yet.
|
||||
|
|
|
@ -36,9 +36,9 @@ function newState(): RegimenState {
|
|||
};
|
||||
}
|
||||
|
||||
export let initialState: RegimenState = newState();
|
||||
export const initialState: RegimenState = newState();
|
||||
|
||||
export let regimensReducer = generateReducer<RegimenState>(initialState)
|
||||
export const regimensReducer = generateReducer<RegimenState>(initialState)
|
||||
.add<TaggedResource>(Actions.DESTROY_RESOURCE_OK, (s, { payload }) => {
|
||||
switch (payload.uuid) {
|
||||
case s.selectedSequenceUUID:
|
||||
|
|
|
@ -33,6 +33,6 @@ export const generalizedError = (payload: GeneralizedError) => {
|
|||
return { type: Actions._RESOURCE_NO, payload };
|
||||
};
|
||||
|
||||
export let destroyNO = generalizedError;
|
||||
export let createNO = generalizedError;
|
||||
export let updateNO = generalizedError;
|
||||
export const destroyNO = generalizedError;
|
||||
export const createNO = generalizedError;
|
||||
export const updateNO = generalizedError;
|
||||
|
|
|
@ -40,7 +40,7 @@ export * from "./selectors_for_indexing";
|
|||
* unless there is actually a reason for the resource to not have a UUID.
|
||||
* `findId()` is more appropriate 99% of the time because it can spot
|
||||
* referential integrity issues. */
|
||||
export let maybeDetermineUuid =
|
||||
export const maybeDetermineUuid =
|
||||
(index: ResourceIndex, kind: ResourceName, id: number) => {
|
||||
const kni = joinKindAndId(kind, id);
|
||||
const uuid = index.byKindAndId[kni];
|
||||
|
@ -50,7 +50,7 @@ export let maybeDetermineUuid =
|
|||
}
|
||||
};
|
||||
|
||||
export let findId = (index: ResourceIndex, kind: ResourceName, id: number): UUID => {
|
||||
export const findId = (index: ResourceIndex, kind: ResourceName, id: number): UUID => {
|
||||
const uuid = maybeDetermineUuid(index, kind, id);
|
||||
if (uuid) {
|
||||
return uuid;
|
||||
|
@ -59,7 +59,7 @@ export let findId = (index: ResourceIndex, kind: ResourceName, id: number): UUID
|
|||
}
|
||||
};
|
||||
|
||||
export let isKind = (name: ResourceName) => (tr: TaggedResource) => tr.kind === name;
|
||||
export const isKind = (name: ResourceName) => (tr: TaggedResource) => tr.kind === name;
|
||||
|
||||
export function groupPointsByType(index: ResourceIndex) {
|
||||
return chain(selectAllActivePoints(index))
|
||||
|
@ -151,7 +151,7 @@ export function getSequenceByUUID(index: ResourceIndex,
|
|||
|
||||
/** GIVEN: a slot UUID.
|
||||
* FINDS: Tool in that slot (if any) */
|
||||
export let currentToolInSlot = (index: ResourceIndex) =>
|
||||
export const currentToolInSlot = (index: ResourceIndex) =>
|
||||
(toolSlotUUID: string): TaggedTool | undefined => {
|
||||
const currentSlot = selectCurrentToolSlot(index, toolSlotUUID);
|
||||
if (currentSlot
|
||||
|
|
|
@ -31,7 +31,7 @@ export const findAllById =
|
|||
return output;
|
||||
};
|
||||
|
||||
export let byId =
|
||||
export const byId =
|
||||
<T extends TaggedResource>(name: T["kind"]) =>
|
||||
(index: ResourceIndex, id: number): T | undefined => {
|
||||
const resources = findAll(index, name);
|
||||
|
@ -40,7 +40,7 @@ export let byId =
|
|||
return resources.filter(f)[0] as T | undefined;
|
||||
};
|
||||
|
||||
export let findFarmEventById = (ri: ResourceIndex, fe_id: number) => {
|
||||
export const findFarmEventById = (ri: ResourceIndex, fe_id: number) => {
|
||||
const fe = byId("FarmEvent")(ri, fe_id);
|
||||
if (fe && isTaggedFarmEvent(fe) && sanityCheck(fe)) {
|
||||
return fe;
|
||||
|
@ -50,7 +50,7 @@ export let findFarmEventById = (ri: ResourceIndex, fe_id: number) => {
|
|||
}
|
||||
};
|
||||
|
||||
export let maybeFindToolById = (ri: ResourceIndex, tool_id?: number):
|
||||
export const maybeFindToolById = (ri: ResourceIndex, tool_id?: number):
|
||||
TaggedTool | undefined => {
|
||||
const tool = tool_id && byId("Tool")(ri, tool_id);
|
||||
if (tool && isTaggedTool(tool) && sanityCheck(tool)) {
|
||||
|
@ -60,7 +60,7 @@ export let maybeFindToolById = (ri: ResourceIndex, tool_id?: number):
|
|||
}
|
||||
};
|
||||
|
||||
export let findToolById = (ri: ResourceIndex, tool_id: number) => {
|
||||
export const findToolById = (ri: ResourceIndex, tool_id: number) => {
|
||||
const tool = maybeFindToolById(ri, tool_id);
|
||||
if (tool) {
|
||||
return tool;
|
||||
|
@ -69,7 +69,7 @@ export let findToolById = (ri: ResourceIndex, tool_id: number) => {
|
|||
}
|
||||
};
|
||||
|
||||
export let findSequenceById = (ri: ResourceIndex, sequence_id: number) => {
|
||||
export const findSequenceById = (ri: ResourceIndex, sequence_id: number) => {
|
||||
const sequence = byId("Sequence")(ri, sequence_id);
|
||||
if (sequence && isTaggedSequence(sequence) && sanityCheck(sequence)) {
|
||||
return sequence;
|
||||
|
@ -78,9 +78,9 @@ export let findSequenceById = (ri: ResourceIndex, sequence_id: number) => {
|
|||
}
|
||||
};
|
||||
|
||||
export let findSlotById = byId<TaggedToolSlotPointer>("Point");
|
||||
export const findSlotById = byId<TaggedToolSlotPointer>("Point");
|
||||
/** Find a Tool's corresponding Slot. */
|
||||
export let findSlotByToolId = (index: ResourceIndex, tool_id: number) => {
|
||||
export const findSlotByToolId = (index: ResourceIndex, tool_id: number) => {
|
||||
const tool = findToolById(index, tool_id);
|
||||
const query = { body: { tool_id: tool.body.id } };
|
||||
const every = Object
|
||||
|
@ -122,7 +122,7 @@ export function maybeFindSavedGardenById(index: ResourceIndex, id: number) {
|
|||
if (resource && isTaggedSavedGarden(resource)) { return resource; }
|
||||
}
|
||||
|
||||
export let findRegimenById = (ri: ResourceIndex, regimen_id: number) => {
|
||||
export const findRegimenById = (ri: ResourceIndex, regimen_id: number) => {
|
||||
const regimen = byId("Regimen")(ri, regimen_id);
|
||||
if (regimen && isTaggedRegimen(regimen) && sanityCheck(regimen)) {
|
||||
return regimen;
|
||||
|
|
|
@ -54,13 +54,13 @@ const uuidFinder = <T extends TaggedResource>(r: T["kind"]) =>
|
|||
}
|
||||
};
|
||||
|
||||
export let findTool = uuidFinder<TaggedTool>("Tool");
|
||||
export let findSequence = uuidFinder<TaggedSequence>("Sequence");
|
||||
export let findRegimen = uuidFinder<TaggedRegimen>("Regimen");
|
||||
export let findFarmEvent = uuidFinder<TaggedFarmEvent>("FarmEvent");
|
||||
export let findPoints = uuidFinder<TaggedPoint>("Point");
|
||||
export let findPointGroup = uuidFinder<TaggedPoint>("Point");
|
||||
export let findSavedGarden = uuidFinder<TaggedSavedGarden>("SavedGarden");
|
||||
export const findTool = uuidFinder<TaggedTool>("Tool");
|
||||
export const findSequence = uuidFinder<TaggedSequence>("Sequence");
|
||||
export const findRegimen = uuidFinder<TaggedRegimen>("Regimen");
|
||||
export const findFarmEvent = uuidFinder<TaggedFarmEvent>("FarmEvent");
|
||||
export const findPoints = uuidFinder<TaggedPoint>("Point");
|
||||
export const findPointGroup = uuidFinder<TaggedPoint>("Point");
|
||||
export const findSavedGarden = uuidFinder<TaggedSavedGarden>("SavedGarden");
|
||||
|
||||
export const selectAllCrops =
|
||||
(i: ResourceIndex) => findAll<TaggedCrop>(i, "Crop");
|
||||
|
|
|
@ -79,29 +79,29 @@ function isTaggedPoint(x: {}): x is PointerType {
|
|||
return (is("Point")(x)) && (x.kind === "Point");
|
||||
}
|
||||
|
||||
export let isTaggedRegimen =
|
||||
export const isTaggedRegimen =
|
||||
(x: object): x is TaggedRegimen => is("Regimen")(x);
|
||||
export let isTaggedFolder =
|
||||
export const isTaggedFolder =
|
||||
(x: object): x is TaggedRegimen => is("Folder")(x);
|
||||
export let isTaggedSequence =
|
||||
export const isTaggedSequence =
|
||||
(x: object): x is TaggedSequence => is("Sequence")(x);
|
||||
export let isTaggedTool =
|
||||
export const isTaggedTool =
|
||||
(x: object): x is TaggedTool => is("Tool")(x);
|
||||
export let isTaggedFarmEvent =
|
||||
export const isTaggedFarmEvent =
|
||||
(x: object): x is TaggedFarmEvent => is("FarmEvent")(x);
|
||||
export let isTaggedToolSlotPointer =
|
||||
export const isTaggedToolSlotPointer =
|
||||
(x: object): x is TaggedToolSlotPointer => {
|
||||
return isTaggedPoint(x) && (x.body.pointer_type === "ToolSlot");
|
||||
};
|
||||
export let isTaggedPlantPointer =
|
||||
export const isTaggedPlantPointer =
|
||||
(x: object): x is TaggedPlantPointer => {
|
||||
return isTaggedPoint(x) && (x.body.pointer_type === "Plant");
|
||||
};
|
||||
export let isTaggedGenericPointer =
|
||||
export const isTaggedGenericPointer =
|
||||
(x: object): x is TaggedGenericPointer => {
|
||||
return isTaggedPoint(x) && (x.body.pointer_type === "GenericPointer");
|
||||
};
|
||||
export let isTaggedSavedGarden =
|
||||
export const isTaggedSavedGarden =
|
||||
(x: object): x is TaggedSavedGarden => is("SavedGarden")(x);
|
||||
export let isTaggedPlantTemplate =
|
||||
export const isTaggedPlantTemplate =
|
||||
(x: object): x is TaggedPlantTemplate => is("PlantTemplate")(x);
|
||||
|
|
|
@ -9,7 +9,7 @@ export const initialState: SequenceReducerState = {
|
|||
stepIndex: undefined,
|
||||
};
|
||||
|
||||
export let sequenceReducer = generateReducer<SequenceReducerState>(initialState)
|
||||
export const sequenceReducer = generateReducer<SequenceReducerState>(initialState)
|
||||
.add<TaggedResource>(Actions.DESTROY_RESOURCE_OK, (s, { payload }) => {
|
||||
switch (payload.uuid) {
|
||||
case s.current:
|
||||
|
|
|
@ -118,7 +118,7 @@ export function InnerIf(props: IfParams) {
|
|||
/** Creates a function that can be used in the `onChange` event of a _else or
|
||||
* _then block in the sequence editor.
|
||||
*/
|
||||
export let IfBlockDropDownHandler = (props: ThenElseParams) => {
|
||||
export const IfBlockDropDownHandler = (props: ThenElseParams) => {
|
||||
|
||||
const { dispatch, index, thenElseKey } = props;
|
||||
const step = props.currentStep;
|
||||
|
|
|
@ -7,7 +7,7 @@ interface Props {
|
|||
expanded: boolean;
|
||||
}
|
||||
|
||||
export let ExpandableHeader = (props: Props) => {
|
||||
export const ExpandableHeader = (props: Props) => {
|
||||
const { onClick, title, expanded } = props;
|
||||
const icon_string = expanded ? "minus" : "plus";
|
||||
const nbwhitespace = title != "";
|
||||
|
|
|
@ -18,7 +18,7 @@ import {
|
|||
} from "lodash";
|
||||
import { t } from "../i18next_wrapper";
|
||||
|
||||
export let colors: Array<ResourceColor> = [
|
||||
export const colors: Array<ResourceColor> = [
|
||||
"blue",
|
||||
"green",
|
||||
"yellow",
|
||||
|
|
Loading…
Reference in New Issue