fix browser blank page on gateways (#8453)

StorageInfo component will not be rendered if
Storage used is null.
This commit is contained in:
Kanagaraj M 2019-10-28 23:18:02 +05:30 committed by kannappanr
parent a2825702f8
commit 4e6bf136a8
3 changed files with 58 additions and 39 deletions

View file

@ -26,7 +26,13 @@ export class StorageInfo extends React.Component {
}
render() {
const { used } = this.props.storageInfo
var totalUsed = used.reduce((v1, v2) => v1 + v2, 0)
if (!used) {
return <noscript />
}
const totalUsed = used.reduce((v1, v2) => v1 + v2, 0)
return (
<div className="feh-used">
<div className="fehu-chart">

View file

@ -35,4 +35,15 @@ describe("StorageInfo", () => {
)
expect(fetchStorageInfo).toHaveBeenCalled()
})
it("should not render anything if used is null", () => {
const fetchStorageInfo = jest.fn()
const wrapper = shallow(
<StorageInfo
storageInfo={{ used: null }}
fetchStorageInfo={fetchStorageInfo}
/>
)
expect(wrapper.text()).toBe("")
})
})

File diff suppressed because one or more lines are too long