diff --git a/packages/web/src/components/AppIcon/index.tsx b/packages/web/src/components/AppIcon/index.tsx index df5eb884..0d3e6d35 100644 --- a/packages/web/src/components/AppIcon/index.tsx +++ b/packages/web/src/components/AppIcon/index.tsx @@ -19,7 +19,7 @@ export default function AppIcon(props: AppIconProps & AvatarProps) { (null); const { flow } = props; return ( @@ -17,13 +18,20 @@ export default function Editor(props: EditorProps) { flex={1} flexDirection="column" alignItems="center" - width={800} - maxWidth="100%" alignSelf="center" py={3} gap={2} > - {flow?.steps?.map(step => ())} + {flow?.steps?.map((step, index) => ( + setCurrentStep(index)} + onClose={() => setCurrentStep(null)} + /> + ))} ) }; \ No newline at end of file diff --git a/packages/web/src/components/EditorLayout/index.tsx b/packages/web/src/components/EditorLayout/index.tsx index f1fd7ff4..35fdd1a0 100644 --- a/packages/web/src/components/EditorLayout/index.tsx +++ b/packages/web/src/components/EditorLayout/index.tsx @@ -9,6 +9,7 @@ import Switch from '@mui/material/Switch'; import IconButton from '@mui/material/IconButton'; import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew'; +import Container from 'components/Container'; import Editor from 'components/Editor'; import useFormatMessage from 'hooks/useFormatMessage'; import { GET_FLOW } from 'graphql/queries/get-flow'; @@ -33,7 +34,7 @@ export default function EditorLayout(props: EditorLayoutProps) { - + {flow?.name} @@ -49,11 +50,11 @@ export default function EditorLayout(props: EditorLayoutProps) { - + {!flow && 'not found'} {flow && } - + ) diff --git a/packages/web/src/components/FlowStep/index.tsx b/packages/web/src/components/FlowStep/index.tsx index cc2e5a2c..470a29b7 100644 --- a/packages/web/src/components/FlowStep/index.tsx +++ b/packages/web/src/components/FlowStep/index.tsx @@ -1,18 +1,58 @@ import * as React from 'react'; +import { useQuery } from '@apollo/client'; +import Stack from '@mui/material/Stack'; +import Typography from '@mui/material/Typography'; +import Button from '@mui/material/Button'; -import { Wrapper } from './style'; +import AppIcon from 'components/AppIcon'; +import { GET_APP } from 'graphql/queries/get-app'; +import useFormatMessage from 'hooks/useFormatMessage'; +import type { Step } from 'types/step'; +import { StepType } from 'types/step'; +import { Header, Wrapper } from './style'; type FlowStepProps = { - collapsed?: boolean; - step?: any; + collapsed?: boolean; + step: Step; + index?: number; + onOpen?: () => void; + onClose?: () => void; } export default function FlowStep(props: FlowStepProps) { - const { step } = props; + const { collapsed, index, step } = props; + const formatMessage = useFormatMessage(); + const { data } = useQuery(GET_APP, { variables: { key: step?.appKey }}) + const app = data?.getApp; + + if (!app) return null; + + const onOpen = () => collapsed && props.onOpen?.(); + const onClose = () => props.onClose?.(); return ( - - {step?.type} - {step?.appKey} - {step?.key} - {step?.connectionId} + +
+ + + +
+ + {step.type === StepType.Trigger ? formatMessage('flowStep.triggerType') : formatMessage('flowStep.actionType')} + + + + {index}. {app.name} + +
+
+
+ + {!collapsed && ( + + )}
) }; diff --git a/packages/web/src/components/FlowStep/style.ts b/packages/web/src/components/FlowStep/style.ts index 3b38e402..29b7172d 100644 --- a/packages/web/src/components/FlowStep/style.ts +++ b/packages/web/src/components/FlowStep/style.ts @@ -1,8 +1,16 @@ -import { styled } from '@mui/material/styles'; +import { styled, alpha } from '@mui/material/styles'; import Card from '@mui/material/Card'; export const Wrapper = styled(Card)` width: 100%; - padding: ${({ theme }) => theme.spacing(1, 2)}; `; +type HeaderProps = { + borderBottom?: boolean; +} + +export const Header = styled('div', { shouldForwardProp: prop => prop !== 'borderBottom' })` + border-bottom: 1px solid ${({ theme, borderBottom }) => borderBottom ? alpha(theme.palette.divider, .8) : 'transparent'}; + padding: ${({ theme }) => theme.spacing(2, 2)}; + cursor: ${({ borderBottom }) => borderBottom ? 'unset' : 'pointer'}; +`; \ No newline at end of file diff --git a/packages/web/src/graphql/queries/get-flow.ts b/packages/web/src/graphql/queries/get-flow.ts index 047525d9..669a9e2c 100644 --- a/packages/web/src/graphql/queries/get-flow.ts +++ b/packages/web/src/graphql/queries/get-flow.ts @@ -10,7 +10,9 @@ export const GET_FLOW = gql` type key appKey - connectionId + connection { + id + } } } } diff --git a/packages/web/src/locales/en.json b/packages/web/src/locales/en.json index 8f381649..6fc20bf1 100644 --- a/packages/web/src/locales/en.json +++ b/packages/web/src/locales/en.json @@ -32,5 +32,7 @@ "connection.addedAt": "added {datetime}", "createFlow.creating": "Creating a flow...", "flow.active": "Enabled", - "flow.inactive": "Disabled" + "flow.inactive": "Disabled", + "flowStep.triggerType": "Trigger", + "flowStep.actionType": "Action" } \ No newline at end of file diff --git a/packages/web/src/types/step.ts b/packages/web/src/types/step.ts index e31ae613..ab807a5e 100644 --- a/packages/web/src/types/step.ts +++ b/packages/web/src/types/step.ts @@ -1,7 +1,12 @@ +export enum StepType { + Trigger = 'trigger', + Action = 'action', +} + export type Step = { id: string; key: string; appKey: string; - type: 'trigger' | 'action'; + type: StepType; connectionId: number; };