PromucFlow_constructor/app/client/src/constants/OnboardingConstants.tsx

153 lines
3.3 KiB
TypeScript
Raw Normal View History

2020-12-30 07:31:20 +00:00
import { ReduxAction, ReduxActionTypes } from "./ReduxActionConstants";
2021-01-11 04:16:59 +00:00
import { showTooltip } from "actions/onboardingActions";
2020-12-30 07:31:20 +00:00
export enum OnboardingStep {
NONE = -1,
WELCOME = 0,
EXAMPLE_DATABASE = 1,
RUN_QUERY = 2,
RUN_QUERY_SUCCESS = 3,
ADD_WIDGET = 4,
SUCCESSFUL_BINDING = 5,
DEPLOY = 6,
FINISH = 7,
2020-12-30 07:31:20 +00:00
}
export type OnboardingTooltip = {
title: string;
description?: string;
action?: {
label: string;
action?: ReduxAction<OnboardingStep>;
};
2021-01-11 04:16:59 +00:00
onClickOutside?: ReduxAction<any>;
2020-12-30 07:31:20 +00:00
snippet?: string;
isFinalStep?: boolean;
};
export type OnboardingStepConfig = {
name: string;
2020-12-30 07:31:20 +00:00
setup: () => { type: string; payload?: any }[];
tooltip: OnboardingTooltip;
};
export const OnboardingConfig: Record<OnboardingStep, OnboardingStepConfig> = {
[OnboardingStep.NONE]: {
name: "NONE",
2020-12-30 07:31:20 +00:00
setup: () => {
return [];
},
tooltip: {
title: "",
description: "",
},
},
[OnboardingStep.WELCOME]: {
name: "WELCOME",
2020-12-30 07:31:20 +00:00
setup: () => {
// To setup the state if any
// Return action that needs to be dispatched
return [
{
type: ReduxActionTypes.SHOW_WELCOME,
},
];
},
tooltip: {
title: "",
description: "",
},
},
[OnboardingStep.EXAMPLE_DATABASE]: {
name: "EXAMPLE_DATABASE",
2020-12-30 07:31:20 +00:00
setup: () => {
return [
{
type: ReduxActionTypes.CREATE_ONBOARDING_DBQUERY_INIT,
},
{
type: ReduxActionTypes.LISTEN_FOR_CREATE_ACTION,
},
];
},
tooltip: {
title:
"Weve connected to an example Postgres database. You can now query it.",
},
},
[OnboardingStep.RUN_QUERY]: {
name: "RUN_QUERY",
2020-12-30 07:31:20 +00:00
setup: () => {
return [];
},
tooltip: {
title:
"This is where you query data. Heres one that fetches a list of users stored in the DB.",
},
},
[OnboardingStep.RUN_QUERY_SUCCESS]: {
name: "RUN_QUERY_SUCCESS",
2020-12-30 07:31:20 +00:00
setup: () => {
return [
{
type: ReduxActionTypes.LISTEN_FOR_ADD_WIDGET,
},
{
type: ReduxActionTypes.LISTEN_FOR_TABLE_WIDGET_BINDING,
},
];
},
tooltip: {
title:
"This is the response from your query. Now lets connect it to a UI widget.",
},
},
[OnboardingStep.ADD_WIDGET]: {
name: "ADD_WIDGET",
2020-12-30 07:31:20 +00:00
setup: () => {
return [];
},
tooltip: {
title:
"Your first widget 🎉 Copy the snippet below and paste it inside TableData to see the magic",
snippet: "{{ExampleQuery.data}}",
},
},
[OnboardingStep.SUCCESSFUL_BINDING]: {
name: "SUCCESSFUL_BINDING",
2020-12-30 07:31:20 +00:00
setup: () => {
2021-01-11 04:16:59 +00:00
return [];
2020-12-30 07:31:20 +00:00
},
tooltip: {
title: "Your widget is now talking to your data 👌👏",
description:
"You can access widgets and actions as JS variables anywhere inside {{ }}",
2021-01-11 04:16:59 +00:00
onClickOutside: showTooltip(OnboardingStep.DEPLOY),
2020-12-30 07:31:20 +00:00
},
},
[OnboardingStep.DEPLOY]: {
name: "DEPLOY",
2020-12-30 07:31:20 +00:00
setup: () => {
return [
{
type: ReduxActionTypes.LISTEN_FOR_DEPLOY,
},
];
},
tooltip: {
title: "Youre almost done! Just Hit Deploy",
isFinalStep: true,
},
},
// Final step
[OnboardingStep.FINISH]: {
name: "FINISH",
setup: () => {
return [];
},
tooltip: {
title: "",
},
},
2020-12-30 07:31:20 +00:00
};