diff --git a/.editorconfig b/.editorconfig index 219985c..c35a002 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,7 +4,6 @@ root = true - [*] end_of_line = lf charset = utf-8 diff --git a/.eslintrc.js b/.eslintrc.js index 0fdd421..9f3cfc9 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,8 +1,14 @@ +'use strict'; + module.exports = { root: true, + parser: 'babel-eslint', parserOptions: { ecmaVersion: 2018, - sourceType: 'module' + sourceType: 'module', + ecmaFeatures: { + legacyDecorators: true + } }, globals: { console: true @@ -19,7 +25,10 @@ module.exports = { }, rules: { 'ember/avoid-leaking-state-in-ember-objects': 'warn', - 'no-console': 'off' + 'no-console': 'off', + 'ember/no-jquery': 'error', + 'ember/require-computed-property-dependencies': 'warn', + 'ember/no-observers': 'warn' }, overrides: [ // node files @@ -35,8 +44,7 @@ module.exports = { 'server/**/*.js' ], parserOptions: { - sourceType: 'script', - ecmaVersion: 2015 + sourceType: 'script' }, env: { browser: false, diff --git a/.template-lintrc.js b/.template-lintrc.js index f9345c8..5e45040 100644 --- a/.template-lintrc.js +++ b/.template-lintrc.js @@ -1,10 +1,93 @@ 'use strict'; module.exports = { - extends: 'recommended', + extends: 'octane', rules: { 'simple-unless': false, 'no-nested-interactive': false - } + }, + + ignore: [ + 'kredits-web/templates/components/**', + 'app/templates/components/**' + ], + + pending: [ + { + "moduleId": "app/templates/dashboard", + "only": [ + "no-action" + ] + }, + { + "moduleId": "app/components/add-contribution/template", + "only": [ + "no-action", + "no-curly-component-invocation" + ] + }, + { + "moduleId": "app/components/add-contributor/template", + "only": [ + "no-action", + "no-curly-component-invocation" + ] + }, + { + "moduleId": "app/components/contribution-list/template", + "only": [ + "no-action", + "no-curly-component-invocation" + ] + }, + { + "moduleId": "app/components/contributor-list/template", + "only": [ + "no-action" + ] + }, + { + "moduleId": "app/components/topbar-account-panel/template", + "only": [ + "no-action" + ] + }, + { + "moduleId": "app/templates/contributions/new", + "only": [ + "no-action" + ] + }, + { + "moduleId": "app/templates/contributions/resubmit", + "only": [ + "no-action" + ] + }, + { + "moduleId": "app/templates/contributors/edit", + "only": [ + "no-action" + ] + }, + { + "moduleId": "app/templates/contributors/new", + "only": [ + "no-action" + ] + }, + { + "moduleId": "app/templates/signup/eth-account", + "only": [ + "no-action" + ] + }, + { + "moduleId": "app/templates/signup/index", + "only": [ + "no-action" + ] + } + ] }; diff --git a/.travis.yml b/.travis.yml index eda3f73..db3b0cc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,9 @@ env: # See https://git.io/vdao3 for details. - JOBS=1 +branches: + only: + - master + script: - - npm run lint:hbs - - npm run lint:js - npm test diff --git a/app/app.js b/app/app.js index b3b2bd6..d8e2088 100644 --- a/app/app.js +++ b/app/app.js @@ -1,14 +1,12 @@ import Application from '@ember/application'; -import Resolver from './resolver'; +import Resolver from 'ember-resolver'; import loadInitializers from 'ember-load-initializers'; import config from './config/environment'; -const App = Application.extend({ - modulePrefix: config.modulePrefix, - podModulePrefix: config.podModulePrefix, - Resolver -}); +export default class App extends Application { + modulePrefix = config.modulePrefix; + podModulePrefix = config.podModulePrefix; + Resolver = Resolver; +} loadInitializers(App, config.modulePrefix); - -export default App; diff --git a/app/components/add-contribution/component.js b/app/components/add-contribution/component.js index 19247a8..56de353 100644 --- a/app/components/add-contribution/component.js +++ b/app/components/add-contribution/component.js @@ -45,7 +45,9 @@ export default Component.extend({ actions: { - submit () { + submit (evt) { + evt.preventDefault(); + if (!this.isValid) { alert('Invalid data. Please review and try again.'); return; diff --git a/app/components/add-contribution/template.hbs b/app/components/add-contribution/template.hbs index 2174967..ab7b930 100644 --- a/app/components/add-contribution/template.hbs +++ b/app/components/add-contribution/template.hbs @@ -1,11 +1,11 @@ -
+ @@ -42,33 +42,33 @@

{{input type="text" placeholder="500" - value=amount - class=(if isValidAmount "valid" "")}} + value=this.amount + class=(if this.isValidAmount "valid" "")}}

- {{#if details}} + {{#if this.details}} @@ -76,8 +76,8 @@

{{input type="submit" - disabled=inProgress - value=(if inProgress "Processing" "Save")}} + disabled=this.inProgress + value=(if this.inProgress "Processing" "Save")}}

diff --git a/app/components/add-contributor/component.js b/app/components/add-contributor/component.js index 346135a..d2a9535 100644 --- a/app/components/add-contributor/component.js +++ b/app/components/add-contributor/component.js @@ -7,8 +7,8 @@ import { isAddress } from 'web3-utils'; export default Component.extend({ - kredits: service(), router: service(), + kredits: service(), attributes: null, @@ -60,9 +60,15 @@ export default Component.extend({ actions: { - submit () { + submit (evt) { + evt.preventDefault(); + + if (!this.kredits.currentUserIsCore) { + window.alert('Only core team members can edit profiles. Please ask someone to set you up.'); + return; + } if (!this.isValid) { - alert('Invalid data. Please review and try again.'); + window.alert('Invalid data. Please review and try again.'); return; } diff --git a/app/components/add-contributor/template.hbs b/app/components/add-contributor/template.hbs index 8eceeee..8478db6 100644 --- a/app/components/add-contributor/template.hbs +++ b/app/components/add-contributor/template.hbs @@ -1,55 +1,56 @@ -
+

- {{input name="account" id="c-account" - type="text" value=account - placeholder="0xF18E631Ea191aE4ebE70046Fcb01a436554421BA4" - class=(if isValidAccount "valid" "")}} +

- + +

- {{input name="name" type="text" value=name placeholder="Zero Cool" - class=(if isValidName "valid" "") id="c-name"}} + {{input name="name" type="text" value=this.name placeholder="Zero Cool" + class=(if this.isValidName "valid" "") id="c-name"}}

- {{input name="url" type="text" value=url placeholder="http://zerocool.bit" - class=(if isValidURL "valid" "") id="c-url"}} + {{input name="url" type="text" value=this.url placeholder="http://zerocool.bit" + class=(if this.isValidURL "valid" "") id="c-url"}}

- {{input name="github_uid" type="text" value=github_uid placeholder="2342" - class=(if isValidGithubUID "valid" "") id="c-github-uid"}} + {{input name="github_uid" type="text" value=this.github_uid placeholder="2342" + class=(if this.isValidGithubUID "valid" "") id="c-github-uid"}}

- {{input name="github_username" type="text" value=github_username placeholder="zerocool" - class=(if isValidGithubUsername "valid" "") id="c-github-username"}} + {{input name="github_username" type="text" value=this.github_username placeholder="zerocool" + class=(if this.isValidGithubUsername "valid" "") id="c-github-username"}}

- {{input name="gitea_username" type="text" value=gitea_username placeholder="zerocool" - class=(if isValidGiteaUsername "valid" "") id="c-gitea-username"}} + {{input name="gitea_username" type="text" value=this.gitea_username placeholder="zerocool" + class=(if this.isValidGiteaUsername "valid" "") id="c-gitea-username"}}

- {{input name="wiki_username" type="text" value=wiki_username placeholder="ZeroCool" - class=(if isValidWikiUsername "valid" "") id="c-wiki-username"}} + {{input name="wiki_username" type="text" value=this.wiki_username placeholder="ZeroCool" + class=(if this.isValidWikiUsername "valid" "") id="c-wiki-username"}}

- {{input name="zoom_display_name" type="text" value=zoom_display_name placeholder="Zero Cool" - class=(if isValidZoomDisplayName "valid" "") id="c-zoom-display-name"}} + {{input name="zoom_display_name" type="text" value=this.zoom_display_name placeholder="Zero Cool" + class=(if this.isValidZoomDisplayName "valid" "") id="c-zoom-display-name"}}

- {{input type="submit" disabled=inProgress - value=(if inProgress "Processing" "Save")}} + {{input type="submit" disabled=this.inProgress + value=(if this.inProgress "Processing" "Save")}}

diff --git a/app/components/add-proposal/component.js b/app/components/add-proposal/component.js deleted file mode 100644 index 2e65fdf..0000000 --- a/app/components/add-proposal/component.js +++ /dev/null @@ -1,64 +0,0 @@ -import Component from '@ember/component'; -import { computed } from '@ember/object'; -import { and, notEmpty } from '@ember/object/computed'; - -export default Component.extend({ - - attributes: null, - contributors: Object.freeze([]), - - isValidContributor: notEmpty('contributorId'), - isValidAmount: computed('amount', function() { - return parseInt(this.amount, 10) > 0; - }), - isValidDescription: notEmpty('description'), - isValidUrl: notEmpty('url'), - isValid: and('isValidContributor', - 'isValidAmount', - 'isValidDescription'), - - init () { - this._super(...arguments); - - // Default attributes used by reset - this.set('attributes', { - contributorId: null, - kind: 'community', - amount: null, - description: null, - url: null, - }); - }, - - didInsertElement() { - this._super(...arguments); - this.reset(); - }, - - reset: function() { - this.setProperties(this.attributes); - }, - - actions: { - submit() { - if (!this.isValid) { - alert('Invalid data. Please review and try again.'); - return; - } - - let attributes = Object.keys(this.attributes); - let proposal = this.getProperties(attributes); - let saved = this.save(proposal); - - // The promise handles inProgress - this.set('inProgress', saved); - - saved.then(() => { - this.reset(); - window.scroll(0,0); - window.alert('Proposal added.'); - }); - } - } - -}); diff --git a/app/components/add-proposal/template.hbs b/app/components/add-proposal/template.hbs deleted file mode 100644 index 4cf6f21..0000000 --- a/app/components/add-proposal/template.hbs +++ /dev/null @@ -1,44 +0,0 @@ -
-

- -

-

- -

-

- {{input type="text" - placeholder="100" - value=amount - class=(if isValidAmount "valid" "")}} -

-

- {{input type="text" - placeholder="Description" - value=description - class=(if isValidDescription "valid" "")}} -

-

- {{input type="text" - placeholder="URL (optional)" - value=url - class=(if isValidUrl "valid" "")}} -

-

- {{input type="submit" - disabled=(is-pending inProgress) - value=(if (is-pending inProgress) "Processing" "Save")}} - {{#link-to "index"}}Back{{/link-to}} -

-
- diff --git a/app/components/chart-contributions-by-type/template.hbs b/app/components/chart-contributions-by-type/template.hbs index 56f2b44..da4906f 100644 --- a/app/components/chart-contributions-by-type/template.hbs +++ b/app/components/chart-contributions-by-type/template.hbs @@ -1,7 +1,6 @@
- {{ember-chart type="doughnut" - data=chartData - options=chartOptions - width=200 - height=200}} +
\ No newline at end of file diff --git a/app/components/contribution-list/component.js b/app/components/contribution-list/component.js index ceebc4a..e297444 100644 --- a/app/components/contribution-list/component.js +++ b/app/components/contribution-list/component.js @@ -24,12 +24,10 @@ export default Component.extend({ contributors: sort('kredits.contributors', 'contributorsSorting'), contributorsActive: computed('contributors.[]', 'contributions', function() { - let activeIds = this.contributions.mapBy('contributorId') - .map(id => id.toString()) - .uniq(); - return this.contributors.filter(c => { - return activeIds.includes(c.id.toString()); - }); + const activeIds = new Set(this.contributions.mapBy('contributorId') + .map(id => id.toString())); + + return this.contributors.filter(c => activeIds.has(c.id.toString())); }), contributionKinds: computed('contributions.[]', function() { diff --git a/app/components/contribution-list/template.hbs b/app/components/contribution-list/template.hbs index 49419cb..87d2349 100644 --- a/app/components/contribution-list/template.hbs +++ b/app/components/contribution-list/template.hbs @@ -1,28 +1,28 @@ -{{#if showQuickFilter}} +{{#if @showQuickFilter}}

@@ -30,12 +30,12 @@ {{/if}}