From f8fd082ccbe8ffe9f9f9b2aa776c092f1270f159 Mon Sep 17 00:00:00 2001 From: Devin Alexander Torres Date: Mon, 26 Mar 2018 22:13:57 -0500 Subject: [PATCH] feat(settings): add ability to label accounts --- app/components/account-card/styles.scss | 29 ++++++++------ app/components/account-card/template.hbs | 12 ++++-- app/components/account-label/component.js | 9 +++++ app/components/account-label/styles.scss | 2 + app/components/account-label/template.hbs | 7 ++++ app/components/account-settings/component.js | 26 +++++++++++++ app/components/account-settings/template.hbs | 27 +++++++++++++ app/components/navigation-bar/template.hbs | 2 +- app/components/wallet-settings/template.hbs | 7 ---- app/router.js | 1 + app/utils/generate-seed.js | 2 +- app/validations/change-account-settings.js | 5 +++ .../overview/accounts/settings/route.js | 21 ++++++++++ .../overview/accounts/settings/template.hbs | 1 + .../components/account-card/component-test.js | 5 ++- .../account-carousel/component-test.js | 5 ++- .../account-label/component-test.js | 24 ++++++++++++ .../account-settings/component-test.js | 38 +++++++++++++++++++ .../wallet-overview/component-test.js | 5 ++- .../overview/accounts/settings/route-test.js | 18 +++++++++ translations/en-us.yaml | 6 ++- 21 files changed, 220 insertions(+), 32 deletions(-) create mode 100644 app/components/account-label/component.js create mode 100644 app/components/account-label/styles.scss create mode 100644 app/components/account-label/template.hbs create mode 100644 app/components/account-settings/component.js create mode 100644 app/components/account-settings/template.hbs create mode 100644 app/validations/change-account-settings.js create mode 100644 app/wallets/overview/accounts/settings/route.js create mode 100644 app/wallets/overview/accounts/settings/template.hbs create mode 100644 tests/integration/components/account-label/component-test.js create mode 100644 tests/integration/components/account-settings/component-test.js create mode 100644 tests/unit/wallets/overview/accounts/settings/route-test.js diff --git a/app/components/account-card/styles.scss b/app/components/account-card/styles.scss index f3500dc9..5ae40f56 100644 --- a/app/components/account-card/styles.scss +++ b/app/components/account-card/styles.scss @@ -1,4 +1,5 @@ button { + cursor: pointer; border: 0; outline: none; background-color: transparent; @@ -25,6 +26,13 @@ button { transform: scale(1.10) !important; } + .settings { + outline: none; + position: absolute; + top: 5px; + right: 10px; + } + img.qr-code { display: block; height: auto; @@ -56,26 +64,23 @@ button { font-size: 14px; } - .address { - cursor: pointer; + .label { width: 100%; - overflow-wrap: break-word; - background-color: $dark-purple; - color: white; - text-align: center; } .copy-btn { - border: 0; outline: none; - cursor: pointer; - background-color: $dark-purple; - font-size: 0.7rem; - color: white; + border: 0; margin: 0; padding: 10px; height: 60px; - width: 100%; + font-size: 0.7rem; + background-color: $dark-purple; + color: white; overflow-wrap: break-word; + + big { + font-size: 1.1rem; + } } } diff --git a/app/components/account-card/template.hbs b/app/components/account-card/template.hbs index 6727caf7..5058f8b0 100644 --- a/app/components/account-card/template.hbs +++ b/app/components/account-card/template.hbs @@ -2,6 +2,10 @@
{{#if account.id}} {{#if hideHistory}} + {{#link-to 'wallets.overview.accounts.settings' account bubbles=false class='settings' title=(t 'accountSettings')}} + {{bs-tooltip fade=true delayShow=500 placement='top' title=(t 'accountSettings')}} + {{fa-icon 'cog' ariaLabel=(t 'accountSettings')}} + {{/link-to}} {{qr-code text=account.id width=170 height=170}} {{/if}}

@@ -12,10 +16,10 @@
+{{format-amount account.pending}}

-
- {{bs-tooltip fade=true delayShow=1000 placement='bottom' title=(t 'copyValue' value=(concat (slice 0 9 account.id)))}} - {{#copy-button tagName='div' buttonType=null clipboardText=account.id success=(action 'copyAddress' (concat (slice 0 9 account.id) '...' (slice 59 64 account.id)))}} - {{account-address value=account.id}} +
+ {{bs-tooltip fade=true delayShow=1000 placement='bottom' title=(t 'copyAddress')}} + {{#copy-button tagName='div' class="d-flex flex-column justify-content-center" buttonType=null clipboardText=account.id success=(action 'copyAddress' (concat (slice 0 9 account.id) '...' (slice 59 64 account.id)))}} + {{account-label class="flex-row w-100 align-self-center" account=account}} {{/copy-button}}
{{else}} diff --git a/app/components/account-label/component.js b/app/components/account-label/component.js new file mode 100644 index 00000000..06448346 --- /dev/null +++ b/app/components/account-label/component.js @@ -0,0 +1,9 @@ +import Component from '@ember/component'; + +import { storageFor } from 'ember-local-storage'; + +export default Component.extend({ + settings: storageFor('settings', 'account'), + + account: null, +}); diff --git a/app/components/account-label/styles.scss b/app/components/account-label/styles.scss new file mode 100644 index 00000000..0b2fcf5c --- /dev/null +++ b/app/components/account-label/styles.scss @@ -0,0 +1,2 @@ +& { +} diff --git a/app/components/account-label/template.hbs b/app/components/account-label/template.hbs new file mode 100644 index 00000000..e4b3ea34 --- /dev/null +++ b/app/components/account-label/template.hbs @@ -0,0 +1,7 @@ +{{#if settings.label}} + {{settings.label}} +
+ {{account-address value=account.id truncate=true}} +{{else}} + {{account-address value=account.id}} +{{/if}} diff --git a/app/components/account-settings/component.js b/app/components/account-settings/component.js new file mode 100644 index 00000000..86754b6a --- /dev/null +++ b/app/components/account-settings/component.js @@ -0,0 +1,26 @@ +import Component from '@ember/component'; +import { get } from '@ember/object'; +import { tryInvoke } from '@ember/utils'; + +import { storageFor } from 'ember-local-storage'; + +import { action } from 'ember-decorators/object'; + +import ChangeAccountSettingsValidations from '../../validations/change-account-settings'; + +export default Component.extend({ + ChangeAccountSettingsValidations, + + settings: storageFor('settings', 'account'), + + account: null, + onSave: null, + onCancel: null, + + @action + save(changeset) { + const settings = this.get('settings'); + const label = get(changeset, 'label'); + tryInvoke(settings, 'setProperties', [{ label }]); + }, +}); diff --git a/app/components/account-settings/template.hbs b/app/components/account-settings/template.hbs new file mode 100644 index 00000000..98116c4c --- /dev/null +++ b/app/components/account-settings/template.hbs @@ -0,0 +1,27 @@ +{{#with (changeset (hash label=settings.label) ChangeAccountSettingsValidations) as |model|}} + {{#bs-modal onHide=(action (optional onCancel)) as |modal|}} + {{#modal.header}} + + {{/modal.header}} + {{#modal.body}} + {{#bs-form model=model onSubmit=(action (queue (action 'save' model) (action (optional onSave)))) as |form|}} +
+ + {{account-address class="form-control-plaintext" value=account.id truncate=true}} +
+ {{form.element controlType="text" label=(t 'label') property="label"}} + {{/bs-form}} + {{/modal.body}} + {{#modal.footer}} + {{#bs-button onClick=(action modal.close) type="secondary"}} + {{t 'cancel'}} + {{/bs-button}} + {{#bs-button type="primary" buttonType='submit'}} + {{fa-icon 'check'}} + {{t 'save'}} + {{/bs-button}} + {{/modal.footer}} + {{/bs-modal}} +{{/with}} diff --git a/app/components/navigation-bar/template.hbs b/app/components/navigation-bar/template.hbs index 334a7a4a..6685c480 100644 --- a/app/components/navigation-bar/template.hbs +++ b/app/components/navigation-bar/template.hbs @@ -29,7 +29,7 @@