-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b286a55
commit 3c7a06f
Showing
6 changed files
with
137 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@smartcontractkit/operator-ui': minor | ||
--- | ||
|
||
Add ability to show TOML config | ||
|
||
On the configuration screen, the user is now able to view their node's TOML config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
type ConfigV2Payload { | ||
user: String! | ||
effective: String! | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
src/screens/Configuration/ConfigurationV2Card/ConfigurationV2Card.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import React from 'react' | ||
|
||
import { gql, useQuery } from '@apollo/client' | ||
|
||
import Card from '@material-ui/core/Card' | ||
import CardHeader from '@material-ui/core/CardHeader' | ||
import Table from '@material-ui/core/Table' | ||
import TableBody from '@material-ui/core/TableBody' | ||
import TableCell from '@material-ui/core/TableCell' | ||
import TableRow from '@material-ui/core/TableRow' | ||
import Grid from '@material-ui/core/Grid' | ||
|
||
export const CONFIG_V2_QUERY = gql` | ||
query FetchConfigV2 { | ||
configv2 { | ||
user | ||
effective | ||
} | ||
} | ||
` | ||
export const ConfigurationV2Card = () => { | ||
const { data, loading, error } = useQuery< | ||
FetchConfigV2, | ||
FetchConfigV2Variables | ||
>(CONFIG_V2_QUERY, { | ||
fetchPolicy: 'cache-and-network', | ||
}) | ||
|
||
var user: string[] = [] | ||
if (data != undefined) { | ||
user = data?.configv2.user.split(/\n/).map((l) => { | ||
return l | ||
}) | ||
} else { | ||
user = [] | ||
} | ||
var effective: string[] = [] | ||
if (data != undefined) { | ||
effective = data?.configv2.effective.split(/\n/).map((l) => { | ||
return l | ||
}) | ||
} else { | ||
effective = [] | ||
} | ||
|
||
return ( | ||
<> | ||
<Grid item xs={12}> | ||
<TOMLCard | ||
title="TOML Configuration (user-specified)" | ||
error={error?.message} | ||
loading={loading} | ||
entries={user} | ||
showHead | ||
/> | ||
</Grid> | ||
<Grid item xs={12}> | ||
<TOMLCard | ||
title="TOML Configuration (effective)" | ||
error={error?.message} | ||
loading={loading} | ||
entries={effective} | ||
showHead | ||
/> | ||
</Grid> | ||
</> | ||
) | ||
} | ||
|
||
interface Props { | ||
entries: Array<string> | ||
loading: boolean | ||
showHead?: boolean | ||
title?: string | ||
error?: string | ||
} | ||
|
||
const SpanRow: React.FC = ({ children }) => ( | ||
<TableRow> | ||
<TableCell component="th" scope="row" colSpan={3}> | ||
{children} | ||
</TableCell> | ||
</TableRow> | ||
) | ||
|
||
const FetchingRow = () => <SpanRow>...</SpanRow> | ||
|
||
const ErrorRow: React.FC = ({ children }) => <SpanRow>{children}</SpanRow> | ||
|
||
const TOMLCard = ({ loading, entries, error = '', title }: Props) => { | ||
if (error) { | ||
return <ErrorRow>{error}</ErrorRow> | ||
} | ||
|
||
if (loading) { | ||
return <FetchingRow /> | ||
} | ||
|
||
return ( | ||
<Card> | ||
{title && <CardHeader title={title} />} | ||
{/* <Table size="small"> */} | ||
<Table> | ||
<TableBody> | ||
{entries.map((k, i) => ( | ||
<TableRow | ||
key={title + k + i} | ||
// sx={{ '&:last-child td, &:last-child th': { border: 0 } }} | ||
> | ||
<TableCell>{k}</TableCell> | ||
</TableRow> | ||
))} | ||
</TableBody> | ||
</Table> | ||
</Card> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters