From 9e210e5eda80f11a0a5f93a742d9ff8a173b06a2 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 20 Feb 2017 16:40:01 +0100 Subject: [PATCH] Vault Management UI (first round) (#4446) * Add RPCs for parity_vault (create, open, list, etc.) * WIP * WIP * WIP * WIP (create should create) * Create & close working * WIP * WIP * WIP * Open & Close now working * WIP * WIP * Merge relevant changes from js-home * Hover actions * WIP (start of account assignment) * Open, Close & Account assignment works * Fix margins * UI updates * Update tests * Add the parity_{get|set}VaultMeta calls * Handle metadata * Adjust padding in Open/Close modals * moveAccounts take both in and out * Adjust padding * Fix stretch * Optimize hover stretch * pre-merge * Cleanup variable naming (duplication) * Rename Vault{Close,Open} -> Vault{Lock,Unlock} * clearVaultFields uses setters * TODO for small Portal sizes * Vaults rendering tests * .only * libusb compile * VaultCard rendering tests * Update message keys (rename gone rouge) * Display passwordHint op vault unlock * Update failing tests * Manually dispatch allAccountsInfo when move completed * Open/Close always shows vault image in colour * Password submit submits modal (PR comment) * Add link to account --- js/src/api/subscriptions/personal.js | 1 - js/src/modals/CreateAccount/createAccount.css | 29 +- js/src/modals/CreateAccount/errors.js | 19 +- js/src/modals/VaultAccounts/index.js | 17 + js/src/modals/VaultAccounts/vaultAccounts.css | 48 ++ js/src/modals/VaultAccounts/vaultAccounts.js | 195 +++++++ .../VaultAccounts/vaultAccounts.spec.js | 179 ++++++ js/src/modals/VaultCreate/index.js | 17 + js/src/modals/VaultCreate/vaultCreate.css | 38 ++ js/src/modals/VaultCreate/vaultCreate.js | 227 ++++++++ js/src/modals/VaultCreate/vaultCreate.spec.js | 162 ++++++ js/src/modals/VaultLock/index.js | 17 + js/src/modals/VaultLock/vaultLock.js | 92 ++++ js/src/modals/VaultLock/vaultLock.spec.js | 131 +++++ js/src/modals/VaultUnlock/index.js | 17 + js/src/modals/VaultUnlock/vaultUnlock.css | 27 + js/src/modals/VaultUnlock/vaultUnlock.js | 118 ++++ js/src/modals/VaultUnlock/vaultUnlock.spec.js | 146 +++++ js/src/modals/index.js | 64 +-- js/src/routes.js | 3 +- js/src/ui/ConfirmDialog/confirmDialog.css | 1 + js/src/ui/ConfirmDialog/confirmDialog.js | 59 +- js/src/ui/ConfirmDialog/confirmDialog.spec.js | 112 ++-- js/src/ui/Container/Title/title.css | 4 + js/src/ui/Container/container.css | 18 +- js/src/ui/Icons/index.js | 3 + js/src/ui/Icons/index.spec.js | 28 + js/src/ui/Page/page.js | 24 +- js/src/ui/Page/page.spec.js | 79 +++ js/src/ui/Portal/portal.css | 29 +- js/src/ui/Portal/portal.js | 6 +- js/src/ui/Title/title.css | 9 +- js/src/ui/Title/title.js | 14 +- js/src/ui/Title/title.spec.js | 90 +++ js/src/ui/VaultCard/Layout/index.js | 17 + js/src/ui/VaultCard/Layout/layout.css | 45 ++ js/src/ui/VaultCard/Layout/layout.js | 66 +++ js/src/ui/VaultCard/Layout/layout.spec.js | 90 +++ js/src/ui/VaultCard/index.js | 17 + js/src/ui/VaultCard/vaultCard.css | 62 +++ js/src/ui/VaultCard/vaultCard.js | 102 ++++ js/src/ui/VaultCard/vaultCard.spec.js | 94 ++++ js/src/ui/index.js | 1 + js/src/views/Accounts/accounts.js | 47 +- js/src/views/Vaults/index.js | 17 + js/src/views/Vaults/store.js | 323 +++++++++++ js/src/views/Vaults/store.spec.js | 516 ++++++++++++++++++ js/src/views/Vaults/vaults.css | 25 + js/src/views/Vaults/vaults.js | 193 +++++++ js/src/views/Vaults/vaults.spec.js | 185 +++++++ js/src/views/Vaults/vaults.test.js | 90 +++ js/src/views/index.js | 1 + 52 files changed, 3722 insertions(+), 192 deletions(-) create mode 100644 js/src/modals/VaultAccounts/index.js create mode 100644 js/src/modals/VaultAccounts/vaultAccounts.css create mode 100644 js/src/modals/VaultAccounts/vaultAccounts.js create mode 100644 js/src/modals/VaultAccounts/vaultAccounts.spec.js create mode 100644 js/src/modals/VaultCreate/index.js create mode 100644 js/src/modals/VaultCreate/vaultCreate.css create mode 100644 js/src/modals/VaultCreate/vaultCreate.js create mode 100644 js/src/modals/VaultCreate/vaultCreate.spec.js create mode 100644 js/src/modals/VaultLock/index.js create mode 100644 js/src/modals/VaultLock/vaultLock.js create mode 100644 js/src/modals/VaultLock/vaultLock.spec.js create mode 100644 js/src/modals/VaultUnlock/index.js create mode 100644 js/src/modals/VaultUnlock/vaultUnlock.css create mode 100644 js/src/modals/VaultUnlock/vaultUnlock.js create mode 100644 js/src/modals/VaultUnlock/vaultUnlock.spec.js create mode 100644 js/src/ui/Icons/index.spec.js create mode 100644 js/src/ui/Page/page.spec.js create mode 100644 js/src/ui/Title/title.spec.js create mode 100644 js/src/ui/VaultCard/Layout/index.js create mode 100644 js/src/ui/VaultCard/Layout/layout.css create mode 100644 js/src/ui/VaultCard/Layout/layout.js create mode 100644 js/src/ui/VaultCard/Layout/layout.spec.js create mode 100644 js/src/ui/VaultCard/index.js create mode 100644 js/src/ui/VaultCard/vaultCard.css create mode 100644 js/src/ui/VaultCard/vaultCard.js create mode 100644 js/src/ui/VaultCard/vaultCard.spec.js create mode 100644 js/src/views/Vaults/index.js create mode 100644 js/src/views/Vaults/store.js create mode 100644 js/src/views/Vaults/store.spec.js create mode 100644 js/src/views/Vaults/vaults.css create mode 100644 js/src/views/Vaults/vaults.js create mode 100644 js/src/views/Vaults/vaults.spec.js create mode 100644 js/src/views/Vaults/vaults.test.js diff --git a/js/src/api/subscriptions/personal.js b/js/src/api/subscriptions/personal.js index c1f070262..15b037b42 100644 --- a/js/src/api/subscriptions/personal.js +++ b/js/src/api/subscriptions/personal.js @@ -119,7 +119,6 @@ export default class Personal { case 'parity_removeAddress': case 'parity_setAccountName': case 'parity_setAccountMeta': - case 'parity_changeVault': this._accountsInfo(); return; diff --git a/js/src/modals/CreateAccount/createAccount.css b/js/src/modals/CreateAccount/createAccount.css index 5c8bc7e5c..d58e0edfd 100644 --- a/js/src/modals/CreateAccount/createAccount.css +++ b/js/src/modals/CreateAccount/createAccount.css @@ -19,23 +19,24 @@ line-height: 1.618em; } -.password { - flex: 0 1 50%; - width: 50%; - box-sizing: border-box; - - &:nth-child(odd) { - padding-right: 0.25rem; - } - - &:nth-child(even) { - padding-left: 0.25rem; - } -} - +/* TODO: 2 column layout can be made generic, now duplicated in Vaults */ .passwords { display: flex; flex-wrap: wrap; + + .password { + box-sizing: border-box; + flex: 0 1 50%; + width: 50%; + + &:nth-child(odd) { + padding-right: 0.25rem; + } + + &:nth-child(even) { + padding-left: 0.25rem; + } + } } .identities, .selector { diff --git a/js/src/modals/CreateAccount/errors.js b/js/src/modals/CreateAccount/errors.js index 487bf9729..bb5708275 100644 --- a/js/src/modals/CreateAccount/errors.js +++ b/js/src/modals/CreateAccount/errors.js @@ -18,37 +18,44 @@ import React from 'react'; import { FormattedMessage } from 'react-intl'; export default { + duplicateName: ( + + ), + noFile: ( ), noKey: ( ), noMatchPassword: ( ), noName: ( ), invalidKey: ( ) diff --git a/js/src/modals/VaultAccounts/index.js b/js/src/modals/VaultAccounts/index.js new file mode 100644 index 000000000..506a569f3 --- /dev/null +++ b/js/src/modals/VaultAccounts/index.js @@ -0,0 +1,17 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +export default from './vaultAccounts'; diff --git a/js/src/modals/VaultAccounts/vaultAccounts.css b/js/src/modals/VaultAccounts/vaultAccounts.css new file mode 100644 index 000000000..1960376f3 --- /dev/null +++ b/js/src/modals/VaultAccounts/vaultAccounts.css @@ -0,0 +1,48 @@ +/* Copyright 2015-2017 Parity Technologies (UK) Ltd. +/* This file is part of Parity. +/* +/* Parity is free software: you can redistribute it and/or modify +/* it under the terms of the GNU General Public License as published by +/* the Free Software Foundation, either version 3 of the License, or +/* (at your option) any later version. +/* +/* Parity is distributed in the hope that it will be useful, +/* but WITHOUT ANY WARRANTY; without even the implied warranty of +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +/* GNU General Public License for more details. +/* +/* You should have received a copy of the GNU General Public License +/* along with Parity. If not, see . +*/ + +/* TODO: These overlap with DappPermissions now, make DRY */ +/* (selection component or just styles?) */ +.iconDisabled { + opacity: 0.15; +} + +.item { + display: flex; + flex: 1; + position: relative; + + .overlay { + position: absolute; + right: 0.5em; + top: 0.5em; + } +} + +.selected, +.unselected { + margin-bottom: 0.25em; + width: 100%; + + &:focus { + outline: none; + } +} + +.selected { + background: rgba(255, 255, 255, 0.15) !important; +} diff --git a/js/src/modals/VaultAccounts/vaultAccounts.js b/js/src/modals/VaultAccounts/vaultAccounts.js new file mode 100644 index 000000000..96f170f79 --- /dev/null +++ b/js/src/modals/VaultAccounts/vaultAccounts.js @@ -0,0 +1,195 @@ +// Copyright 2015-2017 Parity Technologies (UK) Ltd. +// This file is part of Parity. + +// Parity is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// Parity is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with Parity. If not, see . + +import { observer } from 'mobx-react'; +import React, { Component, PropTypes } from 'react'; +import { FormattedMessage } from 'react-intl'; +import { connect } from 'react-redux'; +import { bindActionCreators } from 'redux'; + +import { newError } from '~/redux/actions'; +import { personalAccountsInfo } from '~/redux/providers/personalActions'; +import { AccountCard, Button, Portal, SectionList } from '~/ui'; +import { CancelIcon, CheckIcon } from '~/ui/Icons'; + +import styles from './vaultAccounts.css'; + +@observer +class VaultAccounts extends Component { + static contextTypes = { + api: PropTypes.object.isRequired + }; + + static propTypes = { + accounts: PropTypes.object.isRequired, + newError: PropTypes.func.isRequired, + personalAccountsInfo: PropTypes.func.isRequired, + vaultStore: PropTypes.object.isRequired + }; + + render () { + const { accounts } = this.props; + const { isBusyAccounts, isModalAccountsOpen, selectedAccounts } = this.props.vaultStore; + + if (!isModalAccountsOpen) { + return null; + } + + const vaultAccounts = Object + .keys(accounts) + .filter((address) => accounts[address].uuid) + .map((address) => accounts[address]); + + return ( + } + key='cancel' + label={ + + } + onClick={ this.onClose } + />, +