From c89bac7465587746aa30bd77397ec1908a45d885 Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 14 Nov 2018 15:23:18 +0100 Subject: [PATCH 01/27] ModalPropose --- .../components/governance/ModalPropose.vue | 183 ++++++++++++++++++ .../components/governance/PageGovernance.vue | 38 +++- .../components/governance/PageProposal.vue | 5 +- .../governance/PageProposalsNewText.vue | 114 ----------- .../components/governance/TableProposals.vue | 1 - .../governance/PageProposalsNewText.spec.js | 97 ---------- 6 files changed, 221 insertions(+), 217 deletions(-) create mode 100644 app/src/renderer/components/governance/ModalPropose.vue delete mode 100644 app/src/renderer/components/governance/PageProposalsNewText.vue delete mode 100644 test/unit/specs/components/governance/PageProposalsNewText.spec.js diff --git a/app/src/renderer/components/governance/ModalPropose.vue b/app/src/renderer/components/governance/ModalPropose.vue new file mode 100644 index 0000000000..b40e2b5afb --- /dev/null +++ b/app/src/renderer/components/governance/ModalPropose.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/app/src/renderer/components/governance/PageGovernance.vue b/app/src/renderer/components/governance/PageGovernance.vue index 907919166d..ad683aae44 100644 --- a/app/src/renderer/components/governance/PageGovernance.vue +++ b/app/src/renderer/components/governance/PageGovernance.vue @@ -2,6 +2,7 @@ tm-page(data-title='Governance').governance template(slot="menu-body") tm-balance(:tabs="tabs") + tm-btn#propose-btn(value="Create Proposal" color="primary" @click.native="onPropose") div(slot="menu"): vm-tool-bar router-link(to="/governance/proposals/new" exact v-tooltip.bottom="'New Proposal'") @@ -10,7 +11,12 @@ tm-page(data-title='Governance').governance i.search.material-icons search modal-search(type="proposals") - + modal-propose( + v-if="showModalPropose" + v-on:createProposal="propose" + :showModalVote.sync="showModalVote" + :denom="bondingDenom.toLowerCase()" + ) router-view @@ -18,6 +24,7 @@ tm-page(data-title='Governance').governance import { mapGetters } from "vuex" import DataEmptySearch from "common/TmDataEmptySearch" import ModalSearch from "common/TmModalSearch" +import ModalPropose from "./ModalPropose" import VmToolBar from "common/VmToolBar" import TmBalance from "common/TmBalance" import { TmPage, TmDataEmpty, TmDataLoading } from "@tendermint/ui" @@ -29,16 +36,41 @@ export default { TmDataEmpty, DataEmptySearch, ModalSearch, + ModalPropose, TmPage, VmToolBar }, computed: { - ...mapGetters([`config`, `proposals`, `filters`]) + // TODO: get min deposit denom from gov params + ...mapGetters([`proposals`, `filters`, `bondingDenom`]) }, data: () => ({ - tabs: [`Proposals`] + tabs: [`Proposals`], + showModalPropose: false }), methods: { + onPropose() { + this.showModalPropose = true + }, + async propose({ title, description, proposal_type, initial_deposit }) { + try { + this.$store.dispatch(`submitProposal`, { + title, + description, + proposal_type, + initial_deposit + }) + this.$store.commit(`notify`, { + title: `Successful proposal submission!`, + body: `You have successfully submitted a new ${this.proposal_type.toLowercase()} proposal` + }) + } catch ({ message }) { + this.$store.commit(`notifyError`, { + title: `Error while submitting a new ${this.proposal_type.toLowercase()} proposal`, + body: message + }) + } + }, setSearch(bool = !this.filters[`proposals`].search.visible) { this.$store.commit(`setSearchVisible`, [`proposals`, bool]) } diff --git a/app/src/renderer/components/governance/PageProposal.vue b/app/src/renderer/components/governance/PageProposal.vue index c95ef26610..dd98374b15 100644 --- a/app/src/renderer/components/governance/PageProposal.vue +++ b/app/src/renderer/components/governance/PageProposal.vue @@ -47,10 +47,11 @@ tm-page(data-title='Proposal') modal-deposit( v-if="showModalDeposit" - v-on:castVote="deposit" - :showModalVote.sync="showModalVote" + v-on:submitDeposit="deposit" + :showModalDeposit.sync="showModalDeposit" :proposalId="proposal.proposal_id" :proposalTitle="proposal.title" + :denom="bondingDenom.toLowerCase()" ) modal-vote( diff --git a/app/src/renderer/components/governance/PageProposalsNewText.vue b/app/src/renderer/components/governance/PageProposalsNewText.vue deleted file mode 100644 index 800d0fc7d5..0000000000 --- a/app/src/renderer/components/governance/PageProposalsNewText.vue +++ /dev/null @@ -1,114 +0,0 @@ - - - diff --git a/app/src/renderer/components/governance/TableProposals.vue b/app/src/renderer/components/governance/TableProposals.vue index 80f6823fe7..312a052f25 100644 --- a/app/src/renderer/components/governance/TableProposals.vue +++ b/app/src/renderer/components/governance/TableProposals.vue @@ -141,7 +141,6 @@ export default { Mousetrap.bind([`command+f`, `ctrl+f`], () => this.setSearch(true)) Mousetrap.bind([`command+n`, `ctrl+n`], () => this.newProposal()) Mousetrap.bind(`esc`, () => this.setSearch(false)) - this.$store.dispatch(`getProposals`) } } diff --git a/test/unit/specs/components/governance/PageProposalsNewText.spec.js b/test/unit/specs/components/governance/PageProposalsNewText.spec.js deleted file mode 100644 index 93cfaf8a81..0000000000 --- a/test/unit/specs/components/governance/PageProposalsNewText.spec.js +++ /dev/null @@ -1,97 +0,0 @@ -import Node from "renderer/connectors/node" -import PageProposalsNewText from "renderer/components/governance/PageProposalsNewText" -import Store from "renderer/vuex/store" -import Vuelidate from "vuelidate" -import { createLocalVue, mount } from "@vue/test-utils" - -describe(`PageProposalsNewText`, () => { - let $store - let wrapper - - beforeEach(() => { - const localVue = createLocalVue() - localVue.use(Vuelidate) - - $store = { - dispatch: jest.fn(), - getters: { lastPage: null, user: { history: [] } } - } - - wrapper = mount(PageProposalsNewText, { - localVue, - mocks: { - $router: [], - $store - } - }) - }) - - it(`has the expected HTML structure`, () => { - expect(wrapper.vm.$el).toMatchSnapshot() - }) - - it(`onSubmit`, () => { - wrapper.setData({ - fields: { body: `description`, title: `proposal title` } - }) - - wrapper.vm.onSubmit() - - expect($store.dispatch.mock.calls).toEqual([ - [ - `submitProposal`, - { - description: `description`, - proposal_type: `Text`, - title: `proposal title` - } - ] - ]) - }) - - it(`sends the correct request to Gaia Lite`, done => { - const axios = async options => { - const { - data: { description, proposal_type, title }, - method, - url - } = options - - expect({ - data: { description, proposal_type, title }, - method, - url - }).toEqual({ - data: { - description: `description`, - proposal_type: `Text`, - title: `proposal title` - }, - method: `POST`, - url: `http://remotehost/gov/proposals` - }) - - done() - return { data: { check_tx: {}, deliver_tx: {} } } - } - - const node = Node(axios, `http://localhost`, `http://remotehost`) - const store = Store({ node }) - const localVue = createLocalVue() - localVue.use(Vuelidate) - - wrapper = mount(PageProposalsNewText, { - localVue, - mocks: { - $router: [] - }, - store - }) - - wrapper.setData({ - fields: { body: `description`, title: `proposal title` } - }) - - wrapper.vm.onSubmit() - }) -}) From 595908da305cc99e050eb3412c637824cf62809a Mon Sep 17 00:00:00 2001 From: Federico Kunze Date: Wed, 14 Nov 2018 15:32:30 +0100 Subject: [PATCH 02/27] minor tests fixes --- .../components/governance/ModalPropose.vue | 38 ++-- app/src/renderer/routes.js | 4 - .../__snapshots__/PageGovernance.spec.js.snap | 2 + .../PageProposalsNewText.spec.js.snap | 191 ------------------ 4 files changed, 26 insertions(+), 209 deletions(-) delete mode 100644 test/unit/specs/components/governance/__snapshots__/PageProposalsNewText.spec.js.snap diff --git a/app/src/renderer/components/governance/ModalPropose.vue b/app/src/renderer/components/governance/ModalPropose.vue index b40e2b5afb..e424169c84 100644 --- a/app/src/renderer/components/governance/ModalPropose.vue +++ b/app/src/renderer/components/governance/ModalPropose.vue @@ -50,18 +50,20 @@ diff --git a/app/src/renderer/components/governance/PageGovernance.vue b/app/src/renderer/components/governance/PageGovernance.vue index 6a96145a67..0d4bc520ae 100644 --- a/app/src/renderer/components/governance/PageGovernance.vue +++ b/app/src/renderer/components/governance/PageGovernance.vue @@ -3,11 +3,9 @@ tm-page(data-title='Governance').governance template(slot="menu-body") tm-balance(:tabs="tabs"): tm-btn#propose-btn(value="Create Proposal" color="secondary" @click.native="onPropose") - div(slot="menu"): vm-tool-bar - router-link(to="/governance/proposals/new" exact v-tooltip.bottom="'New Proposal'") - i.material-icons add - a(@click='setSearch()' v-tooltip.bottom="'Search'") - i.search.material-icons search + vm-tool-bar + a(@click='setSearch()' v-tooltip.bottom="'Search'") + i.search.material-icons search modal-search(type="proposals") modal-propose( diff --git a/app/src/renderer/components/staking/PageStaking.vue b/app/src/renderer/components/staking/PageStaking.vue index ee6e4054a8..f17fef20b5 100644 --- a/app/src/renderer/components/staking/PageStaking.vue +++ b/app/src/renderer/components/staking/PageStaking.vue @@ -3,11 +3,11 @@ tm-page(data-title="Staking").staking template(slot="menu-body") tm-balance(:tabs="tabs") - div(slot="menu"): vm-tool-bar - a(@click='connected && updateDelegates()' v-tooltip.bottom="'Refresh'" :disabled="!connected") - i.material-icons refresh - a(@click='setSearch()' v-tooltip.bottom="'Search'") - i.search.material-icons search + vm-tool-bar + a(@click='connected && updateDelegates()' v-tooltip.bottom="'Refresh'" :disabled="!connected") + i.material-icons refresh + a(@click='setSearch()' v-tooltip.bottom="'Search'") + i.search.material-icons search modal-search(type="delegates") diff --git a/app/src/renderer/components/wallet/PageTransactions.vue b/app/src/renderer/components/wallet/PageTransactions.vue index 110eefe86f..78766f9490 100644 --- a/app/src/renderer/components/wallet/PageTransactions.vue +++ b/app/src/renderer/components/wallet/PageTransactions.vue @@ -1,7 +1,7 @@