aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/pages/create-account/connect-hardware/connect-screen.js
blob: ec6a11b403b14a7bdeb5505e09dcb59b9eb35472 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const { Component } = require('react')
const PropTypes = require('prop-types')
const h = require('react-hyperscript')

class ConnectScreen extends Component {
    constructor (props, context) {
        super(props)
    }

    renderUnsupportedBrowser () {
        return (
            h('div', {}, [
                h('div.hw-unsupported-browser', [
                    h('h3.hw-unsupported-browser__title', {}, this.context.t('browserNotSupported')),
                    h('p.hw-unsupported-browser__msg', {}, this.context.t('chromeRequiredForTrezor')),
                ]),
                h(
                    'button.btn-primary.btn--large',
                    { onClick: () => global.platform.openWindow({
                    url: 'https://google.com/chrome',
                    }), style: { margin: 12 } },
                    this.context.t('downloadGoogleChrome')
                ),
            ])
        )
    }

    renderConnectButton () {
        return h(
                    'button.btn-primary.btn--large',
                    { onClick: this.props.connectToTrezor.bind(this), style: { margin: 12 } },
                    this.props.btnText
                )
      }

    render () {
        const isChrome = window.navigator.userAgent.search('Chrome') !== -1
        if (isChrome) {
            return this.renderConnectButton()
        }
        return this.renderUnsupportedBrowser()
    }
}

ConnectScreen.propTypes = {
    connectToTrezor: PropTypes.func.isRequired,
    btnText: PropTypes.string,
}

ConnectScreen.contextTypes = {
    t: PropTypes.func,
}

module.exports = ConnectScreen