summaryrefslogtreecommitdiff
path: root/ui/app/components/addressbook/index.js
blob: 74c119d37646eebe122b105699f846e21d39a29b (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// Interface to the key manager
//


import React from 'react'
import App from 'app'
import { ButtonToolbar, Button, Glyphicon, Alert } from 'react-bootstrap'

import {VerticalLayout, Row} from 'components/layout'
import bitmask from 'lib/bitmask'
import './addressbook.less'

export default class Addressbook extends React.Component {

  static get defaultProps() {return{
    account: null
  }}

  constructor(props) {
    super(props)
    this.state = {
      keys: null,
      errorMsg: ""
    }
    this.close = this.close.bind(this)
  }

  componentWillMount() {
    bitmask.keys.list(true).then(keys => {
      this.setState({keys: keys})
    }, error => {
      this.setState({errorMsg: error})
    })
  }

  close() {
    App.show('main', {initialAccount: this.props.account})
  }

  render() {
    let alert = null
    let keyList = null

    if (this.state.errorMsg) {
      alert = (
        <Alert bsStyle="danger">{this.state.errorMsg}</Alert>
      )
    }

    keyList = <b>list of keys goes here</b>

    let buttons = (
      <Button onClick={this.close} className="btn-inverse">
        <Glyphicon glyph="remove" />&nbsp;
        Close
      </Button>
    )

    let page = (
      <VerticalLayout className="darkBg">
        <Row className="header" size="shrink" gutter="8px">
          <div className="pull-right">
            {buttons}
          </div>
          <div className="title">
            {this.props.account.address}
            <h1>Addressbook</h1>
          </div>
        </Row>
        <Row className="lightFg" size="expand">
          {alert}
          {keyList}
        </Row>
      </VerticalLayout>
    )
    return page
  }

}