MCPcopy Index your code
hub / github.com/triggerdotdev/jsonhero-web / ContainerInfo

Function ContainerInfo

app/components/ContainerInfo.tsx:15–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13];
14
15export function ContainerInfo() {
16 const { selectedNodeId, highlightedNodeId } = useJsonColumnViewState();
17
18 if (!selectedNodeId || !highlightedNodeId) {
19 return <></>;
20 }
21
22 const [json] = useJson();
23
24 const selectedHeroPath = new JSONHeroPath(selectedNodeId);
25 const selectedJson = selectedHeroPath.first(json);
26 const selectedInfo = inferType(selectedJson);
27
28 const isSelectedLeafNode =
29 selectedInfo.name !== "object" && selectedInfo.name !== "array";
30
31 const highlightedHeroPath = new JSONHeroPath(highlightedNodeId);
32 const highlightedJson = highlightedHeroPath.first(json);
33 const highlightedInfo = inferType(highlightedJson);
34
35 const isHighlightedLeafNode =
36 highlightedInfo.name !== "object" && highlightedInfo.name !== "array";
37
38 const shouldHighlightInPreview =
39 selectedNodeId !== highlightedNodeId && !isHighlightedLeafNode;
40
41 const shouldDisplayCodePreview =
42 shouldHighlightInPreview || !isSelectedLeafNode;
43
44 if (!shouldDisplayCodePreview) {
45 return <></>;
46 }
47
48 return (
49 <Tabs tabs={tabs}>
50 <>
51 <TabContent value="json">
52 {shouldHighlightInPreview ? (
53 <JsonPreview
54 json={highlightedJson}
55 highlightPath={pathToDescendant(
56 highlightedNodeId,
57 selectedNodeId
58 )}
59 />
60 ) : (
61 <JsonPreview json={selectedJson} />
62 )}
63 </TabContent>
64 <TabContent value="schema">
65 {shouldHighlightInPreview ? (
66 <JsonSchemaViewer path={highlightedNodeId} />
67 ) : (
68 <JsonSchemaViewer path={selectedNodeId} />
69 )}
70 </TabContent>
71 </>
72 </Tabs>

Callers

nothing calls this directly

Calls 3

useJsonColumnViewStateFunction · 0.90
useJsonFunction · 0.90
pathToDescendantFunction · 0.90

Tested by

no test coverage detected