From c7d046aa464bff9d098444bdc4e981381407311f Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Thu, 18 Jul 2019 19:26:16 +0200 Subject: [PATCH 01/12] Move topbar account info to component, add tests Adds a failing test for users with wallet, but no known contributor account, where it currently shows no name at all. --- .../topbar-account-panel/component.js | 10 +++++ .../topbar-account-panel/template.hbs | 12 ++++++ app/templates/application.hbs | 12 +----- .../topbar-account-panel/component-test.js | 39 +++++++++++++++++++ 4 files changed, 62 insertions(+), 11 deletions(-) create mode 100644 app/components/topbar-account-panel/component.js create mode 100644 app/components/topbar-account-panel/template.hbs create mode 100644 tests/integration/components/topbar-account-panel/component-test.js diff --git a/app/components/topbar-account-panel/component.js b/app/components/topbar-account-panel/component.js new file mode 100644 index 0000000..2a5c942 --- /dev/null +++ b/app/components/topbar-account-panel/component.js @@ -0,0 +1,10 @@ +import Component from '@ember/component'; +import { inject as service } from '@ember/service'; + +export default Component.extend({ + + tagName: '', + + kredits: service(), + +}); diff --git a/app/components/topbar-account-panel/template.hbs b/app/components/topbar-account-panel/template.hbs new file mode 100644 index 0000000..b65983a --- /dev/null +++ b/app/components/topbar-account-panel/template.hbs @@ -0,0 +1,12 @@ +
+ {{#if kredits.hasAccounts }} + {{#if kredits.currentUser}} + {{kredits.currentUser.name}} + {{#if kredits.currentUserIsCore}} + (core) + {{/if}} + {{/if}} + {{else}} + Anonymous + {{/if}} +
\ No newline at end of file diff --git a/app/templates/application.hbs b/app/templates/application.hbs index d82b972..11b8e12 100644 --- a/app/templates/application.hbs +++ b/app/templates/application.hbs @@ -1,16 +1,6 @@

{{link-to "Kosmos Kredits" "dashboard"}}

- -
- {{#if kredits.hasAccounts }} - {{#if kredits.currentUser}} - {{kredits.currentUser.name}} - {{#if kredits.currentUserIsCore}}(core){{/if}} - {{/if}} - {{else}} - Anonymous - {{/if}} -
+ {{topbar-account-panel}}
{{outlet}} diff --git a/tests/integration/components/topbar-account-panel/component-test.js b/tests/integration/components/topbar-account-panel/component-test.js new file mode 100644 index 0000000..b6054ab --- /dev/null +++ b/tests/integration/components/topbar-account-panel/component-test.js @@ -0,0 +1,39 @@ +import { module, test } from 'qunit'; +import { setupRenderingTest } from 'ember-qunit'; +import { render } from '@ember/test-helpers'; +import hbs from 'htmlbars-inline-precompile'; + +module('Integration | Component | topbar-account-panel', function(hooks) { + setupRenderingTest(hooks); + + test('unknown user without wallet (or no permission to get wallet/account info)', async function(assert) { + await render(hbs``); + + assert.equal(this.element.textContent.trim(), 'Anonymous'); + }); + + test('unknown user with Ethereum wallet', async function(assert) { + let service = this.owner.lookup('service:kredits'); + service.set('currentUserAccounts', [{ foo: 'bar' }]); + await render(hbs``); + + assert.equal(this.element.textContent.trim(), 'Anonymous'); + }); + + test('known contributor', async function(assert) { + let service = this.owner.lookup('service:kredits'); + service.set('currentUserAccounts', [{ foo: 'bar' }]); + service.set('currentUser', { + name: 'Dorian Nakamoto', + isCore: false + }); + await render(hbs``); + + assert.equal(this.element.textContent.trim(), 'Dorian Nakamoto'); + + service.set('currentUser.isCore', true); + await render(hbs``); + + assert.equal(this.element.querySelectorAll('span.core-flag').length, 1); + }); +}); From 6a176b59049f2240c564194aea7ef4929b643c8c Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Thu, 18 Jul 2019 19:27:53 +0200 Subject: [PATCH 02/12] Fix empty name in account info When the user brings Ethereum accounts, but none of them is known as contributor, instead of "Anonymous" it just shows nothing. This fixes the if condition in the template to eliminate the faulty case. --- app/components/topbar-account-panel/template.hbs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/app/components/topbar-account-panel/template.hbs b/app/components/topbar-account-panel/template.hbs index b65983a..080621a 100644 --- a/app/components/topbar-account-panel/template.hbs +++ b/app/components/topbar-account-panel/template.hbs @@ -1,10 +1,8 @@
- {{#if kredits.hasAccounts }} - {{#if kredits.currentUser}} - {{kredits.currentUser.name}} - {{#if kredits.currentUserIsCore}} - (core) - {{/if}} + {{#if (and kredits.hasAccounts kredits.currentUser)}} + {{kredits.currentUser.name}} + {{#if kredits.currentUserIsCore}} + (core) {{/if}} {{else}} Anonymous From 0a71d7ad913c1511d155597e29bba61ae02e231a Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Thu, 18 Jul 2019 19:31:03 +0200 Subject: [PATCH 03/12] Add signup route --- app/router.js | 1 + app/routes/signup.js | 4 ++++ app/templates/signup.hbs | 1 + tests/unit/routes/signup-test.js | 11 +++++++++++ 4 files changed, 17 insertions(+) create mode 100644 app/routes/signup.js create mode 100644 app/templates/signup.hbs create mode 100644 tests/unit/routes/signup-test.js diff --git a/app/router.js b/app/router.js index 339fd9e..78e9943 100644 --- a/app/router.js +++ b/app/router.js @@ -26,6 +26,7 @@ Router.map(function() { this.route('new'); this.route('edit', { path: ':id/edit' }); }); + this.route('signup'); }); export default Router; diff --git a/app/routes/signup.js b/app/routes/signup.js new file mode 100644 index 0000000..6c74252 --- /dev/null +++ b/app/routes/signup.js @@ -0,0 +1,4 @@ +import Route from '@ember/routing/route'; + +export default Route.extend({ +}); diff --git a/app/templates/signup.hbs b/app/templates/signup.hbs new file mode 100644 index 0000000..e2147ca --- /dev/null +++ b/app/templates/signup.hbs @@ -0,0 +1 @@ +{{outlet}} \ No newline at end of file diff --git a/tests/unit/routes/signup-test.js b/tests/unit/routes/signup-test.js new file mode 100644 index 0000000..72e0efd --- /dev/null +++ b/tests/unit/routes/signup-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | signup', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:signup'); + assert.ok(route); + }); +}); From 725d36bed6e808c121d92b9f1655514657e76b2e Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Thu, 18 Jul 2019 19:43:39 +0200 Subject: [PATCH 04/12] Add signup button for unknown users --- app/components/topbar-account-panel/component.js | 9 +++++++++ app/components/topbar-account-panel/template.hbs | 1 + app/styles/app.scss | 1 + app/styles/components/_topbar-account-panel.scss | 7 +++++++ .../components/topbar-account-panel/component-test.js | 4 ++-- 5 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 app/styles/components/_topbar-account-panel.scss diff --git a/app/components/topbar-account-panel/component.js b/app/components/topbar-account-panel/component.js index 2a5c942..65185e7 100644 --- a/app/components/topbar-account-panel/component.js +++ b/app/components/topbar-account-panel/component.js @@ -6,5 +6,14 @@ export default Component.extend({ tagName: '', kredits: service(), + router: service(), + + actions: { + + signup() { + this.router.transitionTo('signup'); + } + + } }); diff --git a/app/components/topbar-account-panel/template.hbs b/app/components/topbar-account-panel/template.hbs index 080621a..0731a4c 100644 --- a/app/components/topbar-account-panel/template.hbs +++ b/app/components/topbar-account-panel/template.hbs @@ -6,5 +6,6 @@ {{/if}} {{else}} Anonymous + {{/if}}
\ No newline at end of file diff --git a/app/styles/app.scss b/app/styles/app.scss index 5db3cf8..ce49075 100644 --- a/app/styles/app.scss +++ b/app/styles/app.scss @@ -106,4 +106,5 @@ section { @import "components/loading-spinner"; @import "components/proposal-list"; @import "components/topbar"; +@import "components/topbar-account-panel"; @import "components/user-avatar"; diff --git a/app/styles/components/_topbar-account-panel.scss b/app/styles/components/_topbar-account-panel.scss new file mode 100644 index 0000000..900eb04 --- /dev/null +++ b/app/styles/components/_topbar-account-panel.scss @@ -0,0 +1,7 @@ +header#topbar section#user-account { + + button { + margin-left: 1.2rem; + } + +} diff --git a/tests/integration/components/topbar-account-panel/component-test.js b/tests/integration/components/topbar-account-panel/component-test.js index b6054ab..f194f73 100644 --- a/tests/integration/components/topbar-account-panel/component-test.js +++ b/tests/integration/components/topbar-account-panel/component-test.js @@ -9,7 +9,7 @@ module('Integration | Component | topbar-account-panel', function(hooks) { test('unknown user without wallet (or no permission to get wallet/account info)', async function(assert) { await render(hbs``); - assert.equal(this.element.textContent.trim(), 'Anonymous'); + assert.ok(this.element.textContent.trim().match(/^Anonymous/)); }); test('unknown user with Ethereum wallet', async function(assert) { @@ -17,7 +17,7 @@ module('Integration | Component | topbar-account-panel', function(hooks) { service.set('currentUserAccounts', [{ foo: 'bar' }]); await render(hbs``); - assert.equal(this.element.textContent.trim(), 'Anonymous'); + assert.ok(this.element.textContent.trim().match(/^Anonymous/)); }); test('known contributor', async function(assert) { From 4c70c0d233752d55ab548f180f24d13535c34913 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sun, 21 Jul 2019 16:04:00 +0200 Subject: [PATCH 05/12] Basic signup view --- app/styles/_buttons.scss | 13 +++++++++++++ app/styles/_layout.scss | 19 +++++++++++++++++++ app/templates/signup.hbs | 28 +++++++++++++++++++++++++++- 3 files changed, 59 insertions(+), 1 deletion(-) diff --git a/app/styles/_buttons.scss b/app/styles/_buttons.scss index 0e80146..6389aaf 100644 --- a/app/styles/_buttons.scss +++ b/app/styles/_buttons.scss @@ -53,4 +53,17 @@ button, input[type=submit], .button { border-color: $green; } } + + &.icon { + svg { + width: 2rem; + height: 2rem; + vertical-align: middle; + margin-right: 1rem; + + .fg { + fill: $primary-color; + } + } + } } diff --git a/app/styles/_layout.scss b/app/styles/_layout.scss index f025692..b405c5d 100644 --- a/app/styles/_layout.scss +++ b/app/styles/_layout.scss @@ -28,6 +28,25 @@ main { } } } + + section { + .content { + &.text-lg { + p { + font-size: 1.2rem; + margin-bottom: 1em; + line-height: 1.5em; + } + } + + p { + &.actions { + text-align: center; + padding-top: 2rem; + } + } + } + } } @media (min-width: 550px) { diff --git a/app/templates/signup.hbs b/app/templates/signup.hbs index e2147ca..7d690fa 100644 --- a/app/templates/signup.hbs +++ b/app/templates/signup.hbs @@ -1 +1,27 @@ -{{outlet}} \ No newline at end of file +
+ +
+
+

Create your contributor profile

+
+ +
+

+ You have already contributed to a Kosmos project, or you are interested + in contributing in the near future? Fantastic! +

+

+ In order to earn kredits for your contributions, you will need a + registered contributor profile. The quickest way to register is by + connecting one of the following accounts: +

+

+ +

+
+
+ +
\ No newline at end of file From d6d2b1a61cbc29d2041684768211d0051201fbdc Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Sun, 21 Jul 2019 17:03:50 +0200 Subject: [PATCH 06/12] Add signup completion page --- app/controllers/signup/eth-account.js | 13 ++++++++++++ app/router.js | 4 +++- app/routes/signup/eth-account.js | 4 ++++ app/styles/_buttons.scss | 4 ++++ app/styles/_forms.scss | 7 ++++++- app/styles/_layout.scss | 4 ++++ app/templates/signup.hbs | 16 +------------- app/templates/signup/eth-account.hbs | 22 ++++++++++++++++++++ app/templates/signup/index.hbs | 15 +++++++++++++ tests/unit/routes/signup/eth-account-test.js | 11 ++++++++++ 10 files changed, 83 insertions(+), 17 deletions(-) create mode 100644 app/controllers/signup/eth-account.js create mode 100644 app/routes/signup/eth-account.js create mode 100644 app/templates/signup/eth-account.hbs create mode 100644 app/templates/signup/index.hbs create mode 100644 tests/unit/routes/signup/eth-account-test.js diff --git a/app/controllers/signup/eth-account.js b/app/controllers/signup/eth-account.js new file mode 100644 index 0000000..489ae13 --- /dev/null +++ b/app/controllers/signup/eth-account.js @@ -0,0 +1,13 @@ +import Controller from '@ember/controller'; +import { not, notEmpty } from '@ember/object/computed'; +// import { computed } from '@ember/object'; + +export default Controller.extend({ + + ethAddress: null, + + // TODO address validation + isValidEthAccount: notEmpty('ethAddress'), + signupButtonDisabled: not('isValidEthAccount') + +}); diff --git a/app/router.js b/app/router.js index 78e9943..839c8c1 100644 --- a/app/router.js +++ b/app/router.js @@ -26,7 +26,9 @@ Router.map(function() { this.route('new'); this.route('edit', { path: ':id/edit' }); }); - this.route('signup'); + this.route('signup', function() { + this.route('eth-account'); + }); }); export default Router; diff --git a/app/routes/signup/eth-account.js b/app/routes/signup/eth-account.js new file mode 100644 index 0000000..6c74252 --- /dev/null +++ b/app/routes/signup/eth-account.js @@ -0,0 +1,4 @@ +import Route from '@ember/routing/route'; + +export default Route.extend({ +}); diff --git a/app/styles/_buttons.scss b/app/styles/_buttons.scss index 6389aaf..eea2c90 100644 --- a/app/styles/_buttons.scss +++ b/app/styles/_buttons.scss @@ -23,6 +23,10 @@ button, input[type=submit], .button { border-color: $primary-color; } + &[disabled] { + color: rgba(255,255,255,0.5); + } + &.small { font-size: 0.8rem; padding: 0.2rem 0.8rem; diff --git a/app/styles/_forms.scss b/app/styles/_forms.scss index f9e3dd9..97a644d 100644 --- a/app/styles/_forms.scss +++ b/app/styles/_forms.scss @@ -1,12 +1,17 @@ section#add-contributor, section#add-contribution, -section#add-proposal { +section#add-proposal, +section#signup { form { p { margin-bottom: 1.5rem; + &.mg-bottom-md { + margin-bottom: 2rem; + } + &.actions { padding-top: 1.5rem; text-align: center; diff --git a/app/styles/_layout.scss b/app/styles/_layout.scss index b405c5d..66729a6 100644 --- a/app/styles/_layout.scss +++ b/app/styles/_layout.scss @@ -40,6 +40,10 @@ main { } p { + &.mg-bottom-md { + margin-bottom: 2rem; + } + &.actions { text-align: center; padding-top: 2rem; diff --git a/app/templates/signup.hbs b/app/templates/signup.hbs index 7d690fa..f6d10f9 100644 --- a/app/templates/signup.hbs +++ b/app/templates/signup.hbs @@ -6,21 +6,7 @@
-

- You have already contributed to a Kosmos project, or you are interested - in contributing in the near future? Fantastic! -

-

- In order to earn kredits for your contributions, you will need a - registered contributor profile. The quickest way to register is by - connecting one of the following accounts: -

-

- -

+ {{outlet}}
diff --git a/app/templates/signup/eth-account.hbs b/app/templates/signup/eth-account.hbs new file mode 100644 index 0000000..6e20d06 --- /dev/null +++ b/app/templates/signup/eth-account.hbs @@ -0,0 +1,22 @@ +

+ Kredits allow you to take part in project governance, and to earn rewards for + your contributions. For both, you will need an Ethereum wallet/account. +

+ +
+

+ +

+
+ +

+ +

\ No newline at end of file diff --git a/app/templates/signup/index.hbs b/app/templates/signup/index.hbs new file mode 100644 index 0000000..f57768b --- /dev/null +++ b/app/templates/signup/index.hbs @@ -0,0 +1,15 @@ +

+ You have already contributed to a Kosmos project, or you are interested + in contributing in the near future? Fantastic! +

+

+ In order to earn kredits for your contributions, you will need a + registered contributor profile. The quickest way to register is by + connecting one of the following accounts: +

+

+ {{#link-to "signup.eth-account" class="button icon"}} + {{icon-account-github-com}} + Connect GitHub + {{/link-to}} +

diff --git a/tests/unit/routes/signup/eth-account-test.js b/tests/unit/routes/signup/eth-account-test.js new file mode 100644 index 0000000..4c4f714 --- /dev/null +++ b/tests/unit/routes/signup/eth-account-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | signup/eth-account', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:signup/eth-account'); + assert.ok(route); + }); +}); From a8ae2b01564e0089c970d6cf949fa58f4893a104 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Mon, 22 Jul 2019 17:29:31 +0200 Subject: [PATCH 07/12] Validate Ethereum addresses in input fields --- app/components/add-contributor/component.js | 9 +- app/controllers/signup/eth-account.js | 20 +- package-lock.json | 223 ++++++++++++++++++++ package.json | 3 +- 4 files changed, 247 insertions(+), 8 deletions(-) diff --git a/app/components/add-contributor/component.js b/app/components/add-contributor/component.js index 36c2097..84ab38f 100644 --- a/app/components/add-contributor/component.js +++ b/app/components/add-contributor/component.js @@ -1,7 +1,9 @@ import Component from '@ember/component'; +import { computed } from '@ember/object'; import { and, notEmpty } from '@ember/object/computed'; import { inject as service } from '@ember/service'; import { isPresent } from '@ember/utils'; +import { isAddress } from 'web3-utils'; export default Component.extend({ @@ -9,14 +11,17 @@ export default Component.extend({ attributes: null, - // TODO: add proper address validation - isValidAccount: notEmpty('account'), + isValidAccount: computed('ethAddress', function() { + return isAddress(this.ethAddress); + }), + isValidName: notEmpty('name'), isValidURL: notEmpty('url'), isValidGithubUID: notEmpty('github_uid'), isValidGithubUsername: notEmpty('github_username'), isValidGiteaUsername: notEmpty('gitea_username'), isValidWikiUsername: notEmpty('wiki_username'), + isValid: and( 'isValidAccount', 'isValidName', diff --git a/app/controllers/signup/eth-account.js b/app/controllers/signup/eth-account.js index 489ae13..199323d 100644 --- a/app/controllers/signup/eth-account.js +++ b/app/controllers/signup/eth-account.js @@ -1,13 +1,23 @@ import Controller from '@ember/controller'; -import { not, notEmpty } from '@ember/object/computed'; -// import { computed } from '@ember/object'; +import { computed } from '@ember/object'; +import { not } from '@ember/object/computed'; +import { isAddress } from 'web3-utils'; export default Controller.extend({ ethAddress: null, - // TODO address validation - isValidEthAccount: notEmpty('ethAddress'), - signupButtonDisabled: not('isValidEthAccount') + isValidEthAccount: computed('ethAddress', function() { + return isAddress(this.ethAddress); + }), + + signupButtonDisabled: not('isValidEthAccount'), + + actions: { + + completeSignup() { + } + + } }); diff --git a/package-lock.json b/package-lock.json index 1e1bb71..849e839 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4241,6 +4241,12 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, + "buffer-to-arraybuffer": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz", + "integrity": "sha1-YGSkD6dutDxyOrqe+PbhIW0QURo=", + "dev": true + }, "buffer-xor": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz", @@ -5636,6 +5642,12 @@ "esutils": "^2.0.2" } }, + "dom-walk": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz", + "integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg=", + "dev": true + }, "domain-browser": { "version": "1.1.7", "resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.1.7.tgz", @@ -8414,6 +8426,17 @@ "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=", "dev": true }, + "eth-lib": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.7.tgz", + "integrity": "sha1-L5Pxex4jrsN1nNSj/iDBKGo/wco=", + "dev": true, + "requires": { + "bn.js": "^4.11.6", + "elliptic": "^6.4.0", + "xhr-request-promise": "^0.1.2" + } + }, "ethers": { "version": "4.0.27", "resolved": "https://registry.npmjs.org/ethers/-/ethers-4.0.27.tgz", @@ -8468,6 +8491,24 @@ } } }, + "ethjs-unit": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/ethjs-unit/-/ethjs-unit-0.1.6.tgz", + "integrity": "sha1-xmWSHkduh7ziqdWIpv4EBbLEFpk=", + "dev": true, + "requires": { + "bn.js": "4.11.6", + "number-to-bn": "1.7.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", + "dev": true + } + } + }, "event-emitter": { "version": "0.3.5", "resolved": "https://registry.npmjs.org/event-emitter/-/event-emitter-0.3.5.tgz", @@ -9245,6 +9286,15 @@ } } }, + "for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dev": true, + "requires": { + "is-callable": "^1.1.3" + } + }, "for-in": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", @@ -10073,6 +10123,24 @@ "integrity": "sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs=", "dev": true }, + "global": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz", + "integrity": "sha1-52mJJopsdMOJCLEwWxD8DjlOnQ8=", + "dev": true, + "requires": { + "min-document": "^2.19.0", + "process": "~0.5.1" + }, + "dependencies": { + "process": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/process/-/process-0.5.2.tgz", + "integrity": "sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8=", + "dev": true + } + } + }, "global-modules": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/global-modules/-/global-modules-1.0.0.tgz", @@ -11111,6 +11179,12 @@ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, + "is-function": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.1.tgz", + "integrity": "sha1-Es+5i2W1fdPRk6MSH19uL0N2ArU=", + "dev": true + }, "is-git-url": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-git-url/-/is-git-url-1.0.0.tgz", @@ -11126,6 +11200,12 @@ "is-extglob": "^2.1.0" } }, + "is-hex-prefixed": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz", + "integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ=", + "dev": true + }, "is-ip": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-ip/-/is-ip-2.0.0.tgz", @@ -12765,6 +12845,15 @@ "integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ==", "dev": true }, + "min-document": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz", + "integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=", + "dev": true, + "requires": { + "dom-walk": "^0.1.0" + } + }, "minimalistic-assert": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz", @@ -13433,6 +13522,24 @@ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", "dev": true }, + "number-to-bn": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz", + "integrity": "sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA=", + "dev": true, + "requires": { + "bn.js": "4.11.6", + "strip-hex-prefix": "1.0.0" + }, + "dependencies": { + "bn.js": { + "version": "4.11.6", + "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz", + "integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU=", + "dev": true + } + } + }, "nwsapi": { "version": "2.1.4", "resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.1.4.tgz", @@ -13781,6 +13888,16 @@ "safe-buffer": "^5.1.1" } }, + "parse-headers": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.2.tgz", + "integrity": "sha512-/LypJhzFmyBIDYP9aDVgeyEb5sQfbfY5mnDq4hVhlQ69js87wXfmEI5V3xI6vvXasqebp0oCytYFLxsBVfCzSg==", + "dev": true, + "requires": { + "for-each": "^0.3.3", + "string.prototype.trim": "^1.1.2" + } + }, "parse-json": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", @@ -14500,6 +14617,12 @@ "safe-buffer": "^5.1.0" } }, + "randomhex": { + "version": "0.1.5", + "resolved": "https://registry.npmjs.org/randomhex/-/randomhex-0.1.5.tgz", + "integrity": "sha1-us7vmCMpCRQA8qKRLGzQLxCU9YU=", + "dev": true + }, "range-parser": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", @@ -15430,6 +15553,23 @@ "debug": "^2.2.0" } }, + "simple-concat": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz", + "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY=", + "dev": true + }, + "simple-get": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-2.8.1.tgz", + "integrity": "sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw==", + "dev": true, + "requires": { + "decompress-response": "^3.3.0", + "once": "^1.3.1", + "simple-concat": "^1.0.0" + } + }, "simple-html-tokenizer": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/simple-html-tokenizer/-/simple-html-tokenizer-0.5.7.tgz", @@ -16118,6 +16258,17 @@ } } }, + "string.prototype.trim": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", + "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", + "dev": true, + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.0", + "function-bind": "^1.0.2" + } + }, "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", @@ -16148,6 +16299,15 @@ "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", "dev": true }, + "strip-hex-prefix": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz", + "integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=", + "dev": true, + "requires": { + "is-hex-prefixed": "1.0.0" + } + }, "strip-indent": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz", @@ -17039,6 +17199,12 @@ "prepend-http": "^2.0.0" } }, + "url-set-query": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz", + "integrity": "sha1-AW6M/Xwg7gXK/neV6JK9BwL6ozk=", + "dev": true + }, "url-to-options": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/url-to-options/-/url-to-options-1.0.1.tgz", @@ -17067,6 +17233,12 @@ "integrity": "sha512-ayNkOJdoNSGNDBE46Nkc+l6IXmeugbzahZLSMkwvgRWv5y5ZqNY2IrzcgmkR4z32sj1W3tM3TuTUMqkqBzO+RA==", "dev": true }, + "utf8": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/utf8/-/utf8-3.0.0.tgz", + "integrity": "sha512-E8VjFIQ/TyQgp+TZfS6l8yp/xWppSAHzidGiRrqe4bK4XP9pTRyKFgGJpO3SN7zdX4DeomTrwaseCHovfpFcqQ==", + "dev": true + }, "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -17212,6 +17384,21 @@ "defaults": "^1.0.3" } }, + "web3-utils": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0.tgz", + "integrity": "sha512-zm0gdLXLk54ldwxxBMNPS62EuqHI2PaJohEGijTowacNS0BS2vEXdriNA8gp1+EplP2WgoHE0uRVmQIfpAyV+Q==", + "dev": true, + "requires": { + "bn.js": "4.11.8", + "eth-lib": "0.2.7", + "ethjs-unit": "0.1.6", + "number-to-bn": "1.7.0", + "randomhex": "0.1.5", + "underscore": "1.9.1", + "utf8": "3.0.0" + } + }, "webidl-conversions": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", @@ -17483,6 +17670,42 @@ "integrity": "sha1-SWsswQnsqNus/i3HK2A8F8WHCtQ=", "dev": true }, + "xhr": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/xhr/-/xhr-2.5.0.tgz", + "integrity": "sha512-4nlO/14t3BNUZRXIXfXe+3N6w3s1KoxcJUUURctd64BLRe67E4gRwp4PjywtDY72fXpZ1y6Ch0VZQRY/gMPzzQ==", + "dev": true, + "requires": { + "global": "~4.3.0", + "is-function": "^1.0.1", + "parse-headers": "^2.0.0", + "xtend": "^4.0.0" + } + }, + "xhr-request": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/xhr-request/-/xhr-request-1.1.0.tgz", + "integrity": "sha512-Y7qzEaR3FDtL3fP30k9wO/e+FBnBByZeybKOhASsGP30NIkRAAkKD/sCnLvgEfAIEC1rcmK7YG8f4oEnIrrWzA==", + "dev": true, + "requires": { + "buffer-to-arraybuffer": "^0.0.5", + "object-assign": "^4.1.1", + "query-string": "^5.0.1", + "simple-get": "^2.7.0", + "timed-out": "^4.0.1", + "url-set-query": "^1.0.0", + "xhr": "^2.0.4" + } + }, + "xhr-request-promise": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/xhr-request-promise/-/xhr-request-promise-0.1.2.tgz", + "integrity": "sha1-NDxE0e53JrhkgGloLQ+EDIO0Jh0=", + "dev": true, + "requires": { + "xhr-request": "^1.0.1" + } + }, "xml-name-validator": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", diff --git a/package.json b/package.json index 8d0fb67..c7b46b6 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,8 @@ "ndjson": "github:hugomrdias/ndjson#feat/readable-stream3", "qunit-dom": "^0.8.4", "transform-loader": "^0.2.4", - "tv4": "^1.3.0" + "tv4": "^1.3.0", + "web3-utils": "^1.0.0" }, "engines": { "node": "8.* || >= 10.*" From 780afc9bc6cde9480ae383208d3bc5cba8563b8d Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Wed, 24 Jul 2019 11:56:51 +0200 Subject: [PATCH 08/12] Fix wrong property name --- app/components/add-contributor/component.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/components/add-contributor/component.js b/app/components/add-contributor/component.js index 84ab38f..118aba3 100644 --- a/app/components/add-contributor/component.js +++ b/app/components/add-contributor/component.js @@ -11,8 +11,8 @@ export default Component.extend({ attributes: null, - isValidAccount: computed('ethAddress', function() { - return isAddress(this.ethAddress); + isValidAccount: computed('account', function() { + return isAddress(this.account); }), isValidName: notEmpty('name'), From 413bcddb1ed4a419f26b63955351e80ee7cbe140 Mon Sep 17 00:00:00 2001 From: Garret Alfert Date: Fri, 26 Jul 2019 03:38:18 +0200 Subject: [PATCH 09/12] Wire up signup via Github --- app/controllers/signup/eth-account.js | 33 ++++++++++++++++++-- app/controllers/signup/index.js | 14 +++++++++ app/router.js | 1 + app/routes/signup/eth-account.js | 13 ++++++++ app/routes/signup/github.js | 18 +++++++++++ app/services/kredits.js | 1 + app/templates/signup/index.hbs | 4 +-- config/environment.js | 6 ++++ package-lock.json | 45 ++++++++------------------- 9 files changed, 99 insertions(+), 36 deletions(-) create mode 100644 app/controllers/signup/index.js create mode 100644 app/routes/signup/github.js diff --git a/app/controllers/signup/eth-account.js b/app/controllers/signup/eth-account.js index 199323d..d1a8bcf 100644 --- a/app/controllers/signup/eth-account.js +++ b/app/controllers/signup/eth-account.js @@ -1,11 +1,16 @@ import Controller from '@ember/controller'; import { computed } from '@ember/object'; -import { not } from '@ember/object/computed'; +import { alias, not } from '@ember/object/computed'; import { isAddress } from 'web3-utils'; +import { inject as service } from '@ember/service'; +import config from 'kredits-web/config/environment'; export default Controller.extend({ + kredits: service(), + ethAddress: null, + githubAccessToken: alias('kredits.githubAccessToken'), isValidEthAccount: computed('ethAddress', function() { return isAddress(this.ethAddress); @@ -15,7 +20,31 @@ export default Controller.extend({ actions: { - completeSignup() { + completeSignup () { + const payload = { + accessToken: this.githubAccessToken, + account: this.ethAddress + } + + fetch(config.githubSignupUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(payload) + }).then(response => { + return response.json(); + }) + .then(data => { + console.log('Created contributor:', data); + + this.setProperties({ + githubAccessToken: null, + ethAddress: null + }); + + // TODO show success message or transition to success page + }); } } diff --git a/app/controllers/signup/index.js b/app/controllers/signup/index.js new file mode 100644 index 0000000..d90035c --- /dev/null +++ b/app/controllers/signup/index.js @@ -0,0 +1,14 @@ +import Controller from '@ember/controller'; +import config from 'kredits-web/config/environment'; + +export default Controller.extend({ + + actions: { + + connectGithub () { + window.location = config.githubConnectUrl; + } + + } + +}); diff --git a/app/router.js b/app/router.js index 839c8c1..61cc122 100644 --- a/app/router.js +++ b/app/router.js @@ -27,6 +27,7 @@ Router.map(function() { this.route('edit', { path: ':id/edit' }); }); this.route('signup', function() { + this.route('github'); this.route('eth-account'); }); }); diff --git a/app/routes/signup/eth-account.js b/app/routes/signup/eth-account.js index 6c74252..078a109 100644 --- a/app/routes/signup/eth-account.js +++ b/app/routes/signup/eth-account.js @@ -1,4 +1,17 @@ import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; +import { isEmpty } from '@ember/utils'; export default Route.extend({ + + kredits: service(), + + redirect () { + this._super(...arguments); + + if (isEmpty(this.kredits.githubAccessToken)) { + this.transitionTo('signup.index'); + } + } + }); diff --git a/app/routes/signup/github.js b/app/routes/signup/github.js new file mode 100644 index 0000000..969dc55 --- /dev/null +++ b/app/routes/signup/github.js @@ -0,0 +1,18 @@ +import Route from '@ember/routing/route'; +import { inject as service } from '@ember/service'; + +export default Route.extend({ + + kredits: service(), + + redirect () { + this._super(...arguments); + + const accessToken = window.location.hash.match(/access_token=(.+)/)[1]; + this.kredits.set('githubAccessToken', accessToken); + + this.transitionTo('signup.eth-account'); + } + +}); + diff --git a/app/services/kredits.js b/app/services/kredits.js index e31e714..a1b9ec2 100644 --- a/app/services/kredits.js +++ b/app/services/kredits.js @@ -24,6 +24,7 @@ export default Service.extend({ contributors: null, contributions: null, proposals: null, + githubAccessToken: null, currentUserIsContributor: notEmpty('currentUser'), currentUserIsCore: alias('currentUser.isCore'), diff --git a/app/templates/signup/index.hbs b/app/templates/signup/index.hbs index f57768b..a8ad30f 100644 --- a/app/templates/signup/index.hbs +++ b/app/templates/signup/index.hbs @@ -8,8 +8,8 @@ connecting one of the following accounts:

- {{#link-to "signup.eth-account" class="button icon"}} +

diff --git a/config/environment.js b/config/environment.js index 1004b33..d1ae6e7 100644 --- a/config/environment.js +++ b/config/environment.js @@ -37,6 +37,9 @@ module.exports = function(environment) { web3ProviderUrl: 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9', + githubConnectUrl: 'https://hal8000.chat.kosmos.org:8082/kredits/signup/connect/github', + githubSignupUrl: 'https://hal8000.chat.kosmos.org:8082/kredits/signup/github', + ipfs: { host: 'ipfs.kosmos.org', port: '5444', @@ -53,6 +56,9 @@ module.exports = function(environment) { // ENV.APP.LOG_VIEW_LOOKUPS = true; ENV.web3ProviderUrl = 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9'; + ENV.githubConnectUrl = 'http://localhost:8888/kredits/signup/connect/github'; + ENV.githubSignupUrl = 'http://localhost:8888/kredits/signup/github'; + ENV.ipfs = { host: 'localhost', port: '5001', diff --git a/package-lock.json b/package-lock.json index 849e839..81bacd8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9429,8 +9429,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -9451,14 +9450,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -9473,20 +9470,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -9603,8 +9597,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -9616,7 +9609,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -9631,7 +9623,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -9639,14 +9630,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -9665,7 +9654,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -9746,8 +9734,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -9759,7 +9746,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -9845,8 +9831,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -9882,7 +9867,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -9902,7 +9886,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -9946,14 +9929,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -10883,7 +10864,7 @@ "bs58": "^4.0.1", "buffer": "^5.2.1", "cids": "~0.5.5", - "concat-stream": "github:hugomrdias/concat-stream#feat/smaller", + "concat-stream": "github:hugomrdias/concat-stream#057bc7b5d6d8df26c8cf00a3f151b6721a0a8034", "debug": "^4.1.0", "detect-node": "^2.0.4", "end-of-stream": "^1.4.1", @@ -10905,7 +10886,7 @@ "multibase": "~0.6.0", "multicodec": "~0.5.0", "multihashes": "~0.4.14", - "ndjson": "github:hugomrdias/ndjson#feat/readable-stream3", + "ndjson": "github:hugomrdias/ndjson#4db16da6b42e5b39bf300c3a7cde62abb3fa3a11", "once": "^1.4.0", "peer-id": "~0.12.2", "peer-info": "~0.15.1", From 60ba019139d86226d1cf91578bc9f931551df570 Mon Sep 17 00:00:00 2001 From: Garret Alfert Date: Fri, 26 Jul 2019 19:02:41 +0200 Subject: [PATCH 10/12] Fix HAL8000 URL Wrong port number. --- config/environment.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/environment.js b/config/environment.js index d1ae6e7..5c0af1e 100644 --- a/config/environment.js +++ b/config/environment.js @@ -37,8 +37,8 @@ module.exports = function(environment) { web3ProviderUrl: 'https://rinkeby.infura.io/v3/d4f788b7a6584f7db2fc3c268d4d09e9', - githubConnectUrl: 'https://hal8000.chat.kosmos.org:8082/kredits/signup/connect/github', - githubSignupUrl: 'https://hal8000.chat.kosmos.org:8082/kredits/signup/github', + githubConnectUrl: 'https://hal8000.chat.kosmos.org/kredits/signup/connect/github', + githubSignupUrl: 'https://hal8000.chat.kosmos.org/kredits/signup/github', ipfs: { host: 'ipfs.kosmos.org', From dc5dfe19f2515a501b493014f0a0c965963d5fc0 Mon Sep 17 00:00:00 2001 From: Sebastian Kippe Date: Tue, 27 Aug 2019 18:19:46 +0200 Subject: [PATCH 11/12] Add success page to GitHub signup --- app/controllers/signup/eth-account.js | 9 ++--- app/router.js | 1 + app/routes/signup/complete.js | 4 ++ app/styles/_layout.scss | 8 ++++ app/styles/app.scss | 4 ++ app/templates/signup.hbs | 10 +---- app/templates/signup/complete.hbs | 15 ++++++++ app/templates/signup/eth-account.hbs | 45 ++++++++++++----------- app/templates/signup/index.hbs | 35 ++++++++++-------- package-lock.json | 45 ++++++++++++++++------- tests/unit/routes/signup/complete-test.js | 11 ++++++ 11 files changed, 123 insertions(+), 64 deletions(-) create mode 100644 app/routes/signup/complete.js create mode 100644 app/templates/signup/complete.hbs create mode 100644 tests/unit/routes/signup/complete-test.js diff --git a/app/controllers/signup/eth-account.js b/app/controllers/signup/eth-account.js index d1a8bcf..1a29880 100644 --- a/app/controllers/signup/eth-account.js +++ b/app/controllers/signup/eth-account.js @@ -28,13 +28,10 @@ export default Controller.extend({ fetch(config.githubSignupUrl, { method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, + headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) - }).then(response => { - return response.json(); }) + .then(res => res.json()) .then(data => { console.log('Created contributor:', data); @@ -43,7 +40,7 @@ export default Controller.extend({ ethAddress: null }); - // TODO show success message or transition to success page + this.transitionToRoute('signup.complete'); }); } diff --git a/app/router.js b/app/router.js index 61cc122..e2c6349 100644 --- a/app/router.js +++ b/app/router.js @@ -29,6 +29,7 @@ Router.map(function() { this.route('signup', function() { this.route('github'); this.route('eth-account'); + this.route('complete'); }); }); diff --git a/app/routes/signup/complete.js b/app/routes/signup/complete.js new file mode 100644 index 0000000..6c74252 --- /dev/null +++ b/app/routes/signup/complete.js @@ -0,0 +1,4 @@ +import Route from '@ember/routing/route'; + +export default Route.extend({ +}); diff --git a/app/styles/_layout.scss b/app/styles/_layout.scss index 66729a6..bd95fe8 100644 --- a/app/styles/_layout.scss +++ b/app/styles/_layout.scss @@ -31,6 +31,10 @@ main { section { .content { + a { + font-size: inherit; + } + &.text-lg { p { font-size: 1.2rem; @@ -39,6 +43,10 @@ main { } } + &.text-center { + text-align: center; + } + p { &.mg-bottom-md { margin-bottom: 2rem; diff --git a/app/styles/app.scss b/app/styles/app.scss index ce49075..8396a20 100644 --- a/app/styles/app.scss +++ b/app/styles/app.scss @@ -38,6 +38,10 @@ h1, h2, h3, h4, h5, input, button { font-weight: 300; } +a { + color: $primary-color; +} + section { h2 { font-size: 1.4rem; diff --git a/app/templates/signup.hbs b/app/templates/signup.hbs index f6d10f9..2e18661 100644 --- a/app/templates/signup.hbs +++ b/app/templates/signup.hbs @@ -1,13 +1,5 @@
-
-
-

Create your contributor profile

-
- -
- {{outlet}} -
+ {{outlet}}
-
\ No newline at end of file diff --git a/app/templates/signup/complete.hbs b/app/templates/signup/complete.hbs new file mode 100644 index 0000000..189db7a --- /dev/null +++ b/app/templates/signup/complete.hbs @@ -0,0 +1,15 @@ +
+

Welcome aboard!

+
+
+

+ Congratulations. Your initial profile is now complete. +

+

+ Why not say hi to your fellow contributors + in one of our chat rooms?. +

+

+ {{#link-to "dashboard" class="button small"}}Return to dashboard{{/link-to}} +

+
\ No newline at end of file diff --git a/app/templates/signup/eth-account.hbs b/app/templates/signup/eth-account.hbs index 6e20d06..b69dca9 100644 --- a/app/templates/signup/eth-account.hbs +++ b/app/templates/signup/eth-account.hbs @@ -1,22 +1,25 @@ -

- Kredits allow you to take part in project governance, and to earn rewards for - your contributions. For both, you will need an Ethereum wallet/account. -

- -
-

- +

+

Complete your contributor profile

+
+
+

+ Kredits allow you to take part in project governance, and to earn rewards for + your contributions. For both, you will need an Ethereum wallet/account.

- - -

- -

\ No newline at end of file +
+

+ +

+
+

+ +

+
\ No newline at end of file diff --git a/app/templates/signup/index.hbs b/app/templates/signup/index.hbs index a8ad30f..b3296e6 100644 --- a/app/templates/signup/index.hbs +++ b/app/templates/signup/index.hbs @@ -1,15 +1,20 @@ -

- You have already contributed to a Kosmos project, or you are interested - in contributing in the near future? Fantastic! -

-

- In order to earn kredits for your contributions, you will need a - registered contributor profile. The quickest way to register is by - connecting one of the following accounts: -

-

- -

+
+

Create your contributor profile

+
+
+

+ You have already contributed to a Kosmos project, or you are interested + in contributing in the near future? Fantastic! +

+

+ In order to earn kredits for your contributions, you will need a + registered contributor profile. The quickest way to register is by + connecting one of the following accounts: +

+

+ +

+
diff --git a/package-lock.json b/package-lock.json index 81bacd8..849e839 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9429,7 +9429,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -9450,12 +9451,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -9470,17 +9473,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -9597,7 +9603,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -9609,6 +9616,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -9623,6 +9631,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -9630,12 +9639,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -9654,6 +9665,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -9734,7 +9746,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -9746,6 +9759,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -9831,7 +9845,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -9867,6 +9882,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -9886,6 +9902,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -9929,12 +9946,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -10864,7 +10883,7 @@ "bs58": "^4.0.1", "buffer": "^5.2.1", "cids": "~0.5.5", - "concat-stream": "github:hugomrdias/concat-stream#057bc7b5d6d8df26c8cf00a3f151b6721a0a8034", + "concat-stream": "github:hugomrdias/concat-stream#feat/smaller", "debug": "^4.1.0", "detect-node": "^2.0.4", "end-of-stream": "^1.4.1", @@ -10886,7 +10905,7 @@ "multibase": "~0.6.0", "multicodec": "~0.5.0", "multihashes": "~0.4.14", - "ndjson": "github:hugomrdias/ndjson#4db16da6b42e5b39bf300c3a7cde62abb3fa3a11", + "ndjson": "github:hugomrdias/ndjson#feat/readable-stream3", "once": "^1.4.0", "peer-id": "~0.12.2", "peer-info": "~0.15.1", diff --git a/tests/unit/routes/signup/complete-test.js b/tests/unit/routes/signup/complete-test.js new file mode 100644 index 0000000..199e6b9 --- /dev/null +++ b/tests/unit/routes/signup/complete-test.js @@ -0,0 +1,11 @@ +import { module, test } from 'qunit'; +import { setupTest } from 'ember-qunit'; + +module('Unit | Route | signup/complete', function(hooks) { + setupTest(hooks); + + test('it exists', function(assert) { + let route = this.owner.lookup('route:signup/complete'); + assert.ok(route); + }); +}); From 0625ee9d7945e207e56ce348f0bcd55bef938c69 Mon Sep 17 00:00:00 2001 From: Garret Alfert Date: Wed, 28 Aug 2019 12:53:21 +0200 Subject: [PATCH 12/12] Handle undefined Github access token --- app/routes/signup/github.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/app/routes/signup/github.js b/app/routes/signup/github.js index 969dc55..7ad6798 100644 --- a/app/routes/signup/github.js +++ b/app/routes/signup/github.js @@ -1,5 +1,6 @@ import Route from '@ember/routing/route'; import { inject as service } from '@ember/service'; +import { isEmpty } from '@ember/utils'; export default Route.extend({ @@ -8,7 +9,17 @@ export default Route.extend({ redirect () { this._super(...arguments); - const accessToken = window.location.hash.match(/access_token=(.+)/)[1]; + let accessToken; + try { + accessToken = window.location.hash.match(/access_token=(.+)/)[1]; + } catch (error) { /* ignore */ } + + if (isEmpty(accessToken) || accessToken === 'undefined') { + console.error('No GitHub access token found.'); + this.transitionTo('signup'); + return; + } + this.kredits.set('githubAccessToken', accessToken); this.transitionTo('signup.eth-account');