diff --git a/src/components/ManagerPage/DeviceInfos.js b/src/components/ManagerPage/DeviceInfos.js index d16146e7..8b8ec5d8 100644 --- a/src/components/ManagerPage/DeviceInfos.js +++ b/src/components/ManagerPage/DeviceInfos.js @@ -49,6 +49,10 @@ class DeviceInfos extends PureComponent { const { device } = this.props const { memoryInfos, isLoading } = this.state + if (!device) { + return {'You dont have any device connected'} + } + const title = ( {device.manufacturer} diff --git a/src/components/ManagerPage/index.js b/src/components/ManagerPage/index.js index 5aa407d6..836c9795 100644 --- a/src/components/ManagerPage/index.js +++ b/src/components/ManagerPage/index.js @@ -9,7 +9,6 @@ import type { Device, T } from 'types/common' import { getCurrentDevice, getDevices } from 'reducers/devices' -import Box from 'components/base/Box' import Pills from 'components/base/Pills' import AppsList from './AppsList' @@ -37,6 +36,14 @@ class ManagerPage extends PureComponent { currentTab: 'apps', } + componentWillReceiveProps(nextProps) { + const { device } = this.props + const { currentTab } = this.state + if (device && !nextProps.device && currentTab === 'device') { + this.setState({ currentTab: 'apps' }) + } + } + handleTabChange = t => this.setState({ currentTab: t.value }) render() { @@ -45,19 +52,18 @@ class ManagerPage extends PureComponent { const tabs = TABS.map(i => { let label = t(`manager:tabs.${i.key}`) if (i.key === 'device') { + if (!device) { + return null + } label += ` (${nbDevices})` } return { ...i, label } - }) + }).filter(Boolean) return ( {currentTab === 'apps' && } - {currentTab === 'device' && ( - - - - )} + {currentTab === 'device' && } ) }