|
1
|
--- |
|
2
|
sidebar_label: "JSON View Section" |
|
3
|
--- |
|
4
|
|
|
5
|
import { TypeList } from "docs-ui" |
|
6
|
|
|
7
|
export const metadata = { |
|
8
|
title: `JsonViewSection - Admin Components`, |
|
9
|
} |
|
10
|
|
|
11
|
# {metadata.title} |
|
12
|
|
|
13
|
<Note> |
|
14
|
|
|
15
|
This component is available since Medusa [v2.21.0](https://github.com/medusajs/medusa/releases/tag/v2.21.0). |
|
16
|
|
|
17
|
</Note> |
|
18
|
|
|
19
|
The `JsonViewSection` component shows a section with the number of keys in an object, and a button that opens a drawer with the object's formatted JSON. The Medusa Admin shows this section at the bottom of its detail pages. |
|
20
|
|
|
21
|
```tsx |
|
22
|
import { JsonViewSection } from "@medusajs/dashboard/components" |
|
23
|
``` |
|
24
|
|
|
25
|
--- |
|
26
|
|
|
27
|
## Example |
|
28
|
|
|
29
|
Use `JsonViewSection` in a [widget](!docs!/learn/fundamentals/admin/widgets) or [UI route](!docs!/learn/fundamentals/admin/ui-routes) to let the user inspect a record's raw data: |
|
30
|
|
|
31
|
```tsx |
|
32
|
import { |
|
33
|
JsonViewSection, |
|
34
|
} from "@medusajs/dashboard/components" |
|
35
|
|
|
36
|
const BrandJsonSection = ({ brand }) => { |
|
37
|
return <JsonViewSection data={brand} /> |
|
38
|
} |
|
39
|
``` |
|
40
|
|
|
41
|
In the drawer, Medusa collapses nested objects beyond the first level, and the user can click the copy icon next to a value to copy it to the clipboard. |
|
42
|
|
|
43
|
--- |
|
44
|
|
|
45
|
## Props |
|
46
|
|
|
47
|
The component accepts the `JsonViewSectionProps` type: |
|
48
|
|
|
49
|
<TypeList |
|
50
|
types={[ |
|
51
|
{ |
|
52
|
name: "data", |
|
53
|
type: "`object`", |
|
54
|
optional: false, |
|
55
|
description: |
|
56
|
"The object to show in JSON format. Its keys and values depend on the record you pass.", |
|
57
|
}, |
|
58
|
{ |
|
59
|
name: "title", |
|
60
|
type: "`string`", |
|
61
|
optional: true, |
|
62
|
description: |
|
63
|
"An optional title. The component accepts it, but it doesn't render it. Medusa always shows its own JSON heading instead.", |
|
64
|
}, |
|
65
|
]} |
|
66
|
/> |