Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/cosmos/voyager into davi…
Browse files Browse the repository at this point in the history
…d/1402-proposal-creation

Merge develop
  • Loading branch information
Federico Kunze committed Nov 9, 2018
2 parents 1fb6b34 + 2786be1 commit 6ebf900
Show file tree
Hide file tree
Showing 15 changed files with 796 additions and 49 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [\1401](https://github.com/cosmos/voyager/issues/1401) Display governance proposals index. @fedekunze
* [\#1472](https://github.com/cosmos/voyager/issues/1472) Added mock functionality for redelegation @fedekunze + @faboweb
* [\#1402](https://github.com/cosmos/voyager/issues/1402) Proposal creation. @NodeGuy
* [\1502](https://github.com/cosmos/voyager/issues/1502) A page for each proposal. @jbibla

### Changed

Expand Down
4 changes: 3 additions & 1 deletion app/src/renderer/components/common/TmBalance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,5 +130,7 @@ export default {
&.tab-selected
border-bottom 2px solid var(--tertiary)
color var(--bright)
a
color var(--bright)
</style>
78 changes: 65 additions & 13 deletions app/src/renderer/components/governance/LiProposal.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,64 @@
<template lang="pug">
tr.li-proposal.li-validator
tr.li-proposal
td.li-proposal__value
h2 {{ proposal.title }}
p Status: {{ proposal.proposal_status }}
//- .proposal-profile__status(v-bind:class="statusColor" v-tooltip.top="proposal.proposal_status")
span.validator-profile__status(v-bind:class="status.color" v-tooltip.top="status.message")
h2
router-link(:to="{ name: 'Proposal', params: { proposalId, proposal, status }}") {{ proposal.title }}
p {{ description }}
td {{ submitBlock }}
td.li-proposal__value.yes {{ proposal.tally_result.yes }}
td.li-proposal__value.no {{ proposal.tally_result.no }}
td.li-proposal__value.no_with_veto {{ proposal.tally_result.no_with_veto }}
td.li-proposal__value.abstain {{ proposal.tally_result.abstain }}
</template>

<script>
import num from "scripts/num"
export default {
name: `li-proposal`,
computed: {
statusColor() {
if (this.proposal.proposal_status === `Rejected`) return `red`
else if (this.proposal.proposal_status === `Passed`) return `green`
status() {
if (this.proposal.proposal_status === `Passed`)
return {
button: null,
message: `This proposal has passed`,
color: `green`
}
if (this.proposal.proposal_status === `Rejected`)
return {
button: null,
message: `This proposal has been rejected and voting is closed`,
color: `red`
}
if (this.proposal.proposal_status === `Pending`)
return {
button: `deposit`,
message: `Deposits are open for this proposal`,
color: `yellow`
}
if (this.proposal.proposal_status === `Active`)
return {
button: `vote`,
message: `Voting for this proposal is open`,
color: `blue`
}
else
return {
button: null,
message: `There was an error determining the status of this proposal.`,
color: `grey`
}
},
// TODO redirect to proposal page
proposalLink() {
return {
name: ``
}
description() {
return this.proposal.description.length > 100
? this.proposal.description.substring(0, 100) + ``
: this.proposal.description.substring(0, 100)
},
submitBlock() {
return `#` + num.prettyInt(this.proposal.submit_block)
},
proposalId() {
return this.proposal.proposal_id
}
},
props: [`proposal`]
Expand All @@ -34,7 +70,23 @@ export default {
.li-proposal
margin 0.5rem 0rem 0.5rem 2rem
background-color var(--app-fg)
border-radius 0.25rem
border 1px solid var(--bc-dim)
&:hover
background var(--hover-bg)
.validator-profile__status
position relative
left 0
top inherit
display inline-block
h2
display inline-block
padding-left 0.5rem
td
padding 0.5rem
padding 1rem 0.5rem
</style>
136 changes: 136 additions & 0 deletions app/src/renderer/components/governance/PageProposal.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
<template lang="pug">
tm-page(data-title='Proposal')
template(slot="menu-body"): tm-balance
div(slot="menu"): tm-tool-bar
router-link(to="/governance" exact): i.material-icons arrow_back

tm-data-error(v-if="!proposal")

template(v-else)
.validator-profile__header.validator-profile__section.proposal
.column.validator-profile__header__info
.row.validator-profile__header__name
.top.column
div.validator-profile__status-and-title
span.validator-profile__status(v-bind:class="status.color" v-tooltip.top="status.message")
.validator-profile__header__name__title {{ proposal.title }}
.column.validator-profile__header__actions
tm-btn(v-if="status.button === 'vote'" value="Vote" color="primary")
tm-btn(v-if="status.button === 'deposit'" value="Deposit" color="primary")
tm-btn(v-if="!status.button" disabled value="Deposit / Vote" color="primary")

.row.description
p This {{ proposalType }} proposal ({{ `#` + proposal.proposal_id }}) was submitted at block {{ submitBlock }} and voting started at {{ voteBlock }}.

.row.validator-profile__header__data.votes
dl.colored_dl
dt Deposit
dd {{ proposal.total_deposit[0].amount + ` ` + proposal.total_deposit[0].denom }}
.validator-profile__header__data__break
dl.colored_dl
dt Yes
dd {{ proposal.tally_result.yes }} / {{ yesPercentage }}
dl.colored_dl
dt No
dd {{ proposal.tally_result.no }} / {{ noPercentage }}
dl.colored_dl
dt No with Veto
dd {{ proposal.tally_result.no_with_veto }} / {{ noWithVetoPercentage }}
dl.colored_dl
dt Abstain
dd {{ proposal.tally_result.abstain }} / {{ abstainPercentage }}

.validator-profile__details.validator-profile__section
.column
.row
text-block(:content="proposal.description")
</template>

<script>
import num from "scripts/num"
import { TmBtn, TmPage, TmToolBar } from "@tendermint/ui"
import TmBalance from "common/TmBalance"
import FieldVote from "common/TmFieldVote"
import TextBlock from "common/TextBlock"
export default {
name: `page-proposal`,
props: [`proposal`, `status`],
components: {
TmBalance,
TmBtn,
FieldVote,
TmToolBar,
TmPage,
TextBlock
},
computed: {
proposalType() {
return this.proposal.proposal_type.toLowerCase()
},
submitBlock() {
return `#` + num.prettyInt(this.proposal.submit_block)
},
voteBlock() {
if (this.proposal.submit_block === this.proposal.voting_start_block) {
return `the same block`
} else {
return `block #` + num.prettyInt(this.proposal.voting_start_block)
}
},
totalVotes() {
return (
Number(this.proposal.tally_result.yes) +
Number(this.proposal.tally_result.no) +
Number(this.proposal.tally_result.no_with_veto) +
Number(this.proposal.tally_result.abstain)
)
},
yesPercentage() {
return num.percentInt(this.proposal.tally_result.yes / this.totalVotes)
},
noPercentage() {
return num.percentInt(this.proposal.tally_result.no / this.totalVotes)
},
noWithVetoPercentage() {
return num.percentInt(
this.proposal.tally_result.no_with_veto / this.totalVotes
)
},
abstainPercentage() {
return num.percentInt(
this.proposal.tally_result.abstain / this.totalVotes
)
}
}
}
</script>
<style lang="stylus">
@require '~variables';
.proposal
b
color var(--bright)
.validator-profile__status
position relative
left 0
margin-right 0.5rem
.description
max-width 500px
.votes
padding-top 2rem
.proposal-id
color var(--dim)
font-size 14px
margin 0
font-weight 400
padding-bottom 0.25rem
.text-block
padding 0
.row b
font-weight 500
</style>
6 changes: 6 additions & 0 deletions app/src/renderer/components/governance/TableProposals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ export default {
tooltip: `The title of the proposal`,
class: `proposal_title`
},
{
title: `Submitted Block`,
value: `submit_block`,
tooltip: `Block height when proposal was submitted`,
class: `submit_block`
},
{
title: `Yes`,
value: `tally_result.yes`,
Expand Down
6 changes: 5 additions & 1 deletion app/src/renderer/components/staking/PageValidator.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template lang="pug">
tm-page(data-title="Validator")
template(slot="menu-body", v-if="config.devMode"): tm-balance
template(slot="menu-body"): tm-balance
div(slot="menu"): tm-tool-bar
router-link(to="/staking" exact): i.material-icons arrow_back

Expand Down Expand Up @@ -452,6 +452,7 @@ export default {
display inline-block
font-size h1
line-height h1
font-weight 400
padding 0 0.5rem 0.5rem 0
&__address
Expand Down Expand Up @@ -485,6 +486,9 @@ export default {
&.green
background var(--success)
&.blue
background var(--primary)
&__status-and-title
align-items center
display flex
Expand Down
2 changes: 1 addition & 1 deletion app/src/renderer/connectors/lcdClientMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ let state = {
],
submit_block: `10`,
voting_start_block: `-1`,
proposal_status: `DepositPeriod`,
proposal_status: `Pending`,
tally_result: {
yes: `0`,
no: `0`,
Expand Down
15 changes: 7 additions & 8 deletions app/src/renderer/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,16 @@ export default [
path: `/governance/proposals/new`,
component: governance(`ProposalsNewText`)
},
// TODO: enable once PageProposal is finished
// {
// path: `governance/proposals/:proposal`,
// name: `proposal`,
// component: governance(`Proposal`)
// },

{
path: `/governance/:proposalId`,
name: `Proposal`,
component: require(`./components/governance/PageProposal`).default,
props: true
},
// STAKE
{
path: `/staking`,
name: `staking`,
name: `Staking`,
component: staking(`Staking`),
redirect: `/staking/my-delegations/`,
children: [
Expand Down
Loading

0 comments on commit 6ebf900

Please sign in to comment.