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
81
82
83
84
85
86
87
88
89
90
91
92
93
|
//
// Interface to the key manager
//
import React from 'react'
import App from 'app'
import { Button, Glyphicon, Alert } from 'react-bootstrap'
import {VerticalLayout, Row} from 'components/layout'
import Spinner from 'components/spinner'
import KeyListItem from './key_list_item'
import './addressbook.less'
import bitmask from 'lib/bitmask'
export default class Addressbook extends React.Component {
static get defaultProps() {return{
account: null
}}
constructor(props) {
super(props)
this.state = {
keys: null,
loading: true,
errorMsg: ""
}
this.close = this.close.bind(this)
}
componentWillMount() {
bitmask.keys.list(this.props.account.id, false).then(keys => {
this.setState({keys: keys, loading: false})
}, error => {
this.setState({keys: null, loading: false, errorMsg: error})
})
}
close() {
App.show('main', {initialAccount: this.props.account})
}
render() {
let alert = null
let keyList = null
let spinner = null
if (this.state.loading) {
spinner = <Spinner />
}
if (this.state.errorMsg) {
alert = (
<Alert bsStyle="danger">{this.state.errorMsg}</Alert>
)
}
if (this.state.keys) {
keyList = this.state.keys.map((theKey, i) => {
return <KeyListItem key={i} data={theKey} account={this.props.account} />
})
}
let buttons = (
<Button onClick={this.close} className="btn-inverse">
<Glyphicon glyph="menu-left" />
Close
</Button>
)
let page = (
<VerticalLayout className="darkBg">
<Row className="header" size="shrink" gutter="8px">
<div className="pull-left">
{buttons}
</div>
<div className="title">
{this.props.account.address} / Addressbook
</div>
</Row>
<Row className="lightFg" size="expand">
{alert}
{spinner}
<div className="key-list">
{keyList}
</div>
</Row>
</VerticalLayout>
)
return page
}
}
|