Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"jest": "^23.4.2",
"lint-staged": "^7.2.0",
"nock": "^9.0.14",
"prettier": "^1.5.3",
"prettier": "1.18.2",
"react": "^16.4.0",
"react-dom": "^16.4.0",
"react-test-renderer": "^16.4.0",
Expand Down
8 changes: 5 additions & 3 deletions src/components/CustomJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ export default class CustomJson extends Component {
}

render() {
const { title, url, apiData, apiError, template } = this.props
const { title, apiData, apiError, template } = this.props

let body = <WidgetLoader />
if (apiData && !apiError) {
const compiled = _.template(template)
body = <div dangerouslySetInnerHTML={createMarkup(compiled, apiData)} />
}

const hasHeader = title && title.length > 0

return (
<Widget>
<WidgetHeader title={title || url} />
<WidgetBody>
{hasHeader && <WidgetHeader title={title} />}
<WidgetBody isHeaderless={hasHeader}>
<TrapApiError error={apiError}>{body}</TrapApiError>
</WidgetBody>
</Widget>
Expand Down
8 changes: 5 additions & 3 deletions src/components/JsonKeys.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class JsonKeys extends Component {
}

render() {
const { title, url, keys, apiData, apiError } = this.props
const { title, keys, apiData, apiError } = this.props

let body = <WidgetLoader />
if (apiData && !apiError) {
Expand All @@ -49,10 +49,12 @@ export default class JsonKeys extends Component {
)
}

const hasHeader = title && title.length > 0

return (
<Widget>
<WidgetHeader title={title || url} />
<WidgetBody disablePadding={true}>
{hasHeader && <WidgetHeader title={title} />}
<WidgetBody disablePadding={true} isHeaderless={hasHeader}>
<TrapApiError error={apiError}>{body}</TrapApiError>
</WidgetBody>
</Widget>
Expand Down
15 changes: 9 additions & 6 deletions src/components/JsonStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class JsonStatus extends Component {
}

render() {
const { title, url, statuses, apiData, apiError, theme } = this.props
const { title, statuses, apiData, apiError, theme } = this.props

let body
let currentStatus = 'unknown'
Expand All @@ -63,9 +63,10 @@ export default class JsonStatus extends Component {
color: theme.colors.failure,
}}
>
invalid assertion:<br />
'{status.assert}'<br />
should conform to:<br />
invalid assertion:
<br />'{status.assert}'<br />
should conform to:
<br />
{'/^(equals|contains|matches)\\((.+),(.+)\\)$/'}
</div>
)
Expand Down Expand Up @@ -122,10 +123,12 @@ export default class JsonStatus extends Component {
body = <WidgetStatusBadge status={currentStatus} message={currentLabel} />
}

const hasHeader = title && title.length > 0

return (
<Widget>
<WidgetHeader title={title || url} />
<WidgetBody>
{hasHeader && <WidgetHeader title={title} />}
<WidgetBody isHeaderless={hasHeader}>
<TrapApiError error={apiError}>{body}</TrapApiError>
</WidgetBody>
</Widget>
Expand Down
5 changes: 2 additions & 3 deletions test/components/JsonKeys.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,10 @@ it('should display loader if no apiData available', () => {
})

describe('title', () => {
it('should display url by default', () => {
it('should display no header by default', () => {
const wrapper = Enzyme.shallow(<JsonKeys url="http://fake.io" keys={['A']} />)

const header = wrapper.find(WidgetHeader)
expect(header.prop('title')).toBe('http://fake.io')
expect(wrapper.find(WidgetHeader).exists()).toBeFalsy()
})

it('should support override', () => {
Expand Down
8 changes: 0 additions & 8 deletions test/components/__snapshots__/JsonKeys.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ exports[`should render as expected 1`] = `
<div
className="sc-bwzfXH bJUZVN"
>
<header
className="sc-htpNat lcyfRu"
style={Object {}}
>
<span>
http://fake.io
</span>
</header>
<div
className="sc-bZQynM FCrnA"
style={Object {}}
Expand Down
7 changes: 4 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4315,9 +4315,10 @@ preserve@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b"

prettier@^1.5.3:
version "1.13.7"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.7.tgz#850f3b8af784a49a6ea2d2eaa7ed1428a34b7281"
prettier@1.18.2:
version "1.18.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.18.2.tgz#6823e7c5900017b4bd3acf46fe9ac4b4d7bda9ea"
integrity sha512-OeHeMc0JhFE9idD4ZdtNibzY0+TPHSpSSb9h8FqtP+YnoZZ1sl8Vc9b1sasjfymH3SonAF4QcA2+mzHPhMvIiw==

pretty-format@^23.2.0:
version "23.2.0"
Expand Down