lotus/lotuspond/front/src/BlockLink.js

41 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-07-25 17:06:10 +00:00
import React from 'react';
import Block from "./Block";
2019-08-19 14:47:09 +00:00
import Address from "./Address";
2019-07-25 17:06:10 +00:00
export class BlockLinks extends React.Component {
render() {
2019-08-19 14:47:09 +00:00
return this.props.cids.map((c, k) => {
let block
if(this.props.blocks) {
block = this.props.blocks[k]
}
2020-04-02 23:09:31 +00:00
return <span key={c + '-' + k}><BlockLink block={block} conn={this.props.conn} cid={c} mountWindow={this.props.mountWindow}/> </span>
2019-08-19 14:47:09 +00:00
})
2019-07-25 17:06:10 +00:00
}
}
class BlockLink extends React.Component {
constructor(props) {
super(props)
this.openBlockViewer = this.openBlockViewer.bind(this)
}
openBlockViewer() {
this.props.mountWindow((onClose) => <Block cid={this.props.cid} conn={this.props.conn} onClose={onClose} mountWindow={this.props.mountWindow}/>)
}
render() {
2019-08-19 14:47:09 +00:00
let info = <span></span>
if(this.props.block) {
info = <span>&nbsp;(by <Address client={this.props.conn} addr={this.props.block.Miner} mountWindow={this.props.mountWindow} short={true}/>)</span>
}
return <span><a href="#" onClick={this.openBlockViewer}><abbr title={this.props.cid['/']}>{this.props.cid['/'].substr(-8)}</abbr></a>{info}</span>
2019-07-25 17:06:10 +00:00
}
}
export default BlockLink