Veto contributions #113

Merged
raucao merged 5 commits from feature/98-veto_unconfirmed_contributions into master 2019-05-01 18:43:29 +00:00
6 changed files with 54 additions and 35 deletions
Showing only changes of commit 9821c8b2ea - Show all commits
+5 -1
View File
@@ -1,5 +1,9 @@
'use strict';
module.exports = {
extends: 'recommended'
extends: 'recommended',
rules: {
'simple-unless': false
}
};
+11 -11
View File
@@ -5,16 +5,16 @@ export default Component.extend({
tagName: 'ul',
classNames: ['contribution-list'],
// actions: {
//
// veto (contributionId) {
// if (this.contractInteractionEnabled) {
// this.vetoContribution(contributionId);
// } else {
// window.alert('Only members can veto contributions. Please ask someone to set you up.');
// }
// }
//
// }
actions: {
veto (contributionId) {
if (this.contractInteractionEnabled) {
this.vetoContribution(contributionId);
} else {
window.alert('Only members can veto contributions. Please ask someone to set you up.');
}
}
}
});
@@ -1,5 +1,5 @@
{{#each contributions as |contribution|}}
<li data-contribution-id={{contribution.id}} class={{if contribution.confirmed "confirmed" "unconfirmed"}}>
<li data-contribution-id={{contribution.id}} class={{contribution-status contribution}}>
<p class="meta">
raucao commented 2019-04-28 14:31:12 +00:00 (Migrated from github.com)
Review

This is a bit of a hack. It shouldn't required the if for the second class. But apparently with the helper, it doesn't bind the contribution property updates, so the value stays the same after setting the contribution vetoed to true. :/

@galfert @fsmanuel Any idea if that's an inherent limitation of helpers, or if I did something wrong?

This is a bit of a hack. It shouldn't required the `if` for the second class. But apparently with the helper, it doesn't bind the contribution property updates, so the value stays the same after setting the contribution `vetoed` to true. :/ @galfert @fsmanuel Any idea if that's an inherent limitation of helpers, or if I did something wrong?
galfert commented 2019-04-29 11:48:39 +00:00 (Migrated from github.com)
Review

Mmh, indeed it looks like when passing objects to a helper, it doesn't recalculate when one of the object's properties changes.

I see two options:

  1. Pass the two properties that the helper is using directly as parameters (contribution-status contribution.vetoed contribution.confirmedAt).

  2. Create a component for the contribution (e.g. contribution-item). This way the component can have a computed property for the class.

Mmh, indeed it looks like when passing objects to a helper, it doesn't recalculate when one of the object's properties changes. I see two options: 1. Pass the two properties that the helper is using directly as parameters (`contribution-status contribution.vetoed contribution.confirmedAt`). 2. Create a component for the contribution (e.g. `contribution-item`). This way the component can have a computed property for the class.
raucao commented 2019-04-29 12:16:35 +00:00 (Migrated from github.com)
Review

Thanks!

I think version 2 is better, but that it should be done when refactoring the UI soon. I think we'll want to use something like ember-boostrap instead of our handrolled everything, because otherwise we spend too much time re-inventing the wheel for all the various UI components.

Thanks! I think version 2 is better, but that it should be done when refactoring the UI soon. I think we'll want to use something like `ember-boostrap` instead of our handrolled everything, because otherwise we spend too much time re-inventing the wheel for all the various UI components.
galfert commented 2019-04-29 12:17:46 +00:00 (Migrated from github.com)
Review

I like version 2 better as well.

I like version 2 better as well.
<span class="recipient">{{user-avatar contributor=contribution.contributor}}</span>
<span class="category {{contribution.kind}}">({{contribution.kind}})</span>
@@ -14,5 +14,12 @@
<p class="kredits-amount">
<span class="amount">{{contribution.amount}}</span><span class="symbol">₭S</span>
</p>
{{#unless contribution.vetoed}}
{{#unless (is-confirmed-contribution contribution)}}
<p class="voting">
<button {{action "veto" contribution.id}} class="small danger">veto</button>
</p>
{{/unless}}
{{/unless}}
</li>
{{/each}}
+4 -4
View File
@@ -33,10 +33,10 @@ export default Controller.extend({
actions: {
vetoContribution (/* contributionId */) {
// this.kredits.vote(proposalId).then(transaction => {
// window.confirm('Vote submitted to Ethereum blockhain: '+transaction.hash);
// });
vetoContribution (contributionId) {
this.kredits.veto(contributionId).then(transaction => {
window.confirm('Veto submitted to Ethereum blockhain: '+transaction.hash);
});
},
confirmProposal (proposalId) {
+13 -2
View File
@@ -52,9 +52,10 @@ export default Service.extend({
});
}
function instantiateWithAccount (web3Provider, context) {
async function instantiateWithAccount (web3Provider, context) {
console.debug('[kredits] Using user-provided instance, e.g. from Mist browser or Metamask');
ethProvider = new ethers.providers.Web3Provider(web3Provider);
// const network = await ethProvider.getNetwork();
ethProvider.listAccounts().then(accounts => {
bumi commented 2019-05-01 18:25:24 +00:00 (Migrated from github.com)
Review

we can delete this comment.

we can delete this comment.
raucao commented 2019-05-01 18:38:36 +00:00 (Migrated from github.com)
Review

I left it there intentionally, so that I don't have to look up how to get to the network info of the external provider, and where to do that, when tackling #82. (Was going to do a drive-by PR for that, but defining which network is the right one isn't straight-forward.)

I left it there intentionally, so that I don't have to look up how to get to the network info of the external provider, and where to do that, when tackling #82. (Was going to do a drive-by PR for that, but defining which network is the right one isn't straight-forward.)
context.set('currentUserAccounts', accounts);
const ethSigner = accounts.length === 0 ? null : ethProvider.getSigner();
@@ -183,12 +184,22 @@ export default Service.extend({
console.debug('[kredits] vote for', proposalId);
return this.kredits.Proposal.functions.vote(proposalId)
.then((data) => {
.then(data => {
console.debug('[kredits] vote response', data);
return data;
});
},
veto(contributionId) {
console.debug('[kredits] veto against', contributionId);
return this.kredits.Contribution.functions.veto(contributionId)
.then(data => {
console.debug('[kredits] veto response', data);
return data;
});
},
getCurrentUser: computed('kredits.provider', function() {
if (isEmpty(this.currentUserAccounts)) {
return RSVP.resolve();
+13 -16
View File
@@ -20,14 +20,6 @@ ul.contribution-list {
font-size: 1.2rem;
border-bottom: 1px solid rgba(255,255,255,0.2);
&.unconfirmed {
grid-template-columns: auto 5rem 5rem;
}
&:first-of-type {
border-top: 1px solid rgba(255,255,255,0.2);
}
p {
align-self: center;
margin: 0;
@@ -37,14 +29,6 @@ ul.contribution-list {
&.kredits-amount, &.voting {
text-align: right;
}
// &.description {
// grid-column-start: span 2;
// }
// &.voting {
// grid-column-start: span 2;
// }
}
span {
@@ -96,6 +80,19 @@ ul.contribution-list {
color: $primary-color;
margin-right: 0.5rem;
}
&:first-of-type {
border-top: 1px solid rgba(255,255,255,0.2);
}
&.unconfirmed {
grid-template-columns: auto 5rem 5rem;
}
&.vetoed {
text-decoration: line-through;
opacity: 0.6;
}
}
}