|
1 | | -import prettyMs from "pretty-ms" |
2 | 1 | import { useMemo } from "react" |
3 | | -import { Link, useLocation } from "react-router" |
4 | | - |
5 | | -import { |
6 | | - Table, |
7 | | - Caption, |
8 | | - Tbody, |
9 | | - Td, |
10 | | - Th, |
11 | | - Thead, |
12 | | - Tr, |
13 | | -} from "@patternfly/react-table" |
14 | | - |
15 | | -import Result from "../Result" |
16 | | -import BreadcrumbBarForBlock from "../breadcrumbs/BreadcrumbBarForBlock" |
17 | | - |
18 | | -import { hasResult } from "../../helpers" |
| 2 | +//import { Link, useLocation } from "react-router" |
19 | 3 |
|
| 4 | +import Topology from "./Topology" |
20 | 5 | import extractVariables from "./model" |
21 | 6 |
|
22 | 7 | type Props = { |
23 | 8 | block: import("../../pdl_ast").PdlBlock |
24 | 9 | } |
25 | 10 |
|
26 | 11 | export default function Variables({ block }: Props) { |
27 | | - const { hash } = useLocation() |
28 | | - const vars = useMemo(() => extractVariables(block), [block]) |
29 | | - |
30 | | - return ( |
31 | | - <Table variant="compact" isStriped> |
32 | | - <Caption>This table shows the variable definitions and uses</Caption> |
33 | | - |
34 | | - <Thead> |
35 | | - <Tr> |
36 | | - <Th modifier="fitContent">Start Time</Th> |
37 | | - <Th modifier="fitContent">Location</Th> |
38 | | - {/*<Th modifier="fitContent">Name</Th>*/} |
39 | | - <Th modifier="fitContent">Where was this value defined?</Th> |
40 | | - <Th modifier="wrap">Value</Th> |
41 | | - </Tr> |
42 | | - </Thead> |
43 | | - |
44 | | - <Tbody> |
45 | | - {vars.map( |
46 | | - ({ incrNanos, block, name, value, defsite, defsiteId }, idx) => ( |
47 | | - <Tr |
48 | | - key={ |
49 | | - idx + |
50 | | - "." + |
51 | | - block.id + |
52 | | - ".use." + |
53 | | - name + |
54 | | - "." + |
55 | | - defsite?.id + |
56 | | - "." + |
57 | | - idx |
58 | | - } |
59 | | - > |
60 | | - <Td> |
61 | | - {idx === 0 ? ( |
62 | | - new Date((block.start_nanos || 0) / 1000000).toLocaleString() |
63 | | - ) : incrNanos === 0 ? ( |
64 | | - <>—</> |
65 | | - ) : ( |
66 | | - "+" + prettyMs(incrNanos / 1000000) |
67 | | - )} |
68 | | - </Td> |
69 | | - <Td> |
70 | | - <BreadcrumbBarForBlock block={block} /> |
71 | | - </Td> |
72 | | - {/*<Td>{name}</Td>*/} |
73 | | - <Td> |
74 | | - {defsite ? ( |
75 | | - <BreadcrumbBarForBlock block={defsite} /> |
76 | | - ) : defsiteId ? ( |
77 | | - <> |
78 | | - This is a use of a literal value defined{" "} |
79 | | - <Link |
80 | | - to={`?detail&type=block&id=${encodeURIComponent(defsiteId.replace(/\.\d+$/, ""))}${hash}`} |
81 | | - > |
82 | | - here |
83 | | - </Link> |
84 | | - . |
85 | | - </> |
86 | | - ) : ( |
87 | | - "This is a new definition" |
88 | | - )} |
89 | | - </Td> |
90 | | - <Td> |
91 | | - <Result |
92 | | - result={hasResult(value) ? value.result : value} |
93 | | - term="" |
94 | | - /> |
95 | | - </Td> |
96 | | - </Tr> |
97 | | - ), |
98 | | - )} |
99 | | - </Tbody> |
100 | | - </Table> |
101 | | - ) |
| 12 | + //const { hash } = useLocation() |
| 13 | + const { nodes, edges } = useMemo(() => extractVariables(block), [block]) |
| 14 | + return <Topology nodes={nodes} edges={edges} /> |
102 | 15 | } |
0 commit comments