Skip to content

Commit

Permalink
feat(json): use react-json-view for great good
Browse files Browse the repository at this point in the history
replaces components/JSON.tsx

currently only being used in body with a depth > 2 and schema display
  • Loading branch information
b5 committed Aug 28, 2019
1 parent c2c96ab commit 842eda2
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 117 deletions.
8 changes: 6 additions & 2 deletions app/components/Body.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react'
import { CSSTransition } from 'react-transition-group'
import ReactJson from 'react-json-view'

import Toast, { ToastTypes } from './chrome/Toast'
import SpinnerWithIcon from './chrome/SpinnerWithIcon'
import HandsonTable from './HandsonTable'
import JSON from './JSON'
import { ApiAction } from '../store/api'

import { Structure } from '../models/dataset'
Expand Down Expand Up @@ -57,7 +57,11 @@ const Body: React.FunctionComponent<BodyProps> = ({ value, pageInfo, headers, st
/>
)
} else { // otherwise use our nifty JSON renderer
bodyContent = <JSON body={value} />
bodyContent = <ReactJson
name={null}
src={value}
displayDataTypes={false}
/>
}

return (
Expand Down
104 changes: 0 additions & 104 deletions app/components/JSON.tsx

This file was deleted.

13 changes: 10 additions & 3 deletions app/components/Schema.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import * as React from 'react'
import ReactJson from 'react-json-view'

import { Dataset } from '../models/dataset'
import SpinnerWithIcon from './chrome/SpinnerWithIcon'

interface SchemaProps {
schema: Dataset['schema']
}

const Schema: React.FunctionComponent<SchemaProps> = (props: SchemaProps) => {
if (!props.schema) {
const Schema: React.FunctionComponent<SchemaProps> = ({ schema }) => {
if (!schema) {
return <SpinnerWithIcon loading={true} />
}

return (
<div className='content'>
<pre>{JSON.stringify(props.schema, null, 2)}</pre>
<ReactJson
name={null}
src={schema}
enableClipboard={false}
displayDataTypes={false}
/>
</div>
)
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@
"moment": "2.24.0",
"react": "16.8.6",
"react-dom": "16.8.6",
"react-json-view": "^1.19.1",
"react-redux": "7.1.0",
"react-router": "5.0.1",
"react-router-dom": "5.0.1",
Expand Down
Loading

0 comments on commit 842eda2

Please sign in to comment.