Skip to content

Commit

Permalink
Only render tooltip for maxHeightBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
nambrot committed Dec 24, 2017
1 parent 176db11 commit 58df2c9
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions src/components/BlockchainTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,45 @@ import { contains, pluck, pipe } from "ramda";
import NewBlock from "./NewBlock";
import DetailBlock from "./DetailBlock";
import { Tooltip, advanceTo, Dialog as WalkthroughDialog } from "./walkthrough";
import { last } from "ramda";

function generateNodeProps(longestChain) {
return function({ node, path }) {
const addBlock = () => {
this.addBlockFrom(node);
advanceTo(3);
};
const normalButton = (
<Button key="add" text="Add block from here" onClick={addBlock} />
);
const isMaxHeightBlock = last(longestChain).hash === node.hash;

return {
buttons: [
<Button
key="detail"
iconName="pt-icon-database"
onClick={this.showBlock(node)}
/>,
<Tooltip
content={
<p style={{ maxWidth: "250px" }}>
Mining blocks means adding blocks to another parent block by
pointing to it in the block header. Unless someone else gives you
coins, mining is the only way for you to get coins, so let's start
here.
</p>
}
next={addBlock}
nextLabel="Start mining!"
step={2}
>
<Button key="add" text="Add block from here" onClick={addBlock} />
</Tooltip>
isMaxHeightBlock ? (
<Tooltip
content={
<p style={{ maxWidth: "250px" }}>
Mining blocks means adding blocks to another parent block by
pointing to it in the block header. Unless someone else gives
you coins, mining is the only way for you to get coins, so let's
start here.
</p>
}
next={addBlock}
nextLabel="Start mining!"
step={2}
>
{normalButton}
</Tooltip>
) : (
normalButton
)
],
node: {
title: `Block ${node.hash.substr(0, 10)}`,
Expand Down

0 comments on commit 58df2c9

Please sign in to comment.