Skip to content
This repository was archived by the owner on Oct 8, 2022. It is now read-only.

Commit 8ab191e

Browse files
committed
Treasury: fixed proposal list and submit proposal
1 parent 683e328 commit 8ab191e

File tree

4 files changed

+68
-41
lines changed

4 files changed

+68
-41
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<template>
2+
<b-field v-if="!accountLocked" label="password 🤫 magic spell" class="password-wrapper">
3+
<b-input :value="value" @input="handlePassword" type="password" password-reveal> </b-input>
4+
</b-field>
5+
</template>
6+
7+
<script lang="ts" >
8+
import { Component, Prop, Vue, Watch, Emit } from 'vue-property-decorator';
9+
import keyring from '@polkadot/ui-keyring';
10+
11+
@Component
12+
export default class PasswordInput extends Vue {
13+
private accountLocked: boolean = false;
14+
15+
@Prop() public value!: string;
16+
@Prop({ default: '' }) public account!: string;
17+
18+
public mounted() {
19+
if (this.account) {
20+
try {
21+
// TODO: missing isLocked from vue-keyring
22+
const acc = keyring.getAccount(this.account)
23+
} catch(err) {
24+
console.warn('[Password] unable to get account', err)
25+
}
26+
27+
28+
}
29+
}
30+
31+
32+
@Emit('input')
33+
private handlePassword(password: string) {
34+
return password;
35+
}
36+
37+
}
38+
</script>

dashboard/src/components/shared/modals/Proposal.vue

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
<template>
22
<ModalWrapper label="Add Proposal" icon="plus">
33
<div>
4-
<Dropdown mode="accounts" @selected="handleAccountSelection" />
5-
<Dropdown mode="accounts" @selected="handleBeneficiary" />
6-
<BalanceInput v-model="value" />
7-
<b-field label="password 🤫 magic spell" class="password-wrapper">
8-
<b-input v-model="password" type="password" password-reveal> </b-input>
9-
</b-field>
10-
4+
<AccountSelect label="submit with account" v-model="accountId" />
5+
<AccountSelect label="beneficiary" v-model="beneficiaryId" />
6+
<BalanceInput v-model="amount" />
7+
<PasswordInput v-model="password" />
118
<b-button
129
type="is-primary"
1310
icon-left="paper-plane"
@@ -30,53 +27,47 @@ import { KeyringPair } from '@polkadot/keyring/types';
3027
import { notificationTypes, showNotification } from '@/utils/notification';
3128
import exec from '@/utils/transactionExecutor';
3229
import { urlBuilderTransaction } from '@/utils/explorerGuide';
33-
import C from '@vue-polkadot/vue-api'
34-
import BalanceInput from '@/components/shared/BalanceInput.vue'
30+
import Connector from '@vue-polkadot/vue-api';
31+
import BalanceInput from '@/components/shared/BalanceInput.vue';
32+
import AccountSelect from '@/components/shared/AccountSelect.vue'
33+
import PasswordInput from '@/components/shared/PasswordInput.vue';
3534
3635
@Component({
3736
components: {
3837
ModalWrapper,
39-
Dropdown,
38+
AccountSelect,
4039
BalanceInput,
40+
PasswordInput
4141
},
4242
})
4343
export default class ProposalModal extends Vue {
44-
private account: any = {};
44+
private accountId: string = '';
45+
private beneficiaryId: string = '';
4546
private password: string = '';
4647
private beneficiary: any = {};
47-
private value: number = 0;
48+
private amount: number = 0;
4849
49-
50-
51-
public handleAccountSelection(account: KeyringPair) {
52-
this.account = account;
53-
}
54-
55-
public handleBeneficiary(account: KeyringPair) {
56-
console.log(account.address)
57-
this.beneficiary = account;
58-
}
59-
6050
public async shipIt() {
61-
const { api } = C.getInstance()
51+
const { api } = Connector.getInstance();
6252
6353
if (!api) {
6454
return;
6555
}
6656
6757
try {
68-
const { value, beneficiary } = this;
69-
showNotification('Dispatched');
70-
const tx = await exec(this.account, this.password, api.tx.treasury.proposeSpend, [value, beneficiary.address]);
71-
// showNotification(`Second ${referendumId.toString()}`, { ...notificationTypes.success, onAction: this.onAction() });
58+
const { amount, beneficiaryId, accountId, password } = this;
59+
showNotification('Dispatched new proposal');
60+
console.log({ amount, beneficiaryId, accountId, password })
61+
const tx = await exec(accountId, password, api.tx.treasury.proposeSpend, [amount, beneficiaryId]);
62+
showNotification('Success', notificationTypes.success );
7263
} catch (e) {
7364
showNotification(e, notificationTypes.danger);
7465
}
7566
7667
}
7768
7869
get disabled() {
79-
return !this.account || !this.password || !this.beneficiary || !this.value
70+
return !this.accountId || !this.beneficiary || !this.amount
8071
}
8172
8273
}

