// // 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
} else if (!this.props.data) { return (
NO KEY
) } 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 = ( {this.state.error} ) } if (this.props.account.address != this.props.data.address) { deleteButton = } else { labelArray.push() labelArray.push() } if (!this.props.data.encr_used) { labelArray.push() } if (this.state.expanded) { details = (
{alert} Security Identifier: {this.props.data.fingerprint}
Last Updated: {this.props.data.refreshed_at}
Expires On: {this.props.data.expiry_date}
{deleteButton}
) } expander = (
) return (
{labelArray}
{expander}
{this.props.data.address}
{details}
) } }