Commit dae195f5 authored by Dan Notestein's avatar Dan Notestein
Browse files

Merge branch 'display_witness_owners' into 'develop'

Display witness owner(s) from witness_owner field

See merge request !79
parents 9d08faaa 0c925dfc
$theme-map: null;
$themes: ( $themes: (
original: ( original: (
colorAccent: $color-blue, colorAccent: $color-blue,
......
...@@ -208,15 +208,30 @@ class Witnesses extends React.Component { ...@@ -208,15 +208,30 @@ class Witnesses extends React.Component {
const now = Moment(); const now = Moment();
const witnesses = sorted_witnesses.map((item) => { const witnesses = sorted_witnesses.map((item) => {
const owner = item.get('owner'); const witnessName = item.get('owner');
if (owner === witnessToHighlight) { if (witnessName === witnessToHighlight) {
foundWitnessToHighlight = true; foundWitnessToHighlight = true;
} }
const witnessDescription = _.get( const witnessDescription = _.get(
witnessAccounts[owner], witnessAccounts[witnessName],
'profile.witness_description', 'profile.witness_description',
null null
); );
const witnessOwnerName = _.get(
witnessAccounts[witnessName],
'profile.witness_owner',
null
);
let witnessOwnerNames;
if (witnessOwnerName) {
witnessOwnerNames = [witnessOwnerName];
if (witnessOwnerName && witnessOwnerName.indexOf(',')) {
witnessOwnerNames = witnessOwnerName
.replace(/ /g, '')
.split(',');
}
}
const totalVotesVests = item.get('votes'); const totalVotesVests = item.get('votes');
const totalVotesHpf = vestsToHpf( const totalVotesHpf = vestsToHpf(
this.props.state, this.props.state,
...@@ -240,7 +255,9 @@ class Witnesses extends React.Component { ...@@ -240,7 +255,9 @@ class Witnesses extends React.Component {
previousTotalVoteHpf = totalVotesHpf; previousTotalVoteHpf = totalVotesHpf;
const thread = item.get('url').replace('steemit.com', 'hive.blog'); const thread = item.get('url').replace('steemit.com', 'hive.blog');
const myVote = witness_votes ? witness_votes.has(owner) : null; const myVote = witness_votes
? witness_votes.has(witnessName)
: null;
const signingKey = item.get('signing_key'); const signingKey = item.get('signing_key');
let witnessCreated = item.get('created'); let witnessCreated = item.get('created');
if (witnessCreated === '1970-01-01T00:00:00') if (witnessCreated === '1970-01-01T00:00:00')
...@@ -269,7 +286,7 @@ class Witnesses extends React.Component { ...@@ -269,7 +286,7 @@ class Witnesses extends React.Component {
const hbdExchangeUpdateDate = item.get('last_hbd_exchange_update'); const hbdExchangeUpdateDate = item.get('last_hbd_exchange_update');
const noBlock7days = (head_block - lastBlock) * 3 > 604800; const noBlock7days = (head_block - lastBlock) * 3 > 604800;
const isDisabled = signingKey == DISABLED_SIGNING_KEY; const isDisabled = signingKey == DISABLED_SIGNING_KEY;
const votingActive = witnessVotesInProgress.has(owner); const votingActive = witnessVotesInProgress.has(witnessName);
const classUp = const classUp =
'Voting__button Voting__button-up' + 'Voting__button Voting__button-up' +
(myVote === true ? ' Voting__button--upvoted' : '') + (myVote === true ? ' Voting__button--upvoted' : '') +
...@@ -287,17 +304,27 @@ class Witnesses extends React.Component { ...@@ -287,17 +304,27 @@ class Witnesses extends React.Component {
witness_link = '(No URL provided)'; witness_link = '(No URL provided)';
} else if (links.remote.test(thread)) { } else if (links.remote.test(thread)) {
witness_link = ( witness_link = (
<a href={thread} target="_blank"> <Link
{tt('witnesses_jsx.external_site')}&nbsp; to={thread}
target="_blank"
rel="noreferrer noopener"
>
{tt('witnesses_jsx.external_site')}
&nbsp;
<Icon name="extlink" /> <Icon name="extlink" />
</a> </Link>
); );
} else { } else {
witness_link = ( witness_link = (
<a href={thread} target="_blank"> <Link
{tt('witnesses_jsx.witness_thread')}&nbsp; to={thread}
target="_blank"
rel="noreferrer noopener"
>
{tt('witnesses_jsx.witness_thread')}
&nbsp;
<Icon name="extlink" /> <Icon name="extlink" />
</a> </Link>
); );
} }
} }
...@@ -308,9 +335,10 @@ class Witnesses extends React.Component { ...@@ -308,9 +335,10 @@ class Witnesses extends React.Component {
return ( return (
<tr <tr
key={owner} key={witnessName}
className={classnames({ className={classnames({
Witnesses__highlight: witnessToHighlight === owner, Witnesses__highlight:
witnessToHighlight === witnessName,
})} })}
> >
<td className="Witnesses__rank"> <td className="Witnesses__rank">
...@@ -325,7 +353,7 @@ class Witnesses extends React.Component { ...@@ -325,7 +353,7 @@ class Witnesses extends React.Component {
href="#" href="#"
onClick={accountWitnessVote.bind( onClick={accountWitnessVote.bind(
this, this,
owner, witnessName,
!myVote !myVote
)} )}
title={ title={
...@@ -340,9 +368,15 @@ class Witnesses extends React.Component { ...@@ -340,9 +368,15 @@ class Witnesses extends React.Component {
</span> </span>
</td> </td>
<td className="Witnesses__info"> <td className="Witnesses__info">
<Link to={'/@' + owner} style={ownerStyle}> <Link
to={`${$STM_Config.social_url}/@${witnessName}`}
style={ownerStyle}
title={tt(
'witnesses_jsx.navigate_to_witness_profile'
)}
>
<Userpic <Userpic
account={owner} account={witnessName}
size="small" size="small"
className={classnames({ className={classnames({
disabled: isDisabled, disabled: isDisabled,
...@@ -351,17 +385,81 @@ class Witnesses extends React.Component { ...@@ -351,17 +385,81 @@ class Witnesses extends React.Component {
</Link> </Link>
<div className="Witnesses__info"> <div className="Witnesses__info">
<div> <div>
<Link to={'/@' + owner} style={ownerStyle}> <Link
{owner} to={`${$STM_Config.social_url}/@${witnessName}`}
style={ownerStyle}
title={tt(
'witnesses_jsx.navigate_to_witness_profile'
)}
target="_blank"
rel="noreferrer noopener"
>
{witnessName}
</Link> </Link>
{witnessOwnerNames && (
<span>
{' '}
by{' '}
{witnessOwnerNames.map(
(ownerName, index) => {
if (
witnessOwnerNames.length >
1 &&
index ===
witnessOwnerNames.length -
1
) {
return (
<span>
{' '}
&{' '}
<Link
to={`${$STM_Config.social_url}/@${ownerName}`}
style={
ownerStyle
}
title={tt(
'witnesses_jsx.navigate_to_witness_profile'
)}
target="_blank"
rel="noreferrer noopener"
>
{ownerName}
</Link>
</span>
);
}
return (
<span>
{index > 0 && ', '}
<Link
to={`${$STM_Config.social_url}/@${ownerName}`}
style={ownerStyle}
title={tt(
'witnesses_jsx.navigate_to_witness_profile'
)}
target="_blank"
rel="noreferrer noopener"
>
{ownerName}
</Link>
</span>
);
}
)}
</span>
)}
<Link <Link
to={`/~witnesses?highlight=${owner}`} to={`/~witnesses?highlight=${witnessName}`}
onClick={(event) => { onClick={(event) => {
event.preventDefault(); event.preventDefault();
updateWitnessToHighlight.apply(this, [ updateWitnessToHighlight.apply(this, [
owner, witnessName,
]); ]);
}} }}
title={tt(
'witnesses_jsx.link_to_highlight_witness'
)}
> >
<Icon <Icon
name="chain" name="chain"
......
...@@ -443,7 +443,9 @@ ...@@ -443,7 +443,9 @@
"hp_required_to_rank_up": "Needs %(votehp)s to level up", "hp_required_to_rank_up": "Needs %(votehp)s to level up",
"witness_age": "Witness age", "witness_age": "Witness age",
"not_produced_over_a_week": "Has not produced any blocks for over a week.", "not_produced_over_a_week": "Has not produced any blocks for over a week.",
"last_block": "Last block" "last_block": "Last block",
"navigate_to_witness_profile": "Navigate to this user's profile",
"link_to_highlight_witness": "Use this for linking to this page and highlight the selected witness"
}, },
"votesandcomments_jsx": { "votesandcomments_jsx": {
"no_responses_yet_click_to_respond": "No responses yet. Click to respond.", "no_responses_yet_click_to_respond": "No responses yet. Click to respond.",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment