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,
|
2021-01-06 04:08:18 +00:00
|
|
|
|
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 = {
|
2021-01-15 09:19:15 +00:00
|
|
|
|
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]: {
|
2021-01-15 09:19:15 +00:00
|
|
|
|
name: "NONE",
|
2020-12-30 07:31:20 +00:00
|
|
|
|
setup: () => {
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
title: "",
|
|
|
|
|
|
description: "",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
[OnboardingStep.WELCOME]: {
|
2021-01-15 09:19:15 +00:00
|
|
|
|
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]: {
|
2021-01-15 09:19:15 +00:00
|
|
|
|
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:
|
|
|
|
|
|
"We’ve connected to an example Postgres database. You can now query it.",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
[OnboardingStep.RUN_QUERY]: {
|
2021-01-15 09:19:15 +00:00
|
|
|
|
name: "RUN_QUERY",
|
2020-12-30 07:31:20 +00:00
|
|
|
|
setup: () => {
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
title:
|
|
|
|
|
|
"This is where you query data. Here’s one that fetches a list of users stored in the DB.",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
[OnboardingStep.RUN_QUERY_SUCCESS]: {
|
2021-01-15 09:19:15 +00:00
|
|
|
|
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 let’s connect it to a UI widget.",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
[OnboardingStep.ADD_WIDGET]: {
|
2021-01-15 09:19:15 +00:00
|
|
|
|
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]: {
|
2021-01-15 09:19:15 +00:00
|
|
|
|
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]: {
|
2021-01-15 09:19:15 +00:00
|
|
|
|
name: "DEPLOY",
|
2020-12-30 07:31:20 +00:00
|
|
|
|
setup: () => {
|
|
|
|
|
|
return [
|
|
|
|
|
|
{
|
|
|
|
|
|
type: ReduxActionTypes.LISTEN_FOR_DEPLOY,
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
},
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
title: "You’re almost done! Just Hit Deploy",
|
|
|
|
|
|
isFinalStep: true,
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2021-01-06 04:08:18 +00:00
|
|
|
|
// Final step
|
|
|
|
|
|
[OnboardingStep.FINISH]: {
|
2021-01-15 09:19:15 +00:00
|
|
|
|
name: "FINISH",
|
2021-01-06 04:08:18 +00:00
|
|
|
|
setup: () => {
|
|
|
|
|
|
return [];
|
|
|
|
|
|
},
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
title: "",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2020-12-30 07:31:20 +00:00
|
|
|
|
};
|