Skip to content

Commit 80121f0

Browse files
committed
expand all json view
1 parent 11d7445 commit 80121f0

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

src/components/CodeView/JsonView.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import ReactJson from "@notdutzi/react-json-view"
2-
import { useDarkTheme } from "../../hooks/useTheme"
1+
import ReactJson from '@notdutzi/react-json-view'
2+
import { useDarkTheme } from '../../hooks/useTheme'
3+
import { useState } from 'react'
34

45
interface IJsonViewProps {
56
src: object
@@ -8,21 +9,28 @@ interface IJsonViewProps {
89

910
export const JsonView = (props: IJsonViewProps) => {
1011
const isDarkTheme = useDarkTheme()
12+
const [expandAll, setExpandAll] = useState<boolean>(false)
13+
14+
const handleClick = (e: React.MouseEvent) => {
15+
if (e.ctrlKey || e.metaKey) {
16+
setExpandAll(!expandAll)
17+
}
18+
}
1119

1220
return (
13-
<div className="p-4">
21+
<div className="p-4" onClick={handleClick}>
1422
<ReactJson
1523
name={null}
1624
src={props.src}
17-
theme={isDarkTheme ? "tomorrow" : "rjv-default"}
25+
theme={isDarkTheme ? 'tomorrow' : 'rjv-default'}
1826
style={{
1927
fontFamily:
2028
'Monaco, Menlo, Consolas, "Droid Sans Mono", "Inconsolata", "Courier New", monospace',
2129
}}
2230
enableClipboard={false}
2331
displayDataTypes={false}
2432
displayObjectSize={true}
25-
collapsed={props.collapsed || 2}
33+
collapsed={expandAll ? 99 : props.collapsed}
2634
/>
2735
</div>
2836
)

src/containers/NetworkPanel/NetworkDetails/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const NetworkDetails = (props: INetworkDetailsProps) => {
4040

4141
return (
4242
<Tabs
43+
key={data.id}
4344
testId="network-tabs"
4445
activeTab={activeTab}
4546
onTabClick={setActiveTab}

src/mocks/mock-requests.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ export const mockRequests: IMockRequest[] = [
333333
id
334334
title
335335
genre
336+
score
336337
}
337338
}
338339
`,
@@ -348,16 +349,19 @@ export const mockRequests: IMockRequest[] = [
348349
id: '1',
349350
title: 'Batman',
350351
genre: 'Action',
352+
score: 8.5,
351353
},
352354
{
353355
id: '2',
354356
title: 'American Psycho',
355357
genre: 'Thriller',
358+
score: 7.5,
356359
},
357360
{
358361
id: '3',
359362
title: 'The Godfather',
360363
genre: 'Drama',
364+
score: 0.0000007,
361365
},
362366
],
363367
},

0 commit comments

Comments
 (0)