/
VaultView.jsx
66 lines (62 loc) · 1.46 KB
/
VaultView.jsx
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
import React from 'react';
import {connect} from 'react-redux';
import {Link, IndexLink, withRouter} from 'react-router';
import sjcl from 'sjcl';
import {uploadVault} from '../actions';
import FocusComponent from './FocusComponent.jsx';
var VaultView = React.createClass({
render: function() {
var className = this.props.children ?
'focus blur' :
'focus';
var vaultItemIds = Object.keys(this.props.vault);
var vaultEntries = vaultItemIds.map((elem)=>{
var entry = this.props.vault[elem];
return <VaultEntry entry={entry} itemId={elem} key={elem}/>
});
return (
<div>
<div
className={className}>
Vault
<Link to="/vault/item/NEW">Add Item</Link>
<table>
<tbody>
{vaultEntries}
</tbody>
</table>
</div>
<FocusComponent>
{this.props.children}
</FocusComponent>
</div>
);
}
});
var VaultEntry = withRouter(React.createClass({
render: function(){
var entry = this.props.entry;
return (
<tr
onClick={this.goToVaultItem}>
<td>
{entry.name}
</td>
<td>
{entry.username}
</td>
</tr>
)
},
goToVaultItem: function(){
this.props.router.push('/vault/item/'+this.props.itemId);
}
}));
var mapStateToProps = function(state){
return {
vault: state.vault
};
}
export default connect(
mapStateToProps
)(VaultView);