dashboard/src/components/treasury/Proposal.vue

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<template>
22
<ItemCard>
3-
<div class="column is-0 proposal-index__main">
3+
<div class="column is-1 proposal-index__main">
44
{{ proposal.id | toNumber }}
55
</div>
6-
<div class="column is-4 proposal-adress__overflow">
6+
<div class="column is-3 proposal-adress__overflow">
77
<WithLabel label="Proposer"><div>{{ proposal.proposal.proposer | toString }}</div></WithLabel>
88

99
</div>
10-
<div class="column is-4 proposal-adress__overflow">
10+
<div class="column is-3 proposal-adress__overflow">
1111
<WithLabel label="Beneficiary"><div>{{ proposal.proposal.beneficiary | toString }}</div></WithLabel>
1212

1313
</div>
14-
<div class="column is-1">
15-
<WithLabel label="Payment"><Money :value="2000000000000000" /></WithLabel>
14+
<div class="column is-2">
15+
<WithLabel label="Payment"><Money :value="proposal.proposal.value" /></WithLabel>
1616
</div>
1717
<div class="column is-1">
18-
<WithLabel label="Bond"><Money :value="100000000000000" /></WithLabel>
18+
<WithLabel label="Bond"><Money :value="proposal.proposal.bond" /></WithLabel>
1919
</div>
2020
<div class="column is-2 ">
21-
<b-button class="proposal-button__action" is-primary disabled
21+
<b-button class="proposal-button__action" is-primary disabled icon-left="step-forward"
2222
>To Council</b-button
2323
>
2424
</div>
@@ -60,8 +60,6 @@ export default class Proposal extends Vue {
6060
} */
6161
6262
.proposal-adress__overflow {
63-
white-space: nowrap;
64-
overflow: hidden;
65-
text-overflow: ellipsis;
63+
word-break: break-word;
6664
}
6765
</style>

dashboard/src/icons.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
faArrowUp, faTools, faCheck, faSeedling, faDatabase, faGem,
1313
faInfoCircle, faExchangeAlt, faBug, faStop, faEllipsisV, faPercent,
1414
faUsersCog, faCoins, faAngleLeft, faAngleRight,
15-
faCreditCard
15+
faCreditCard, faStepForward
1616
} from '@fortawesome/free-solid-svg-icons';
1717

1818
import { faTwitter } from '@fortawesome/free-brands-svg-icons';
@@ -30,7 +30,7 @@ library.add(faTrash, faKey, faSync, faRedo,
3030
faTwitter, faArrowUp, faTools, faCheck, faSeedling,
3131
faDatabase, faGem, faInfoCircle, faExchangeAlt,
3232
faBug, faStop, faEllipsisV, faPercent, faUsersCog, faCoins,
33-
faAngleLeft, faAngleRight, faCreditCard
33+
faAngleLeft, faAngleRight, faCreditCard, faStepForward
3434
);
3535

3636
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';

0 commit comments

Comments
 (0)