Farmbot-Web-App/frontend/sequences/step_tiles/step_title_bar.tsx

61 lines
2.2 KiB
TypeScript
Raw Normal View History

2017-06-29 12:54:02 -06:00
import * as React from "react";
import {
SequenceBodyItem as Step, SequenceBodyItem, LegalSequenceKind,
} from "farmbot";
import { StepTitleBarProps } from "../interfaces";
import { BlurableInput } from "../../ui/index";
import { updateStepTitle } from "./index";
2019-04-02 13:59:37 -06:00
import { t } from "../../i18next_wrapper";
2017-06-29 12:54:02 -06:00
function translate(input: Step): string {
// We load translations async. If I put this const outside of the function,
// i18next might not have the correct translation loaded. To get around this,
// I had to put the translations in the function.
2019-02-26 20:12:02 -07:00
const TRANSLATIONS: Partial<Record<SequenceBodyItem["kind"], string>> = {
"_if": t("If ..."),
"execute_script": t("Run Farmware"),
"execute": t("Execute Sequence"),
"find_home": t("Find Home"),
2019-04-09 22:00:03 -06:00
"move_absolute": t("Move To"),
2017-06-29 12:54:02 -06:00
"move_relative": t("Move Relative"),
2019-04-09 22:11:26 -06:00
"read_pin": t("Read Sensor"),
2017-06-29 12:54:02 -06:00
"send_message": t("Send Message"),
"take_photo": t("Take a Photo"),
"update_resource": t("Mark As"),
["resource_update" as LegalSequenceKind]: t("Deprecated Mark As"),
2019-09-11 11:50:48 -06:00
"assertion": t("Assertion"),
2020-01-02 15:05:12 -07:00
"set_servo_angle": t("Control Servo"),
"wait": t("Wait"),
2019-04-09 22:11:26 -06:00
"write_pin": t("Control Peripheral"),
2019-02-26 20:12:02 -07:00
"sync": t("Sync"),
"power_off": t("Shutdown"),
"read_status": t("Read status"),
"emergency_unlock": t("UNLOCK"),
"emergency_lock": t("E-STOP"),
"install_first_party_farmware": t("Install first-party Farmware"),
"install_farmware": t("Install Farmware"),
"remove_farmware": t("Remove Farmware"),
"update_farmware": t("Update Farmware"),
"check_updates": t("Update"),
"calibrate": t("Calibrate"),
"home": t("Move to Home"),
"factory_reset": t("Factory reset"),
"reboot": t("Reboot"),
2020-01-02 15:05:12 -07:00
"toggle_pin": t("Toggle Peripheral"),
2019-02-26 20:12:02 -07:00
"zero": t("Set zero"),
"set_user_env": t("Set Farmware Env"),
2017-06-29 12:54:02 -06:00
};
return TRANSLATIONS[input.kind] || input.kind;
}
export class StepTitleBar extends React.Component<StepTitleBarProps, {}> {
render() {
return <BlurableInput className="step-label"
2017-06-29 12:54:02 -06:00
value={this.props.step.comment || ""}
placeholder={translate(this.props.step)}
onCommit={updateStepTitle(this.props)}
allowEmpty={true} />;
}
}