Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit 87dad7e

Browse files
committed
feat: start of refactor
1 parent 91fdd52 commit 87dad7e

13 files changed

Lines changed: 5094 additions & 30 deletions

File tree

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v16.15.1
1+
v18.12.0

package.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,14 @@
2222
"react-aria": "3.19.0",
2323
"react-beautiful-dnd": "^13.1.0",
2424
"react-dom": "^18.2.0",
25-
"react-flow-renderer": "11.1.0",
2625
"react-instantsearch-hooks-web": "^6.29.0",
2726
"react-redux": "^7.2.6",
27+
"reactflow": "11.0.0",
2828
"start-server-and-test": "^1.14.0",
2929
"uuid": "^8.3.2"
3030
},
3131
"devDependencies": {
3232
"@reduxjs/toolkit": "^1.6.2",
33-
"@testing-library/jest-dom": "^5.11.4",
34-
"@testing-library/react": "^12.1.2",
35-
"@testing-library/user-event": "^13.5.0",
3633
"@types/algoliasearch": "^4.0.0",
3734
"@types/jest": "^27.0.2",
3835
"@types/node": "^16.11.35",
@@ -41,7 +38,6 @@
4138
"@types/react-dom": "^18.0.6",
4239
"@types/react-tabs": "^2.3.3",
4340
"@types/uuid": "^8.3.1",
44-
"@vitejs/plugin-react": "^2.1.0",
4541
"autoprefixer": "^10.4.12",
4642
"cypress": "^10.11.0",
4743
"eslint-plugin-react-hooks": "^4.3.0",

src/App.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Toast from './components/atoms/Toast';
55
import ToolTip from './components/atoms/Tooltip';
66
import ConfirmationModal from './components/containers/ConfirmationModal';
77
import KBarList from './components/containers/KBarList';
8+
import { FlowProvided } from './components/flow/Flow';
89
import EditorPane from './components/panes/EditorPane';
910
import NavigationPane from './components/panes/NavigationPane';
1011
import WorkflowsPane from './components/panes/WorkflowsPane';

src/components/atoms/Edge.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { EdgeProps } from 'react-flow-renderer';
2+
// import { EdgeProps } from 'react-flow-renderer';
33

44
// export default function Edge({
55
// id,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Button } from "../atoms/Button"
2+
import PreviewToolbox from "./PreviewToolbox"
3+
4+
const FlowTools = () => {
5+
return (<div className="mr-2 px-4 flex flex-row border-r border-r-circle-gray-300">
6+
<Button variant="secondary" className="mr-0 rounded-r-none">Connect</Button>
7+
<Button variant="secondary" className="ml-0 rounded-l-none">Move</Button>
8+
<PreviewToolbox />
9+
</div>)
10+
}
11+
12+
export { FlowTools }

src/components/containers/HeaderMenu.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { Button } from '../atoms/Button';
12
import { ExternalLinks } from './ExternalLinks';
3+
import { FlowTools } from './FlowTools';
24
import PreviewToolbox from './PreviewToolbox';
35

46
export default function HeaderMenu() {
57
return (
6-
<div className="ml-auto flex my-auto flex-row p-4 space-x-2">
7-
<PreviewToolbox />
8+
<div className="ml-auto flex my-auto flex-row space-x-2">
9+
<FlowTools />
810
<ExternalLinks />
911
</div>
1012
);

src/components/flow/Flow.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,41 @@
1-
import ReactFlow, { Background, BackgroundVariant, Controls, MiniMap, ReactFlowProvider, useReactFlow } from "react-flow-renderer";
1+
import ReactFlow, { Background, BackgroundVariant, ControlButton, Controls, MiniMap, ReactFlowProvider, useReactFlow } from "reactflow";
22
import { useStoreState } from "../../state/Hooks";
33

44
export type FlowProps = { className?: string }
55

66
const Flow = (props: FlowProps) => {
7-
const reactFlowInstance = useReactFlow();
7+
// const reactFlowInstance = useReactFlow();
88
const dragging = useStoreState((state) => state.dragging);
99

10-
return <ReactFlow
10+
return <ReactFlow
11+
minZoom={-Infinity}
12+
fitView
13+
// nodes={nodes}
14+
// edges={edges as Edge[]}
15+
// onNodeClick={handleNodeClick}
1116
className={props.className}
1217
onDragOver={(e) => {
1318
if (dragging?.dataType?.dragTarget === 'workflow') {
1419
e.preventDefault();
1520
}
16-
}}>
21+
}}
22+
onInit={(reactFlowInstance) => console.log('flow loaded:', reactFlowInstance)}
23+
>
1724
<Background
18-
variant={BackgroundVariant.Dots}
1925
gap={15}
2026
color="#c7c7c7"
2127
className="bg-circle-gray-200"
22-
size={1}
28+
size={2}
2329
/>
24-
<Controls />
25-
<MiniMap className="w-32 h-24" />
30+
<Controls>
31+
</Controls>
2632
</ReactFlow>
2733
}
2834

