@@ -7,6 +7,14 @@ import CardHeader from '@material-ui/core/CardHeader'
7
7
import TableCell from '@material-ui/core/TableCell'
8
8
import TableRow from '@material-ui/core/TableRow'
9
9
import Grid from '@material-ui/core/Grid'
10
+ import ExpansionPanel from '@material-ui/core/ExpansionPanel'
11
+ import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary'
12
+ import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails'
13
+
14
+ import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'
15
+ import { prism } from 'react-syntax-highlighter/dist/esm/styles/prism'
16
+ import ExpandMoreIcon from '@material-ui/icons/ExpandMore'
17
+ import Typography from '@material-ui/core/Typography'
10
18
11
19
export const CONFIG_V2_QUERY = gql `
12
20
query FetchConfigV2 {
@@ -24,25 +32,46 @@ export const ConfigurationV2Card = () => {
24
32
fetchPolicy : 'cache-and-network' ,
25
33
} )
26
34
35
+ if ( data ?. configv2 . effective == 'N/A' ) {
36
+ return (
37
+ < >
38
+ < Grid item xs = { 12 } >
39
+ < Card >
40
+ < CardHeader title = "TOML Configuration" />
41
+ < TOMLPanel
42
+ title = "V2 config dump:"
43
+ error = { error ?. message }
44
+ loading = { loading }
45
+ toml = { data ?. configv2 . user }
46
+ showHead
47
+ />
48
+ </ Card >
49
+ </ Grid >
50
+ </ >
51
+ )
52
+ }
53
+
27
54
return (
28
55
< >
29
56
< Grid item xs = { 12 } >
30
- < TOMLCard
31
- title = "TOML Configuration (user-specified)"
32
- error = { error ?. message }
33
- loading = { loading }
34
- toml = { data ?. configv2 . user }
35
- showHead
36
- />
37
- </ Grid >
38
- < Grid item xs = { 12 } >
39
- < TOMLCard
40
- title = "TOML Configuration (effective)"
41
- error = { error ?. message }
42
- loading = { loading }
43
- toml = { data ?. configv2 . effective }
44
- showHead
45
- />
57
+ < Card >
58
+ < CardHeader title = "TOML Configuration" />
59
+ < TOMLPanel
60
+ title = "User specified:"
61
+ error = { error ?. message }
62
+ loading = { loading }
63
+ toml = { data ?. configv2 . user }
64
+ showHead
65
+ expanded = { true }
66
+ />
67
+ < TOMLPanel
68
+ title = "Effective (with defaults):"
69
+ error = { error ?. message }
70
+ loading = { loading }
71
+ toml = { data ?. configv2 . effective }
72
+ showHead
73
+ />
74
+ </ Card >
46
75
</ Grid >
47
76
</ >
48
77
)
@@ -54,6 +83,7 @@ interface Props {
54
83
showHead ?: boolean
55
84
title ?: string
56
85
error ?: string
86
+ expanded ?: boolean
57
87
}
58
88
59
89
const SpanRow : React . FC = ( { children } ) => (
@@ -68,7 +98,7 @@ const FetchingRow = () => <SpanRow>...</SpanRow>
68
98
69
99
const ErrorRow : React . FC = ( { children } ) => < SpanRow > { children } </ SpanRow >
70
100
71
- const TOMLCard = ( { loading, toml, error = '' , title } : Props ) => {
101
+ const TOMLPanel = ( { loading, toml, error = '' , title, expanded } : Props ) => {
72
102
if ( error ) {
73
103
return < ErrorRow > { error } </ ErrorRow >
74
104
}
@@ -77,14 +107,24 @@ const TOMLCard = ({ loading, toml, error = '', title }: Props) => {
77
107
return < FetchingRow />
78
108
}
79
109
80
- let styles = { marginLeft : '1em' } ;
110
+ if ( ! title ) {
111
+ title = 'TOML'
112
+ }
113
+
114
+ const styles = { display : 'block' }
81
115
82
116
return (
83
- < Card >
84
- { title && < CardHeader title = { title } /> }
85
- < pre style = { styles } >
86
- < code > { toml } </ code >
87
- </ pre >
88
- </ Card >
117
+ < Typography >
118
+ < ExpansionPanel defaultExpanded = { expanded } >
119
+ < ExpansionPanelSummary expandIcon = { < ExpandMoreIcon /> } >
120
+ { title }
121
+ </ ExpansionPanelSummary >
122
+ < ExpansionPanelDetails style = { styles } >
123
+ < SyntaxHighlighter language = "toml" style = { prism } >
124
+ { toml }
125
+ </ SyntaxHighlighter >
126
+ </ ExpansionPanelDetails >
127
+ </ ExpansionPanel >
128
+ </ Typography >
89
129
)
90
130
}
0 commit comments