diff --git a/packages/backend/src/apps/twitter/info.json b/packages/backend/src/apps/twitter/info.json index 57a296a6..bba524ae 100644 --- a/packages/backend/src/apps/twitter/info.json +++ b/packages/backend/src/apps/twitter/info.json @@ -222,9 +222,11 @@ "description": "Will be triggered when you tweet something new.", "subSteps": [ { + "key": "chooseAccount", "name": "Choose account" }, { + "key": "testStep", "name": "Test trigger" } ] @@ -235,9 +237,11 @@ "description": "Will be triggered when a specific user tweet something new.", "subSteps": [ { + "key": "chooseAccount", "name": "Choose account" }, { + "key": "chooseTrigger", "name": "Set up a trigger", "arguments": [ { @@ -249,6 +253,7 @@ ] }, { + "key": "testStep", "name": "Test trigger" } ] @@ -261,9 +266,11 @@ "description": "Will create a tweet.", "subSteps": [ { + "key": "chooseAccount", "name": "Choose account" }, { + "key": "chooseAction", "name": "Set up action", "arguments": [ { @@ -275,6 +282,7 @@ ] }, { + "key": "testStep", "name": "Test action" } ] diff --git a/packages/backend/src/graphql/types/action.ts b/packages/backend/src/graphql/types/action.ts index d2ad1630..f772118a 100644 --- a/packages/backend/src/graphql/types/action.ts +++ b/packages/backend/src/graphql/types/action.ts @@ -11,6 +11,7 @@ const actionType = new GraphQLObjectType({ new GraphQLObjectType({ name: 'ActionSubStep', fields: { + key: { type: GraphQLString }, name: { type: GraphQLString }, arguments: { type: GraphQLList( diff --git a/packages/backend/src/graphql/types/trigger.ts b/packages/backend/src/graphql/types/trigger.ts index aab59fee..1ddef940 100644 --- a/packages/backend/src/graphql/types/trigger.ts +++ b/packages/backend/src/graphql/types/trigger.ts @@ -11,6 +11,7 @@ const triggerType = new GraphQLObjectType({ new GraphQLObjectType({ name: 'TriggerSubStep', fields: { + key: { type: GraphQLString }, name: { type: GraphQLString }, arguments: { type: GraphQLList( diff --git a/packages/web/src/components/ChooseAppAndEventSubstep/index.tsx b/packages/web/src/components/ChooseAppAndEventSubstep/index.tsx index 0654e69e..1113c5b8 100644 --- a/packages/web/src/components/ChooseAppAndEventSubstep/index.tsx +++ b/packages/web/src/components/ChooseAppAndEventSubstep/index.tsx @@ -94,7 +94,7 @@ function ChooseAppAndEventSubstep(props: ChooseAppAndEventSubstepProps): React.R }); } } - }, [step, onChange]);; + }, [step, onChange]); const onToggle = expanded ? onCollapse : onExpand; diff --git a/packages/web/src/components/FlowStep/index.tsx b/packages/web/src/components/FlowStep/index.tsx index f5682b12..38a98fe7 100644 --- a/packages/web/src/components/FlowStep/index.tsx +++ b/packages/web/src/components/FlowStep/index.tsx @@ -8,7 +8,10 @@ import Collapse from '@mui/material/Collapse'; import List from '@mui/material/List'; import MoreHorizIcon from '@mui/icons-material/MoreHoriz'; import IconButton from '@mui/material/IconButton'; +import ErrorIcon from '@mui/icons-material/Error'; +import CheckCircleIcon from '@mui/icons-material/CheckCircle'; +import TestSubstep from 'components/TestSubstep'; import FlowSubstep from 'components/FlowSubstep'; import ChooseAppAndEventSubstep from 'components/ChooseAppAndEventSubstep'; import ChooseAccountSubstep from 'components/ChooseAccountSubstep'; @@ -20,7 +23,7 @@ import useFormatMessage from 'hooks/useFormatMessage'; import type { App, AppFields } from 'types/app'; import type { Step } from 'types/step'; import { StepType } from 'types/step'; -import { Content, Header, Wrapper } from './style'; +import { AppIconWrapper, AppIconStatusIconWrapper, Content, Header, Wrapper } from './style'; type FlowStepProps = { collapsed?: boolean; @@ -48,6 +51,9 @@ const parseStep = (step: Step) => { } }; +const validIcon = ; +const errorIcon = ; + export default function FlowStep(props: FlowStepProps): React.ReactElement | null { const { collapsed, index, onChange } = props; const contextButtonRef = React.useRef(null); @@ -86,11 +92,19 @@ export default function FlowStep(props: FlowStepProps): React.ReactElement | nul const toggleSubstep = (substepIndex: number) => setCurrentSubstep((value) => value !== substepIndex ? substepIndex : null); + const validationStatusIcon = step.status === 'completed' ? validIcon : errorIcon; + return (
- + + + + + {validationStatusIcon} + +
@@ -129,9 +143,9 @@ export default function FlowStep(props: FlowStepProps): React.ReactElement | nul />
- {substeps?.length > 0 && substeps.map((substep: { name: string, arguments: AppFields[] }, index: number) => ( + {substeps?.length > 0 && substeps.map((substep: { name: string, key: string, arguments: AppFields[] }, index: number) => ( - {substep.name === 'Choose account' && ( + {substep.key === 'chooseAccount' && ( )} - {substep.name !== 'Choose account' && ( + {substep.key === 'testStep' && ( + toggleSubstep((index + 1))} + onCollapse={() => toggleSubstep((index + 1))} + onSubmit={expandNextStep} + onChange={handleChange} + step={step} + /> + )} + + {['chooseAccount', 'testStep'].includes(substep.key) === false && ( - {substep.name !== 'Choose account' && ( - - {args?.map((argument) => ( - - ))} - - )} + + {args?.map((argument) => ( + + ))} + + + + + ); +}; + +export default TestSubstep; diff --git a/packages/web/src/graphql/mutations/execute-flow.ts b/packages/web/src/graphql/mutations/execute-flow.ts new file mode 100644 index 00000000..5c182c87 --- /dev/null +++ b/packages/web/src/graphql/mutations/execute-flow.ts @@ -0,0 +1,13 @@ +import { gql } from '@apollo/client'; + +export const EXECUTE_FLOW = gql` + mutation ExecuteFlow($stepId: String!) { + executeFlow(stepId: $stepId) { + step { + id + status + } + data + } + } +`; diff --git a/packages/web/src/graphql/queries/get-apps.ts b/packages/web/src/graphql/queries/get-apps.ts index 2ff427ab..cc7b7c91 100644 --- a/packages/web/src/graphql/queries/get-apps.ts +++ b/packages/web/src/graphql/queries/get-apps.ts @@ -54,6 +54,7 @@ export const GET_APPS = gql` key description subSteps { + key name arguments { label @@ -68,6 +69,7 @@ export const GET_APPS = gql` key description subSteps { + key name arguments { label diff --git a/packages/web/src/graphql/queries/get-flow.ts b/packages/web/src/graphql/queries/get-flow.ts index 2e11d172..f2e009f3 100644 --- a/packages/web/src/graphql/queries/get-flow.ts +++ b/packages/web/src/graphql/queries/get-flow.ts @@ -11,6 +11,7 @@ export const GET_FLOW = gql` type key appKey + status connection { id verified diff --git a/packages/web/src/types/step.ts b/packages/web/src/types/step.ts index bf29954d..4cb133f0 100644 --- a/packages/web/src/types/step.ts +++ b/packages/web/src/types/step.ts @@ -15,6 +15,7 @@ export type Step = { previousStepId: string | null; parameters: Record; connection: Pick; + status: 'completed' | 'incomplete'; }; export type Substep = {