| 8 | import { View } from './View'; |
| 9 | |
| 10 | class EmptyStateView extends PureComponent { |
| 11 | constructor(props) { |
| 12 | super(props); |
| 13 | |
| 14 | autoBindReact(this); |
| 15 | } |
| 16 | |
| 17 | onRetry() { |
| 18 | const { onRetry } = this.props; |
| 19 | |
| 20 | onRetry(); |
| 21 | } |
| 22 | |
| 23 | renderRetryButton() { |
| 24 | const { retryButtonTitle } = this.props; |
| 25 | |
| 26 | // Show retry button at the bottom only if there is an onRetry action passed |
| 27 | return ( |
| 28 | <View styleName="horizontal anchor-bottom"> |
| 29 | <Button styleName="full-width" onPress={this.onRetry}> |
| 30 | <Text>{retryButtonTitle}</Text> |
| 31 | </Button> |
| 32 | </View> |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | render() { |
| 37 | const { icon, message, onRetry, ...otherProps } = this.props; |
| 38 | |
| 39 | return ( |
| 40 | <View {...otherProps} styleName="vertical flexible h-center v-center"> |
| 41 | <View styleName="icon-placeholder"> |
| 42 | <Icon name={icon} /> |
| 43 | </View> |
| 44 | |
| 45 | <Subtitle styleName="h-center">{message}</Subtitle> |
| 46 | |
| 47 | {onRetry && this.renderRetryButton()} |
| 48 | </View> |
| 49 | ); |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | EmptyStateView.propTypes = { |
| 54 | icon: PropTypes.string, |
nothing calls this directly
no outgoing calls
no test coverage detected