This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6058 from trufflesuite/visual-debug
New feature: Visual debugger for Truffle Dashboard
- Loading branch information
Showing
56 changed files
with
3,203 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
packages/dashboard/src/components/composed/Debugger/Breakpoints/Breakpoint.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import type { BreakpointType } from "src/components/composed/Debugger/utils"; | ||
import { createStyles } from "@mantine/core"; | ||
|
||
const useStyles = createStyles(() => ({ | ||
breakpointGroup: { | ||
display: "flex", | ||
marginBottom: 5 | ||
}, | ||
breakpointDelete: { | ||
"&:hover": { | ||
cursor: "pointer" | ||
}, | ||
"borderRadius": 8, | ||
"backgroundColor": "#FA5252", | ||
"width": 16, | ||
"height": 16, | ||
"marginRight": 16 | ||
}, | ||
breakpoint: { | ||
"&:hover": { | ||
cursor: "pointer" | ||
} | ||
} | ||
})); | ||
|
||
type BreakpointProps = { | ||
sourceName: string; | ||
line: number; | ||
sourceId: string; | ||
handleBreakpointComponentClick: (arg: BreakpointType) => void; | ||
handleBreakpointDeleteClick: (arg: BreakpointType) => void; | ||
}; | ||
|
||
function Breakpoint({ | ||
sourceName, | ||
line, | ||
sourceId, | ||
handleBreakpointComponentClick, | ||
handleBreakpointDeleteClick | ||
}: BreakpointProps): JSX.Element | null { | ||
const { classes } = useStyles(); | ||
return ( | ||
<div className={classes.breakpointGroup}> | ||
<div | ||
className={classes.breakpointDelete} | ||
onClick={() => | ||
handleBreakpointDeleteClick({ | ||
sourceId, | ||
line | ||
}) | ||
} | ||
></div> | ||
<div | ||
className={classes.breakpoint} | ||
onClick={() => | ||
handleBreakpointComponentClick({ | ||
sourceId, | ||
line | ||
}) | ||
} | ||
> | ||
{sourceName} - line {line} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Breakpoint; |
100 changes: 100 additions & 0 deletions
100
packages/dashboard/src/components/composed/Debugger/Breakpoints/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { Source } from "src/components/composed/Debugger/utils"; | ||
import { useDash } from "src/hooks"; | ||
import * as path from "path"; | ||
import { BreakpointType } from "src/components/composed/Debugger/utils"; | ||
import Breakpoint from "src/components/composed/Debugger/Breakpoints/Breakpoint"; | ||
import { Flex, createStyles } from "@mantine/core"; | ||
|
||
const useStyles = createStyles(theme => ({ | ||
breakpointsContainer: { | ||
overflow: "hidden", | ||
height: "30%", | ||
borderWidth: 1, | ||
borderStyle: "solid", | ||
borderRadius: 4, | ||
marginBottom: 20, | ||
borderColor: | ||
theme.colorScheme === "dark" | ||
? theme.colors["truffle-brown"][5] | ||
: `${theme.colors["truffle-beige"][5]}73` | ||
}, | ||
sectionHeader: { | ||
height: 42, | ||
fontSize: 16, | ||
paddingTop: 10, | ||
paddingLeft: 16, | ||
backgroundColor: | ||
theme.colorScheme === "dark" | ||
? `${theme.colors["truffle-beige"][8]}33` | ||
: theme.colors["truffle-beige"][2], | ||
borderBottom: "1px solid", | ||
borderColor: | ||
theme.colorScheme === "dark" | ||
? theme.colors["truffle-brown"][5] | ||
: `${theme.colors["truffle-beige"][5]}73` | ||
}, | ||
breakpoints: { | ||
overflow: "scroll", | ||
height: "100%", | ||
backgroundColor: | ||
theme.colorScheme === "dark" ? theme.colors["truffle-brown"][8] : "white" | ||
}, | ||
breakpointsContent: { | ||
paddingLeft: 10 | ||
} | ||
})); | ||
|
||
type BreakpointsArgs = { | ||
sources: Source[]; | ||
handleBreakpointComponentClick: (breakpoint: BreakpointType) => void; | ||
handleBreakpointDeleteClick: (breakpoint: BreakpointType) => void; | ||
}; | ||
|
||
function Breakpoints({ | ||
sources, | ||
handleBreakpointComponentClick, | ||
handleBreakpointDeleteClick | ||
}: BreakpointsArgs): JSX.Element | null { | ||
const { classes } = useStyles(); | ||
const { | ||
state: { | ||
debugger: { breakpoints } | ||
} | ||
} = useDash()!; | ||
const breakpointsList: JSX.Element[] = []; | ||
for (const source of sources) { | ||
if ( | ||
breakpoints[source.id] === undefined || | ||
breakpoints[source.id].size === 0 | ||
) { | ||
continue; | ||
} | ||
if (!source?.sourcePath) { | ||
continue; | ||
} | ||
const iterator = breakpoints[source.id].values(); | ||
const sourceName = path.basename(source.sourcePath); | ||
for (const line of iterator) { | ||
breakpointsList.push( | ||
<Breakpoint | ||
key={`${source.id}${line.toString()}`} | ||
sourceName={sourceName} | ||
line={line} | ||
sourceId={source.id} | ||
handleBreakpointComponentClick={handleBreakpointComponentClick} | ||
handleBreakpointDeleteClick={handleBreakpointDeleteClick} | ||
/> | ||
); | ||
} | ||
} | ||
return ( | ||
<Flex direction="column" className={classes.breakpointsContainer}> | ||
<div className={classes.sectionHeader}>Breakpoints</div> | ||
<div className={classes.breakpoints}> | ||
<pre className={classes.breakpointsContent}>{breakpointsList}</pre> | ||
</div> | ||
</Flex> | ||
); | ||
} | ||
|
||
export default Breakpoints; |
Oops, something went wrong.