diff --git a/packages/web/src/components/Editor/index.tsx b/packages/web/src/components/Editor/index.tsx new file mode 100644 index 00000000..62980db1 --- /dev/null +++ b/packages/web/src/components/Editor/index.tsx @@ -0,0 +1,29 @@ +import * as React from 'react'; +import Box from '@mui/material/Box'; + +import FlowStep from 'components/FlowStep'; +import type { Flow } from 'types/flow'; + +type EditorProps = { + flow?: Flow; +} + +export default function Editor(props: EditorProps) { + const { flow } = props; + + return ( + + {flow?.steps?.map(step => ())} + + ) +}; \ No newline at end of file diff --git a/packages/web/src/components/EditorLayout/index.tsx b/packages/web/src/components/EditorLayout/index.tsx new file mode 100644 index 00000000..f1fd7ff4 --- /dev/null +++ b/packages/web/src/components/EditorLayout/index.tsx @@ -0,0 +1,60 @@ +import * as React from 'react'; +import { useParams } from 'react-router-dom'; +import { useQuery } from '@apollo/client'; +import Stack from '@mui/material/Stack'; +import Box from '@mui/material/Box'; +import Typography from '@mui/material/Typography'; +import FormControlLabel from '@mui/material/FormControlLabel'; +import Switch from '@mui/material/Switch'; +import IconButton from '@mui/material/IconButton'; +import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew'; + +import Editor from 'components/Editor'; +import useFormatMessage from 'hooks/useFormatMessage'; +import { GET_FLOW } from 'graphql/queries/get-flow'; +import type { Flow } from 'types/flow'; + +type EditorLayoutProps = { + children?: React.ReactNode; +} + +export default function EditorLayout(props: EditorLayoutProps) { + const { flowId } = useParams(); + const formatMessage = useFormatMessage(); + const { data } = useQuery(GET_FLOW, { variables: { id: flowId }}); + const flow: Flow = data?.getFlow; + + return ( + <> + + + + + + + + + {flow?.name} + + + + + + } + label={formatMessage('flow.inactive')} + labelPlacement="start" + /> + + + + + {!flow && 'not found'} + + {flow && } + + + + ) +} \ No newline at end of file diff --git a/packages/web/src/components/FlowStep/index.tsx b/packages/web/src/components/FlowStep/index.tsx new file mode 100644 index 00000000..cc2e5a2c --- /dev/null +++ b/packages/web/src/components/FlowStep/index.tsx @@ -0,0 +1,18 @@ +import * as React from 'react'; + +import { Wrapper } from './style'; + +type FlowStepProps = { + collapsed?: boolean; + step?: any; +} + +export default function FlowStep(props: FlowStepProps) { + const { step } = props; + + return ( + + {step?.type} - {step?.appKey} - {step?.key} - {step?.connectionId} + + ) +}; diff --git a/packages/web/src/components/FlowStep/style.ts b/packages/web/src/components/FlowStep/style.ts new file mode 100644 index 00000000..3b38e402 --- /dev/null +++ b/packages/web/src/components/FlowStep/style.ts @@ -0,0 +1,8 @@ +import { styled } from '@mui/material/styles'; +import Card from '@mui/material/Card'; + +export const Wrapper = styled(Card)` + width: 100%; + padding: ${({ theme }) => theme.spacing(1, 2)}; +`; + diff --git a/packages/web/src/config/urls.ts b/packages/web/src/config/urls.ts index 1aedfebc..b17322ac 100644 --- a/packages/web/src/config/urls.ts +++ b/packages/web/src/config/urls.ts @@ -16,5 +16,6 @@ export const APP_FLOWS = (appKey: string) => `/app/${appKey}/flows`; export const APP_FLOWS_PATTERN = '/app/:appKey/flows'; export const NEW_APP_CONNECTION = '/apps/new'; export const CREATE_FLOW = '/editor/create'; -export const FLOW = (flowKey: string) => `/flows/${flowKey}`; -export const FLOW_PATTERN = '/flows/:flowKey'; +export const FLOW_EDITOR = (flowId: string) => `/editor/${flowId}`; +export const FLOW = (flowId: string) => `/flows/${flowId}`; +export const FLOW_PATTERN = '/flows/:flowId'; diff --git a/packages/web/src/graphql/queries/get-flow.ts b/packages/web/src/graphql/queries/get-flow.ts new file mode 100644 index 00000000..1d1714cb --- /dev/null +++ b/packages/web/src/graphql/queries/get-flow.ts @@ -0,0 +1,17 @@ +import { gql } from '@apollo/client'; + +export const GET_FLOW = gql` + query GetFlow($id: String!) { + getFlow(id: $id) { + id + name + steps { + id + type + key + appKey + connectionId + } + } + } +`; \ No newline at end of file diff --git a/packages/web/src/locales/en.json b/packages/web/src/locales/en.json index ff5cbde2..8f381649 100644 --- a/packages/web/src/locales/en.json +++ b/packages/web/src/locales/en.json @@ -30,5 +30,7 @@ "connection.delete": "Delete", "connection.deletedMessage": "The connection has been deleted.", "connection.addedAt": "added {datetime}", - "createFlow.creating": "Creating a flow..." + "createFlow.creating": "Creating a flow...", + "flow.active": "Enabled", + "flow.inactive": "Disabled" } \ No newline at end of file diff --git a/packages/web/src/pages/Editor/create.tsx b/packages/web/src/pages/Editor/create.tsx index 4ffc6284..6255e031 100644 --- a/packages/web/src/pages/Editor/create.tsx +++ b/packages/web/src/pages/Editor/create.tsx @@ -21,7 +21,7 @@ export default function CreateFlow() { const flowId = response.data?.createFlow?.id; setTimeout(() => { - navigate(URLS.FLOW(flowId)); + navigate(URLS.FLOW_EDITOR(flowId)); }, 1234); } diff --git a/packages/web/src/pages/Editor/index.tsx b/packages/web/src/pages/Editor/index.tsx index 0986d8d1..badb8b4e 100644 --- a/packages/web/src/pages/Editor/index.tsx +++ b/packages/web/src/pages/Editor/index.tsx @@ -1,11 +1,7 @@ -import * as React from 'react'; -import { Routes, Route } from 'react-router-dom'; -import CreateFlowPage from './create'; +import EditorLayout from 'components/EditorLayout'; -export default function Editor() { +export default function FlowEditor() { return ( - - } /> - + ) -} +} \ No newline at end of file diff --git a/packages/web/src/pages/Editor/routes.tsx b/packages/web/src/pages/Editor/routes.tsx new file mode 100644 index 00000000..c7df3f88 --- /dev/null +++ b/packages/web/src/pages/Editor/routes.tsx @@ -0,0 +1,14 @@ +import * as React from 'react'; +import { Routes, Route } from 'react-router-dom'; +import CreateFlowPage from './create'; +import EditorPage from './index'; + +export default function EditorRoutes() { + return ( + + } /> + + } /> + + ) +} diff --git a/packages/web/src/routes.tsx b/packages/web/src/routes.tsx index 8fd9bf1b..0652f454 100644 --- a/packages/web/src/routes.tsx +++ b/packages/web/src/routes.tsx @@ -4,7 +4,7 @@ import Applications from 'pages/Applications'; import Application from 'pages/Application'; import Flows from 'pages/Flows'; import Explore from 'pages/Explore'; -import Editor from 'pages/Editor'; +import EditorRoutes from 'pages/Editor/routes'; import * as URLS from 'config/urls'; export default ( @@ -17,7 +17,7 @@ export default ( } /> - } /> + } /> } /> diff --git a/packages/web/src/styles/theme.ts b/packages/web/src/styles/theme.ts index be2a51c1..412232b6 100644 --- a/packages/web/src/styles/theme.ts +++ b/packages/web/src/styles/theme.ts @@ -229,6 +229,9 @@ const extendedTheme = createTheme({ a: { textDecoration: 'none', }, + '#root': { + height: '100vh' + } }, }, MuiDialog: { diff --git a/packages/web/src/types/flow.ts b/packages/web/src/types/flow.ts index 9f9fb32d..a42ad5da 100644 --- a/packages/web/src/types/flow.ts +++ b/packages/web/src/types/flow.ts @@ -1,4 +1,7 @@ +import type { Step } from './step'; + export type Flow = { id: string; name: string; + steps: Step[]; }; diff --git a/packages/web/src/types/step.ts b/packages/web/src/types/step.ts new file mode 100644 index 00000000..e31ae613 --- /dev/null +++ b/packages/web/src/types/step.ts @@ -0,0 +1,7 @@ +export type Step = { + id: string; + key: string; + appKey: string; + type: 'trigger' | 'action'; + connectionId: number; +};