29-
const FlowProvided = (props: FlowProps) => {
35+
const GraphWrapper = (props: FlowProps) => {
3036
return <ReactFlowProvider>
3137
<Flow {...props} />
3238
</ReactFlowProvider>
3339
}
3440

35-
export { FlowProvided, Flow };
41+
export { GraphWrapper, Flow };

src/components/panes/WorkflowsPane.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Logo from '../../icons/ui/Logo';
22
import HeaderMenu from '../containers/HeaderMenu';
33
// import WorkflowContainer from '../containers/WorkflowContainer';
4-
import { FlowProvided } from '../flow/Flow';
4+
import { GraphWrapper } from '../flow/Flow';
5+
import ReactFlow, { Background, BackgroundVariant, ControlButton, Controls } from 'reactflow';
56

67
const WorkflowsPane = () => {
78
return (
@@ -10,20 +11,18 @@ const WorkflowsPane = () => {
1011
className="flex flex-col flex-nowrap flex-1"
1112
id="Workflows-Pane"
1213
>
13-
<header className="flex w-full bg-white h-16">
14-
<div className="p-2 flex flex-row my-auto w-full">
14+
<header className="flex w-full bg-white p-4">
15+
<div className="flex flex-row my-auto w-full">
1516
<div className="my-auto flex flex-row">
1617
<Logo className="mx-2" />
1718
<h1 className="text-xl font-bold">Visual Config Editor</h1>
1819
</div>
1920
</div>
2021
<HeaderMenu />
2122
</header>
22-
{/* <WorkflowContainer
23-
bgClassName="bg-circle-gray-200"
24-
className="border border-r-0 h-full border-b-0 border-circle-gray-300"
25-
/> */}
26-
<FlowProvided className="border border-r-0 h-full border-b-0 border-circle-gray-300"></FlowProvided>
23+
<GraphWrapper className="z-10 border border-r-0 h-full border-b-0 border-circle-gray-300"></GraphWrapper>
24+
25+
2726
</div>
2827
);
2928
};

src/main.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from 'react'
22
import ReactDOM from 'react-dom/client'
33
import App from './App'
44
import './index.css'
5+
import 'reactflow/dist/style.css';
56

67
ReactDOM.createRoot(document.getElementById('root') as HTMLElement).render(
78
<React.StrictMode>

src/mappings/InspectableMapping.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Generable } from '@circleci/circleci-config-sdk/dist/src/lib/Components';
22
import { FormikValues } from 'formik';
3-
import { Edge, NodeProps } from 'react-flow-renderer';
3+
import { Edge, NodeProps } from 'reactflow';
44
import { IconProps } from '../icons/IconProps';
55
import {
66
DefinitionsModel,

0 commit comments

Comments
 (0)