blob: b8bdad363774a1ddcd5c02e7cae1607c787d1d0b (
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
//
// A key in the list of keys
//
import React from 'react'
import { Glyphicon, Button, ButtonToolbar, Label } from 'react-bootstrap'
import bitmask from 'lib/bitmask'
export default class KeyListItem extends React.Component {
static get defaultProps() {return{
data: null, // the key as an Object
account: null // the account as an Account
}}
constructor(props) {
super(props)
this.state = {
expanded: false,
hidden: false,
deleting: false,
error: null
}
this.toggle = this.toggle.bind(this)
this.delete = this.delete.bind(this)
}
toggle() {
this.setState({expanded: !this.state.expanded})
}
delete() {
if (this.props.account.address == this.props.data.address) {
return // please do not delete your own key
}
bitmask.keys.del(this.props.account.id, this.props.data.address, false).then(
key => {
this.setState({hidden: true})
},
error => {
this.setState({error: error})
}
)
}
render() {
if (this.state.hidden) {
return <div></div>
} else if (!this.props.data) {
return (
<div className="key-list-item">
NO KEY
</div>
)
}
let details = null
let expander = null
let alert = null
let deleteButton = null
let labelArray = []
let labels = null
let glyph = this.state.expanded ? 'triangle-bottom' : 'triangle-right'
if (this.state.error) {
alert = (
<Alert bsStyle="danger">{this.state.error}</Alert>
)
}
if (this.props.account.address != this.props.data.address) {
deleteButton = <Button onClick={this.delete}>Delete</Button>
} else {
labelArray.push(<Label key="owner" bsStyle="primary">Mine</Label>)
labelArray.push(<Label key="level" bsStyle="success">Verified</Label>)
}
if (!this.props.data.encr_used) {
labelArray.push(<Label key="used" bsStyle="default">Never Used</Label>)
}
if (this.state.expanded) {
details = (
<div className="details">
{alert}
Security Identifier: {this.props.data.fingerprint}<br />
Last Updated: {this.props.data.refreshed_at}<br />
Expires On: {this.props.data.expiry_date}<br />
<ButtonToolbar>
<Button onClick={this.toggle}>Close</Button>
{deleteButton}
</ButtonToolbar>
</div>
)
}
expander = (
<div className="expander">
<Glyphicon glyph={glyph} />
</div>
)
return (
<div className="key-list-item">
<div className="top-row clickable" onClick={this.toggle} >
<div className="labels pull-right">
{labelArray}
</div>
{expander}
<div className="address">
{this.props.data.address}
</div>
</div>
{details}
</div>
)
}
}
|