Farmbot-Web-App/frontend/help/tours.ts

163 lines
4.2 KiB
TypeScript
Raw Normal View History

2018-10-15 17:23:58 -06:00
import { history } from "../history";
import { Step as TourStep } from "react-joyride";
import { TourContent } from "../constants";
2019-04-02 13:59:37 -06:00
import { t } from "../i18next_wrapper";
2020-02-18 12:21:09 -07:00
import { selectAllTools } from "../resources/selectors";
import { store } from "../redux/store";
import { getFbosConfig } from "../resources/getters";
import {
2020-02-28 09:35:32 -07:00
getFwHardwareValue, hasUTM,
2020-02-18 12:21:09 -07:00
} from "../devices/components/firmware_hardware_support";
2018-10-15 17:23:58 -06:00
export enum Tours {
gettingStarted = "gettingStarted",
monitoring = "monitoring",
funStuff = "funStuff",
}
export const tourNames = () => [
{ name: Tours.gettingStarted, description: t("getting started") },
{ name: Tours.monitoring, description: t("see what FarmBot is doing") },
{ name: Tours.funStuff, description: t("find new features") },
];
2020-02-18 12:21:09 -07:00
const hasTools = () =>
selectAllTools(store.getState().resources.index).length > 0;
2020-02-26 11:10:59 -07:00
const noUTM = () =>
!hasUTM(getFwHardwareValue(
2020-02-18 12:21:09 -07:00
getFbosConfig(store.getState().resources.index)));
const toolsStep = () => hasTools()
? [{
target: ".tools",
2020-02-26 11:10:59 -07:00
content: noUTM()
2020-02-18 12:21:09 -07:00
? t(TourContent.ADD_SEED_CONTAINERS)
: t(TourContent.ADD_TOOLS),
2020-02-26 11:10:59 -07:00
title: noUTM()
2020-02-18 12:21:09 -07:00
? t("Add seed containers")
: t("Add tools and seed containers"),
}]
: [{
target: ".tools",
2020-02-26 11:10:59 -07:00
content: noUTM()
2020-02-18 12:21:09 -07:00
? t(TourContent.ADD_SEED_CONTAINERS_AND_SLOTS)
: t(TourContent.ADD_TOOLS_AND_SLOTS),
2020-02-26 11:10:59 -07:00
title: noUTM()
2020-02-18 12:21:09 -07:00
? t("Add seed containers and slots")
2020-02-20 19:38:50 -07:00
: t("Add tools and slots"),
2020-02-18 12:21:09 -07:00
}];
const toolSlotsStep = () => hasTools()
? [{
target: ".tool-slots",
content: t(TourContent.ADD_TOOLS_AND_SLOTS),
2020-02-20 19:38:50 -07:00
title: t("Add slots"),
2020-02-18 12:21:09 -07:00
}]
: [];
2018-10-15 17:23:58 -06:00
export const TOUR_STEPS = (): { [x: string]: TourStep[] } => ({
[Tours.gettingStarted]: [
{
target: ".plant-inventory-panel",
2020-02-18 12:21:09 -07:00
content: t(TourContent.ADD_PLANTS),
2018-10-15 17:23:58 -06:00
title: t("Add plants"),
},
2020-02-26 13:08:49 -07:00
...toolsStep(),
...toolSlotsStep(),
2018-10-15 17:23:58 -06:00
{
target: ".peripherals-widget",
2020-02-18 12:21:09 -07:00
content: t(TourContent.ADD_PERIPHERALS),
2018-10-15 17:23:58 -06:00
title: t("Add peripherals"),
},
{
target: ".sequence-list-panel",
2020-02-18 12:21:09 -07:00
content: t(TourContent.ADD_SEQUENCES),
2018-10-15 17:23:58 -06:00
title: t("Create sequences"),
},
{
target: ".regimen-list-panel",
2020-02-18 12:21:09 -07:00
content: t(TourContent.ADD_REGIMENS),
2018-10-15 17:23:58 -06:00
title: t("Create regimens"),
},
{
target: ".farm-event-panel",
2020-02-18 12:21:09 -07:00
content: t(TourContent.ADD_FARM_EVENTS),
2019-04-09 19:52:12 -06:00
title: t("Create events"),
2018-10-15 17:23:58 -06:00
},
],
[Tours.monitoring]: [
{
target: ".move-widget",
2020-02-18 12:21:09 -07:00
content: t(TourContent.LOCATION_GRID),
2018-10-15 17:23:58 -06:00
title: t("View current location"),
},
{
target: ".farm-designer",
2020-02-18 12:21:09 -07:00
content: t(TourContent.VIRTUAL_FARMBOT),
2018-10-15 17:23:58 -06:00
title: t("View current location"),
},
{
target: ".logs-table",
2020-02-18 12:21:09 -07:00
content: t(TourContent.LOGS_TABLE),
2018-10-15 17:23:58 -06:00
title: t("View log messages"),
},
{
target: ".photos",
2020-02-18 12:21:09 -07:00
content: t(TourContent.PHOTOS),
2018-10-15 17:23:58 -06:00
title: t("Take and view photos"),
},
],
[Tours.funStuff]: [
{
target: ".app-settings-widget",
2020-02-18 12:21:09 -07:00
content: t(TourContent.APP_SETTINGS),
2018-10-15 17:23:58 -06:00
title: t("Customize your web app experience"),
},
],
});
export const tourPageNavigation = (nextStepTarget: string | HTMLElement) => {
switch (nextStepTarget) {
case ".farm-designer":
history.push("/app/designer");
break;
case ".plant-inventory-panel":
history.push("/app/designer/plants");
break;
case ".farm-event-panel":
2019-04-09 19:52:12 -06:00
history.push("/app/designer/events");
2018-10-15 17:23:58 -06:00
break;
case ".move-widget":
case ".peripherals-widget":
history.push("/app/controls");
break;
case ".device-widget":
history.push("/app/device");
break;
case ".sequence-list-panel":
history.push("/app/sequences");
break;
case ".regimen-list-panel":
history.push("/app/regimens");
break;
case ".tool-list":
case ".toolbay-list":
history.push("/app/tools");
break;
2020-02-18 12:21:09 -07:00
case ".tools":
case ".tool-slots":
history.push("/app/designer/tools");
break;
2018-10-15 17:23:58 -06:00
case ".photos":
history.push("/app/farmware");
break;
case ".logs-table":
history.push("/app/logs");
break;
case ".app-settings-widget":
history.push("/app/account");
break;
}
};