Skip to content
This repository has been archived by the owner on Mar 23, 2023. It is now read-only.

fix: hide vote button for resigned delegates and add status #1682

Merged
merged 7 commits into from
Feb 19, 2020
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ const network = {
market: {
enabled: false
},
knownWallets: {}
knownWallets: {},
constants: {
activeDelegates: 51
}
}

let wrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@
@click="emitCancel"
/>
</ListDividedItem>
<ListDividedItem :label="$t('WALLET_DELEGATES.STATUS.TITLE')">
<span :class="delegateStatus.class">
{{ delegateStatus.text }}
</span>
</ListDividedItem>
<ListDividedItem
:label="$t('WALLET_DELEGATES.RANK')"
:value="delegate.rank"
:value="rankLabel"
/>
<ListDividedItem
:label="$t('WALLET_DELEGATES.APPROVAL')"
Expand Down Expand Up @@ -205,6 +210,38 @@ export default {
}),

computed: {
delegateStatus () {
const activeThreshold = this.session_network.constants.activeDelegates
if (this.delegate.isResigned) {
return {
text: this.$t('WALLET_DELEGATES.STATUS.RESIGNED'),
class: 'text-red'
}
}
if (this.delegate.rank && this.delegate.rank <= activeThreshold) {
return {
text: this.$t('WALLET_DELEGATES.STATUS.ACTIVE'),
class: 'text-green'
}
}
return {
text: this.$t('WALLET_DELEGATES.STATUS.STANDBY'),
class: 'text-yellow'
dated marked this conversation as resolved.
Show resolved Hide resolved
}
},

rankLabel () {
if (this.delegate.rank === undefined && this.delegate.isResigned) {
return this.$t('WALLET_DELEGATES.RANK_NOT_APPLICABLE')
}

if (this.delegate.rank === undefined) {
return this.$t('WALLET_DELEGATES.RANK_NOT_AVAILABLE')
}

return this.delegate.rank
},

blocksProduced () {
if (!this.delegate.blocks || !this.delegate.blocks.produced) {
return 0
Expand All @@ -214,7 +251,7 @@ export default {
},

showVoteUnvoteButton () {
if (this.currentWallet.isContact || (!!this.votedDelegate && !this.isVoter)) {
if (this.currentWallet.isContact || (!!this.votedDelegate && !this.isVoter) || (this.delegate.isResigned && !this.isVoter)) {
return false
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ export default {
getVoteTitle () {
if (this.isUnvoting && this.votedDelegate) {
return this.$t('WALLET_DELEGATES.UNVOTE_DELEGATE', { delegate: this.votedDelegate.username })
} else if (this.isVoting && this.selectedDelegate) {
} else if (this.isVoting && this.selectedDelegate && !this.selectedDelegate.isResigned) {
return this.$t('WALLET_DELEGATES.VOTE_DELEGATE', { delegate: this.selectedDelegate.username })
} else {
return `${this.$t('COMMON.DELEGATE')} ${this.selectedDelegate.username}`
Expand Down
8 changes: 8 additions & 0 deletions src/renderer/i18n/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -1252,9 +1252,17 @@ export default {
},

WALLET_DELEGATES: {
STATUS: {
TITLE: 'Status',
ACTIVE: 'Active',
STANDBY: 'Standby',
RESIGNED: 'Resigned'
},
RANK: 'Rank',
USERNAME: 'Username',
RANK_BANNER: 'Rank: {rank}',
RANK_NOT_APPLICABLE: 'Not applicable',
RANK_NOT_AVAILABLE: 'Not yet available',
APPROVAL: 'Vote %',
FORGED: 'Forged',
BLOCKS: 'Blocks',
Expand Down