Skip to content

Commit ff8f688

Browse files
authored
Graph based design (#5)
* Initial graph-based design with react-flow. * add scope resize * pan-on-scroll for touchpad panning * Use mouse pos for drag; do not drag out of scope. * Let getScopeAt see up-to-date nodes. * Do not set parent as dirty when a node moves. * calculate absolute pos for all ancestors when drop * sort nodes by level after scope-drop * fix node.positionAbsolute not found issue * add monaco editor to CodeNode * fix navigation-unsave-alert due to react-router-dom v6 * typo: add back update_intervalId * add execution output * remove debugging info on signin header
1 parent 456a35c commit ff8f688

File tree

21 files changed

+1444
-142
lines changed

21 files changed

+1444
-142
lines changed

api/prisma/schema.prisma

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,31 @@ model Repo {
6060

6161
enum PodType {
6262
CODE
63+
SCOPE
6364
DECK
6465
WYSIWYG
6566
MD
6667
REPL
6768
}
6869

70+
model Edge {
71+
// id String @id @default(uuid())
72+
from Pod @relation("FROM", fields: [fromId], references: [id])
73+
fromId String
74+
to Pod @relation("TO", fields: [toId], references: [id])
75+
toId String
76+
77+
@@id([fromId, toId])
78+
}
79+
6980
model Pod {
7081
id String @id @default(uuid())
7182
parent Pod? @relation("PARENT", fields: [parentId], references: [id])
7283
parentId String?
84+
x Float @default(0)
85+
y Float @default(0)
86+
width Float @default(0)
87+
height Float @default(0)
7388
index Int
7489
// TODO how to specify the order of children
7590
//
@@ -112,6 +127,8 @@ model Pod {
112127
113128
repoId String
114129
// this is just a place holder. Not useful
130+
to Edge[] @relation("TO")
131+
from Edge[] @relation("FROM")
115132
}
116133

117134
// model Deck {

api/src/resolver.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,17 @@ export const resolvers = {
367367
},
368368
data: {
369369
...input,
370+
parent:
371+
input.parent && input.parent !== "ROOT"
372+
? {
373+
connect: {
374+
id: input.parent,
375+
},
376+
}
377+
: undefined,
378+
children: {
379+
connect: input.children.map((id) => ({ id })),
380+
},
370381
},
371382
});
372383
console.log("Updated pod", pod);

api/src/typedefs.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ export const typeDefs = gql`
4242
thundar: Boolean
4343
utility: Boolean
4444
name: String
45+
x: Float
46+
y: Float
47+
width: Float
48+
height: Float
4549
}
4650
4751
input PodInput {
@@ -61,6 +65,12 @@ export const typeDefs = gql`
6165
thundar: Boolean
6266
utility: Boolean
6367
name: String
68+
x: Float
69+
y: Float
70+
width: Float
71+
height: Float
72+
parent: ID
73+
children: [ID]
6474
}
6575
6676
type Query {

ui/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@
4040
"react": "^18.2.0",
4141
"react-app-rewired": "^2.1.8",
4242
"react-dom": "^18.2.0",
43+
"react-flow-renderer": "^10.3.17",
4344
"react-icons": "^4.2.0",
4445
"react-monaco-editor": "^0.50.1",
46+
"react-moveable": "^0.39.2",
4547
"react-redux": "^8.0.2",
4648
"react-router-dom": "^6.4.0",
4749
"react-scripts": "5.0.1",
@@ -52,7 +54,6 @@
5254
"socket.io-client": "^4.1.3",
5355
"stompjs": "^2.3.3",
5456
"strip-ansi": "^7.0.0",
55-
"use-resize-observer": "^9.0.2",
5657
"web-vitals": "^3.0.1",
5758
"xterm": "^4.13.0",
5859
"xterm-addon-fit": "^0.5.0"

ui/src/components/Header.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,6 @@ export function Header() {
160160
</Button>
161161
</Box>
162162

163-
{isSignedIn() ? "yes" : "no"}
164163
{isSignedIn() ? (
165164
<Box sx={{ flexGrow: 0 }}>
166165
<Tooltip title="Open settings">

ui/src/components/MyMonaco.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ export function MyMonaco({
416416
autoIndent: "full",
417417
// autoIndent: true,
418418
overviewRulerLanes: 0,
419+
automaticLayout: true,
419420
scrollbar: {
420421
alwaysConsumeMouseWheel: false,
421422
vertical: "hidden",

ui/src/components/repo/edges.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default [
2+
{ id: "e1-2", source: "1", target: "2", animated: true },
3+
{ id: "e1-3", source: "1", target: "3" },
4+
{ id: "e2a-4a", source: "2a", target: "4a" },
5+
{ id: "e3-4", source: "3", target: "4" },
6+
{ id: "e3-4b", source: "3", target: "4b" },
7+
{ id: "e4a-4b1", source: "4a", target: "4b1" },
8+
{ id: "e4a-4b2", source: "4a", target: "4b2" },
9+
{ id: "e4b1-4b2", source: "4b1", target: "4b2" },
10+
];

0 commit comments

Comments
 (0)