[WIP] Update Ember to version 3.8.0 #88

Closed
galfert wants to merge 2 commits from feature/84-update_ember into master
16 changed files with 112 additions and 72 deletions
+25 -18
View File
@@ -1,27 +1,12 @@
import Component from '@ember/component';
import { and, notEmpty } from '@ember/object/computed';
import { inject as injectService } from '@ember/service';
import { inject as service } from '@ember/service';
export default Component.extend({
kredits: injectService(),
kredits: service(),
// Default attributes used by reset
attributes: {
account: null,
name: null,
kind: 'person',
url: null,
github_username: null,
github_uid: null,
wiki_username: null,
isCore: false,
},
didInsertElement() {
this._super(...arguments);
this.reset();
},
attributes: null,
// TODO: add proper address validation
isValidAccount: notEmpty('account'),
@@ -36,6 +21,27 @@ export default Component.extend({
'isValidGithubUID'
),
init () {
this._super(...arguments);
// Default attributes used by reset
this.set('attributes', {
account: null,
name: null,
kind: 'person',
url: null,
github_username: null,
github_uid: null,
wiki_username: null,
isCore: false
});
},
didInsertElement() {
this._super(...arguments);
this.reset();
},
reset: function() {
this.setProperties(this.attributes);
},
@@ -61,4 +67,5 @@ export default Component.extend({
});
}
}
});
+7 -7
View File
@@ -13,7 +13,7 @@
type="text"
placeholder="0xF18E631Ea191aE4ebE70046Fcb01a436554421BA4"
value=account
class=(if isValidAccount 'valid' '')}}
class=(if isValidAccount "valid" "")}}
</p>
<p>
<select required onchange={{action (mut kind) value="target.value"}}>
@@ -26,39 +26,39 @@
type="text"
placeholder="Name"
value=name
class=(if isValidName 'valid' '')}}
class=(if isValidName "valid" "")}}
</p>
<p>
{{input name="url"
type="text"
placeholder="URL"
value=url
class=(if isValidURL 'valid' '')}}
class=(if isValidURL "valid" "")}}
</p>
<p>
{{input name="github_uid"
type="text"
placeholder="GitHub UID (123)"
value=github_uid
class=(if isValidGithubUID 'valid' '')}}
class=(if isValidGithubUID "valid" "")}}
</p>
<p>
{{input name="github_username"
type="text"
placeholder="GitHub username"
value=github_username
class=(if isValidGithubUsername 'valid' '')}}
class=(if isValidGithubUsername "valid" "")}}
</p>
<p>
{{input name="wiki_username"
type="text"
placeholder="Wiki Username"
value=wiki_username
class=(if isValidWikiUsername 'valid' '')}}
class=(if isValidWikiUsername "valid" "")}}
</p>
<p class="actions">
{{input type="submit"
disabled=(is-pending inProgress)
value=(if (is-pending inProgress) 'Processing' 'Save')}}
value=(if (is-pending inProgress) "Processing" "Save")}}
</p>
</form>
+23 -14
View File
@@ -3,21 +3,9 @@ import { computed } from '@ember/object';
import { and, notEmpty } from '@ember/object/computed';
export default Component.extend({
// Default attributes used by reset
attributes: {
contributorId: null,
kind: 'community',
amount: null,
description: null,
url: null,
},
didInsertElement() {
this._super(...arguments);
this.reset();
},
contributors: [],
attributes: null,
contributors: null,
isValidContributor: notEmpty('contributorId'),
isValidAmount: computed('amount', function() {
@@ -29,6 +17,26 @@ export default Component.extend({
'isValidAmount',
'isValidDescription'),
init () {
this._super(...arguments);
// Default attributes used by reset
this.set('attributes', {
contributorId: null,
kind: 'community',
amount: null,
description: null,
url: null,
});
this.set('contributors', []);
},
didInsertElement() {
this._super(...arguments);
this.reset();
},
reset: function() {
this.setProperties(this.attributes);
},
@@ -54,4 +62,5 @@ export default Component.extend({
});
}
}
});
+5 -5
View File
@@ -20,25 +20,25 @@
{{input type="text"
placeholder="100"
value=amount
class=(if isValidAmount 'valid' '')}}
class=(if isValidAmount "valid" "")}}
</p>
<p>
{{input type="text"
placeholder="Description"
value=description
class=(if isValidDescription 'valid' '')}}
class=(if isValidDescription "valid" "")}}
</p>
<p>
{{input type="text"
placeholder="URL (optional)"
value=url
class=(if isValidUrl 'valid' '')}}
class=(if isValidUrl "valid" "")}}
</p>
<p class="actions">
{{input type="submit"
disabled=(is-pending inProgress)
value=(if (is-pending inProgress) 'Processing' 'Save')}}
{{#link-to 'index'}}Back{{/link-to}}
value=(if (is-pending inProgress) "Processing" "Save")}}
{{#link-to "index"}}Back{{/link-to}}
</p>
</form>
@@ -12,6 +12,17 @@ let categoryColors = {
export default Component.extend({
contributions: null,
chartOptions: null,
init () {
this._super(...arguments);
this.set('chartOptions', {
raucao commented 2019-03-27 15:03:19 +00:00 (Migrated from github.com)
Review

I think the Ember way to set hardcoded object properties is actually Object.freeze() in the normal property definition, as opposed to this way.

I think the Ember way to set hardcoded object properties is actually `Object.freeze()` in the normal property definition, as opposed to this way.
galfert commented 2019-03-27 16:53:34 +00:00 (Migrated from github.com)
Review

So the chartOptions are not supposed to be changed at any point? Then we can use Object.freeze() instead.

So the `chartOptions` are not supposed to be changed at any point? Then we can use `Object.freeze()` instead.
galfert commented 2019-03-27 17:25:44 +00:00 (Migrated from github.com)
Review

Changed it in the new PR (#89).

Changed it in the new PR (#89).
legend: {
display: false
}
});
},
chartData: computed('contributions', function() {
let kredits = this.contributions
@@ -52,12 +63,6 @@ export default Component.extend({
'Documentation'
],
}
}),
chartOptions: {
legend: {
display: false
}
}
})
});
@@ -1,5 +1,5 @@
<div class="chart">
{{ember-chart type='doughnut'
{{ember-chart type="doughnut"
data=chartData
options=chartOptions
width=200
+3 -3
View File
@@ -1,8 +1,8 @@
<tbody>
{{#each contributors as |contributor|}}
<tr class="{{if contributor.isCurrentUser 'current-user'}}" {{action "toggleContributorInfo" contributor}}>
<tr role="button" class={{if contributor.isCurrentUser "current-user"}} {{action "toggleContributorInfo" contributor}}>
<td class="person">
<img class="avatar" src={{contributor.avatarURL}}>
<img class="avatar" src={{contributor.avatarURL}} alt="">
{{contributor.name}}
</td>
<td class="kredits">
@@ -10,7 +10,7 @@
<span class="symbol">₭S</span>
</td>
</tr>
<tr class="metadata {{if contributor.isCurrentUser 'current-user'}} {{if contributor.showMetadata 'visible'}}">
<tr class="metadata {{if contributor.isCurrentUser "current-user"}} {{if contributor.showMetadata "visible"}}">
<td colspan="2">
<ul>
<li><a href="https://testnet.etherscan.io/address/{{contributor.account}}">Inspect Ethereum transactions</a></li>
+2 -2
View File
@@ -1,6 +1,6 @@
import Controller from '@ember/controller';
import { inject as injectService } from '@ember/service';
import { inject as service } from '@ember/service';
export default Controller.extend({
kredits: injectService(),
kredits: service(),
});
+4 -4
View File
@@ -1,21 +1,21 @@
import Controller from '@ember/controller';
import { alias, filter, filterBy, sort } from '@ember/object/computed';
import { inject as injectService } from '@ember/service';
import { inject as service } from '@ember/service';
export default Controller.extend({
kredits: injectService(),
kredits: service(),
contributors: alias('kredits.contributors'),
contributorsWithKredits: filter('contributors', function(contributor) {
return contributor.get('balance') !== 0;
}),
contributorsSorting: ['balance:desc'],
contributorsSorting: Object.freeze(['balance:desc']),
contributorsSorted: sort('contributorsWithKredits', 'contributorsSorting'),
proposals: alias('kredits.proposals'),
proposalsOpen: filterBy('proposals', 'isExecuted', false),
proposalsClosed: filterBy('proposals', 'isExecuted', true),
proposalsSorting: ['id:desc'],
proposalsSorting: Object.freeze(['id:desc']),
proposalsClosedSorted: sort('proposalsClosed', 'proposalsSorting'),
proposalsOpenSorted: sort('proposalsOpen', 'proposalsSorting'),
+2 -2
View File
@@ -1,9 +1,9 @@
import Controller from '@ember/controller';
import { alias, filterBy } from '@ember/object/computed';
import { inject as injectService } from '@ember/service';
import { inject as service } from '@ember/service';
export default Controller.extend({
kredits: injectService(),
kredits: service(),
contributors: alias('kredits.contributors'),
minedContributors: filterBy('contributors', 'id'),
+8 -1
View File
@@ -3,6 +3,7 @@ import { alias } from '@ember/object/computed';
import bignumber from 'kredits-web/utils/cps/bignumber';
export default EmberObject.extend({
// Contract
id: bignumber('idRaw', 'toString'),
creatorAccount: null,
@@ -19,7 +20,13 @@ export default EmberObject.extend({
// IPFS
kind: null,
description: null,
details: {},
details: null,
url: null,
ipfsData: '',
init () {
this._super(...arguments);
this.set('details', {});
}
});
+2 -2
View File
@@ -1,8 +1,8 @@
import { inject as injectService } from '@ember/service';
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
export default Route.extend({
kredits: injectService(),
kredits: service(),
beforeModel(transition) {
const kredits = this.kredits;
+8 -3
View File
@@ -16,6 +16,8 @@ export default Service.extend({
currentUserAccounts: null, // default to not having an account. this is the wen web3 is loaded.
currentUser: null,
contributors: null,
proposals: null,
currentUserIsContributor: notEmpty('currentUser'),
currentUserIsCore: alias('currentUser.isCore'),
hasAccounts: notEmpty('currentUserAccounts'),
@@ -23,6 +25,12 @@ export default Service.extend({
return this.currentUserAccounts && isEmpty(this.currentUserAccounts);
}),
init () {
this._super(...arguments);
this.set('contributors', []);
this.set('proposals', []);
},
// this is called in the routes beforeModel(). So it is initialized before everything else
// and we can rely on the ethProvider and the potential currentUserAccounts to be available
getEthProvider: function() {
@@ -84,9 +92,6 @@ export default Service.extend({
return this.kredits.Token.functions.totalSupply();
}),
contributors: [],
proposals: [],
loadContributorsAndProposals() {
return this.getContributors()
.then(contributors => this.contributors.pushObjects(contributors))
+2 -2
View File
@@ -52,7 +52,7 @@
{{!-- TODO: We need a better naming --}}
{{#if kredits.hasAccounts}}
<p class="actions">
{{#link-to 'proposals.new'}}Create new proposal{{/link-to}}
{{#link-to "proposals.new"}}Create new proposal{{/link-to}}
</p>
{{/if}}
</section>
@@ -66,7 +66,7 @@
<div class="content">
{{#if kredits.currentUser.isCore}}
{{add-contributor contributors=contributors save=(action 'save')}}
{{add-contributor contributors=contributors save=(action "save")}}
{{else}}
Only core team members can add new contributors. Please ask someone to set you up.
{{/if}}
+1 -1
View File
@@ -4,7 +4,7 @@
</header>
<div class="content">
{{add-proposal contributors=minedContributors save=(action 'save')}}
{{add-proposal contributors=minedContributors save=(action "save")}}
</div>
</section>
+7
View File
@@ -0,0 +1,7 @@
github id: 843
ether address: 0xD4a64570B12dA659Ee4BBd41c3509B7b1F9c51AC (Metamask)
0x0020e20e6C9ACc0c9fE78Fcb6a427Ad0cC8aca18 (Parity)
0xD4a64570B12dA659Ee4BBd41c3509B7b1F9c51AC (kosmos parity)
raucao commented 2019-03-27 15:05:07 +00:00 (Migrated from github.com)
Review

Is this a personal notes file that was accidentally committed?

Is this a personal notes file that was accidentally committed?
galfert commented 2019-03-27 16:50:35 +00:00 (Migrated from github.com)
Review

Damn, yes. This wasn't supposed to be committed.

Damn, yes. This wasn't supposed to be committed.