Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

david+fede+jordan/1402-Proposal creation #1522

Merged
merged 32 commits into from
Nov 19, 2018
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
577e124
Merge mocked submit deposit
Nov 14, 2018
c89bac7
ModalPropose
Nov 14, 2018
595908d
minor tests fixes
Nov 14, 2018
936e8ae
ModalPropose unit tests
Nov 14, 2018
0baa426
update proposal store module
Nov 14, 2018
585a443
user testing fixes
Nov 14, 2018
982a157
Merge branch 'develop' into david/1402-proposal-creation
fedekunze Nov 14, 2018
6873182
styling for proposal modal
jbibla Nov 14, 2018
a43389f
misspelling causing error
jbibla Nov 14, 2018
888e1d9
added slot to tmbalance so button can go in
jbibla Nov 14, 2018
c80dd24
we don't need to import tm-tool-bar
jbibla Nov 14, 2018
7feb469
another typo of lowerCase
jbibla Nov 14, 2018
6e07337
fixed tests
jbibla Nov 14, 2018
14c0c40
Merge branch 'david/1402-proposal-creation' of https://github.com/cos…
jbibla Nov 14, 2018
81aa088
Create proposal, deposit and voting working (missing test fixes)
Nov 15, 2018
4cedba9
fixed unit tests
Nov 15, 2018
9d2ceb2
update Changelog
Nov 15, 2018
aea68e4
update Changelog
Nov 15, 2018
c772b50
test PageProposal still failing
Nov 15, 2018
d79bf64
Fix broken tests in PageGovernance.
Nov 15, 2018
c35a3a9
Merge branch 'develop' into david/1402-proposal-creation
fedekunze Nov 15, 2018
325b5ce
fix vm-tool-bar on preferences
Nov 15, 2018
36cfc15
snapshot
Nov 15, 2018
45c600b
try and catch error from e2e
Nov 15, 2018
4a47650
fixed e2e by setting window size
Nov 16, 2018
087844f
fix e2e
Nov 16, 2018
41eb319
test for redirect to preferences
Nov 16, 2018
33e65b5
Merge branch 'develop' into david/1402-proposal-creation
fedekunze Nov 18, 2018
59711f9
updated block --> time
Nov 19, 2018
f907a94
lint & CHANGELOG
Nov 19, 2018
ad6730e
Update toolbar and e2e
Nov 19, 2018
4e2e363
Update ModalPropose.vue
fedekunze Nov 19, 2018
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
3 changes: 3 additions & 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.
* [\#1464](https://github.com/cosmos/voyager/issues/1464) Added governance transactions to tx history page @fedekunze
* [\#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 through modal @fedekunze + @NodeGuy + @jbibla
* [\#1501](https://github.com/cosmos/voyager/issues/1501) Vote on proposals through modal @fedekunze + @jbibla
* [\#1567](https://github.com/cosmos/voyager/pull/1567) Various refactors on `main`, `node` and `lcdClient`. @NodeGuy
* [\#1502](https://github.com/cosmos/voyager/issues/1502) A page for each proposal. @jbibla
Expand Down Expand Up @@ -46,6 +47,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [\#1410](https://github.com/cosmos/voyager/issues/1410) removed end undelegations as not needed in the SDK anymore
* [\#1543](https://github.com/cosmos/voyager/issues/1543) updated unit tests to use `describe` and `it` instead of `test` @fedekunze
* [\#1377](https://github.com/cosmos/voyager/issues/1377) deleted AppFooter page @fedekunze
* [\#1582](https://github.com/cosmos/voyager/issues/1582) proposals now use time instead of block number @fedekunze

### Fixed

Expand All @@ -64,6 +66,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
* [\#1131](https://github.com/cosmos/voyager/issues/1131) Display only error message on notifications @fedekunze
* [\#1440](https://github.com/cosmos/voyager/issues/1440) Fixed an error that prevented disconnecting from the RPC websocket if it wasn't defined @fedekunze
* [\#1460](https://github.com/cosmos/voyager/issues/1460) Removing release-candidate tag when publishing @faboweb
* [\#1402](https://github.com/cosmos/voyager/issues/1402) Fixed minor issues in voting and deposit @fedekunze
* [\#1574](https://github.com/cosmos/voyager/issues/1574) Fixed typo on mocked governance txs that prevented the execution of the query @fedekunze
* [\#1575](https://github.com/cosmos/voyager/issues/1575) Fixed tags on governace transactions query @fedekunze

Expand Down
6 changes: 5 additions & 1 deletion app/src/renderer/components/common/PagePreferences.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<template lang="pug">
tm-page(data-title="Preferences")
div(slot="menu"): vm-tool-bar
template(slot="menu-body")
tm-balance
vm-tool-bar

tm-part(title='Settings')
tm-list-item(type="field" title="Select network to connect to")
Expand Down Expand Up @@ -48,11 +50,13 @@ tm-page(data-title="Preferences")
import { mapGetters } from "vuex"
import { TmListItem, TmBtn, TmPage, TmPart, TmField } from "@tendermint/ui"
import VmToolBar from "common/VmToolBar"
import TmBalance from "common/TmBalance"
import TmModal from "common/TmModal"

export default {
name: `page-preferences`,
components: {
TmBalance,
TmBtn,
TmField,
TmListItem,
Expand Down
7 changes: 7 additions & 0 deletions app/src/renderer/components/common/TmBalance.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
:class="{'tab-selected': $route.name === tab}",
)
router-link(:to="{name: tab}") {{ tab }}

slot
</template>
<script>
import num from "scripts/num"
Expand Down Expand Up @@ -133,4 +135,9 @@ export default {

a
color var(--bright)

.tm-btn
position absolute
right 0rem
bottom 1rem
</style>
29 changes: 20 additions & 9 deletions app/src/renderer/components/common/VmToolBar.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
<template lang="pug">
tm-tool-bar
.tm-tool-bar
a.back(@click="back" :disabled="user.history.length === 0" v-tooltip.bottom="'Back'")
i.material-icons arrow_back
slot
a.help(@click="enableModalHelp" v-tooltip.bottom="'Help'")
i.material-icons help_outline
router-link.settings(to="/preferences" v-tooltip.bottom="'Preferences'")
i.material-icons#settings settings
router-link#settings(to="/preferences" v-tooltip.bottom="'Preferences'")
i.material-icons settings
a#signOut-btn(@click="signOut" v-tooltip.bottom.end="'Sign Out'")
i.material-icons exit_to_app
</template>

<script>
import { TmToolBar } from "@tendermint/ui"
import { mapGetters, mapMutations } from "vuex"
export default {
// the name needs to be different from TmToolBar (tm-tool-bar) or else recursive rendering takes place
name: `vm-tool-bar`,
components: {
TmToolBar
},
methods: {
...mapMutations([`pauseHistory`, `popHistory`]),
back() {
Expand All @@ -43,6 +39,21 @@ export default {
}
</script>
<style lang="stylus">
.tm-tool-bar-container a
margin-top 0 !important

.tm-tool-bar
height 100%

.tm-page-header-text
padding-right 1rem

a
cursor pointer

i
padding 1rem
color var(--dim)

&:hover
color var(--bright)

</style>
11 changes: 2 additions & 9 deletions app/src/renderer/components/governance/LiProposal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ tr.li-proposal
td.li-proposal__value
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 }}
router-link(:to="{ name: 'Proposal', params: { proposalId: proposal.proposal_id, proposal, status }}") {{ proposal.title }}
p {{ description }}
td {{ submitBlock }}
td {{ `#` + proposal.proposal_id }}
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: {
Expand Down Expand Up @@ -53,12 +52,6 @@ export default {
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 Down
8 changes: 7 additions & 1 deletion app/src/renderer/components/governance/ModalDeposit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ export default {
this.$emit(`update:showModalDeposit`, false)
},
onDeposit() {
this.$emit(`submitDeposit`, { amount: this.amount })
let amount = [
{
denom: this.denom,
amount: String(this.amount)
}
]
this.$emit(`submitDeposit`, { amount })
this.close()
}
},
Expand Down
207 changes: 207 additions & 0 deletions app/src/renderer/components/governance/ModalPropose.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
<template lang="pug">
.modal-propose#modal-propose(v-click-outside="close")
.modal-propose-header
img.icon(class='modal-propose-atom' src="~assets/images/cosmos-logo.png")
span.tm-modal-title Create Proposal
.tm-modal-icon.tm-modal-close#closeBtn(@click="close()")
i.material-icons close

tm-form-group.page-proposal-form-group
span Title
tm-field#title(
type="text"
placeholder="Proposal title"
v-model="title"
v-focus)

tm-form-group.page-proposal-form-group
span Description
tm-field#description(
type="textarea"
placeholder="Write your proposal here..."
v-model="description")

tm-form-group.modal-propose-form-group(
field-id='amount')
span Deposit amount
tm-field#denom(
type="text"
:placeholder="denom"
readonly)

tm-field#amount(
type="number"
:max="balance"
:min="0"
step="any"
v-model="amount"
v-focus)

.modal-propose-footer
tm-btn#submit-proposal(
@click.native="onPropose"
:disabled="$v.$invalid"
color="primary"
value="Submit proposal"
size="lg")
</template>

<script>
import { mapGetters } from "vuex"
import ClickOutside from "vue-click-outside"
import {
minLength,
maxLength,
required,
between
} from "vuelidate/lib/validators"
import { isEmpty, trim } from "lodash"
import Modal from "common/TmModal"
import { TmBtn, TmField, TmFormGroup } from "@tendermint/ui"

const isValid = type =>
type === `Text` || type === `ParameterChange` || type === `SoftwareUpgrade`

const notBlank = text => !isEmpty(trim(text))

export default {
name: `modal-propose`,
props: [`denom`],
computed: {
// TODO: get coin denom from governance params
...mapGetters([`wallet`]),
balance() {
// TODO: refactor to get the selected coin when multicooin deposit is enabled
fedekunze marked this conversation as resolved.
Show resolved Hide resolved
if (!this.wallet.balancesLoading && !!this.wallet.balances.length) {
let balance = this.wallet.balances.find(
coin => coin.denom === this.denom
)
if (balance) return parseFloat(balance.amount)
}
return 0
}
},
components: {
Modal,
TmBtn,
TmField,
TmFormGroup
},
data: () => ({
titleMinLength: 1,
titleMaxLength: 64,
descriptionMinLength: 1,
descriptionMaxLength: 200,
title: ``,
description: ``,
type: `Text`,
amount: 0
}),
validations() {
return {
title: {
required,
minLength(x) {
return minLength(this.titleMinLength)(x)
},
maxLength(x) {
return maxLength(this.titleMaxLength)(x)
},
notBlank
},
description: {
required,
minLength(x) {
return minLength(this.descriptionMinLength)(x)
},
maxLength(x) {
return maxLength(this.descriptionMaxLength)(x)
},
notBlank
},
type: {
isValid
},
amount: {
required,
between: between(
0.0000000001,
this.balance > 0 ? this.balance : 0.0000000001
)
}
}
},
methods: {
close() {
this.$emit(`update:showModalPropose`, false)
},
onPropose() {
this.$emit(`createProposal`, {
title: this.title,
description: this.description,
type: this.type,
amount: this.amount
})
this.close()
}
},
directives: {
ClickOutside
}
}
</script>

<style lang="stylus">
@import '~variables'

.modal-propose
background var(--app-nav)
display flex
flex-direction column
justify-content space-between
left 50%
padding 2rem
position fixed
bottom 0
width 50%
z-index z(modal)

&-header
align-items center
display flex

&-atom
height 4rem
width 4rem

&-form-group
display block
padding 0

#amount
margin-top -32px

#denom
border none
margin-left 80%
text-align right
width 72px

&-footer
display flex
justify-content flex-end

button
margin-left 1rem
margin-top 1rem

.page-proposal-form-group
display block
padding 0

textarea
min-height 300px

.tm-form-group
margin 0.5rem 0
</style>
Loading