Skip to content

Commit 9e266e6

Browse files
authored
Merge pull request #13 from smartcontractkit/feature/sc-33623-2
ConfigurationV2Card: swap out toml table for code block
2 parents e1e224e + 9b4b952 commit 9e266e6

File tree

1 file changed

+9
-32
lines changed

1 file changed

+9
-32
lines changed

src/screens/Configuration/ConfigurationV2Card/ConfigurationV2Card.tsx

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { gql, useQuery } from '@apollo/client'
44

55
import Card from '@material-ui/core/Card'
66
import CardHeader from '@material-ui/core/CardHeader'
7-
import Table from '@material-ui/core/Table'
8-
import TableBody from '@material-ui/core/TableBody'
97
import TableCell from '@material-ui/core/TableCell'
108
import TableRow from '@material-ui/core/TableRow'
119
import Grid from '@material-ui/core/Grid'
@@ -26,31 +24,14 @@ export const ConfigurationV2Card = () => {
2624
fetchPolicy: 'cache-and-network',
2725
})
2826

29-
var user: string[] = []
30-
if (data != undefined) {
31-
user = data?.configv2.user.split(/\n/).map((l) => {
32-
return l
33-
})
34-
} else {
35-
user = []
36-
}
37-
var effective: string[] = []
38-
if (data != undefined) {
39-
effective = data?.configv2.effective.split(/\n/).map((l) => {
40-
return l
41-
})
42-
} else {
43-
effective = []
44-
}
45-
4627
return (
4728
<>
4829
<Grid item xs={12}>
4930
<TOMLCard
5031
title="TOML Configuration (user-specified)"
5132
error={error?.message}
5233
loading={loading}
53-
entries={user}
34+
toml={data?.configv2.user}
5435
showHead
5536
/>
5637
</Grid>
@@ -59,7 +40,7 @@ export const ConfigurationV2Card = () => {
5940
title="TOML Configuration (effective)"
6041
error={error?.message}
6142
loading={loading}
62-
entries={effective}
43+
toml={data?.configv2.effective}
6344
showHead
6445
/>
6546
</Grid>
@@ -68,7 +49,7 @@ export const ConfigurationV2Card = () => {
6849
}
6950

7051
interface Props {
71-
entries: Array<string>
52+
toml?: string
7253
loading: boolean
7354
showHead?: boolean
7455
title?: string
@@ -87,7 +68,7 @@ const FetchingRow = () => <SpanRow>...</SpanRow>
8768

8869
const ErrorRow: React.FC = ({ children }) => <SpanRow>{children}</SpanRow>
8970

90-
const TOMLCard = ({ loading, entries, error = '', title }: Props) => {
71+
const TOMLCard = ({ loading, toml, error = '', title }: Props) => {
9172
if (error) {
9273
return <ErrorRow>{error}</ErrorRow>
9374
}
@@ -96,18 +77,14 @@ const TOMLCard = ({ loading, entries, error = '', title }: Props) => {
9677
return <FetchingRow />
9778
}
9879

80+
let styles = {marginLeft: '1em'};
81+
9982
return (
10083
<Card>
10184
{title && <CardHeader title={title} />}
102-
<Table>
103-
<TableBody>
104-
{entries.map((k, i) => (
105-
<TableRow key={title + k + i}>
106-
<TableCell>{k}</TableCell>
107-
</TableRow>
108-
))}
109-
</TableBody>
110-
</Table>
85+
<pre style={styles}>
86+
<code>{toml}</code>
87+
</pre>
11188
</Card>
11289
)
11390
}

0 commit comments

Comments
 (0)