From 097fcd8ce7e7514d1b76471208b3c50e300838d1 Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Wed, 8 Nov 2017 15:06:53 +0100 Subject: [PATCH] Remove saveAccountButton and use route directly --- src/components/dialog/dialogs.js | 4 +- src/components/header/header.js | 6 ++- src/components/header/header.test.js | 4 +- src/components/saveAccountButton/index.js | 19 -------- .../saveAccountButton/index.test.js | 45 ----------------- .../saveAccountButton/saveAccountButton.js | 18 ------- .../saveAccountButton.test.js | 48 ------------------- 7 files changed, 8 insertions(+), 136 deletions(-) delete mode 100644 src/components/saveAccountButton/index.js delete mode 100644 src/components/saveAccountButton/index.test.js delete mode 100644 src/components/saveAccountButton/saveAccountButton.js delete mode 100644 src/components/saveAccountButton/saveAccountButton.test.js diff --git a/src/components/dialog/dialogs.js b/src/components/dialog/dialogs.js index 95f1ea0fd..a6a76c0ed 100644 --- a/src/components/dialog/dialogs.js +++ b/src/components/dialog/dialogs.js @@ -45,8 +45,8 @@ export default () => ({ title: i18next.t('New Account'), component: Register, }, - 'save-account': { - title: i18next.t('Remember this account'), + 'saved-accounts': { + title: i18next.t('Saved accounts'), component: SaveAccount, }, settings: { diff --git a/src/components/header/header.js b/src/components/header/header.js index 2765976c9..86ac4f3e9 100644 --- a/src/components/header/header.js +++ b/src/components/header/header.js @@ -4,7 +4,6 @@ import React from 'react'; import grid from 'flexboxgrid/dist/flexboxgrid.css'; import PrivateWrapper from '../privateWrapper'; -import SaveAccountButton from '../saveAccountButton'; import logo from '../../assets/images/LISK-nano.png'; import offlineStyle from '../offlineWrapper/offlineWrapper.css'; import styles from './header.css'; @@ -53,7 +52,10 @@ const Header = props => ( to='decrypt-message'>{props.t('Decrypt message')} - + + {props.t('Saved accounts')} + {props.t('Settings')} diff --git a/src/components/header/header.test.js b/src/components/header/header.test.js index 2550a535e..f5c0c6772 100644 --- a/src/components/header/header.test.js +++ b/src/components/header/header.test.js @@ -45,8 +45,8 @@ describe('Header', () => { expect(wrapper.find(Button)).to.have.length(1); }); - it('renders 9 RelativeLink components', () => { - expect(wrapper.find(RelativeLink)).to.have.length(9); + it('renders 10 RelativeLink components', () => { + expect(wrapper.find(RelativeLink)).to.have.length(10); }); it('should have an image with source of "logo"', () => { diff --git a/src/components/saveAccountButton/index.js b/src/components/saveAccountButton/index.js deleted file mode 100644 index 2d3aec1a4..000000000 --- a/src/components/saveAccountButton/index.js +++ /dev/null @@ -1,19 +0,0 @@ -import { connect } from 'react-redux'; -import { translate } from 'react-i18next'; - -import { accountRemoved } from '../../actions/savedAccounts'; -import SaveAccountButton from './saveAccountButton'; - -const mapStateToProps = state => ({ - account: state.account, - savedAccounts: state.savedAccounts, -}); - -const mapDispatchToProps = dispatch => ({ - accountRemoved: data => dispatch(accountRemoved(data)), -}); - -export default connect( - mapStateToProps, - mapDispatchToProps, -)(translate()(SaveAccountButton)); diff --git a/src/components/saveAccountButton/index.test.js b/src/components/saveAccountButton/index.test.js deleted file mode 100644 index b3422cc06..000000000 --- a/src/components/saveAccountButton/index.test.js +++ /dev/null @@ -1,45 +0,0 @@ -import React from 'react'; -import { expect } from 'chai'; -import { mount } from 'enzyme'; -import configureMockStore from 'redux-mock-store'; -import { BrowserRouter as Router } from 'react-router-dom'; -import PropTypes from 'prop-types'; -import i18n from '../../i18n'; -import SaveAccountButtonHOC from './index'; -import SaveAccountButton from './saveAccountButton'; - -describe('SaveAccountButtonHOC', () => { - let props; - let wrapper; - - const account = { - isDelegate: false, - publicKey: 'sample_key', - username: 'lisk-nano', - }; - const savedAccounts = []; - const store = configureMockStore([])({ - savedAccounts, - account, - activePeerSet: () => {}, - }); - - beforeEach(() => { - wrapper = mount(, { - context: { store, i18n }, - childContextTypes: { - store: PropTypes.object.isRequired, - i18n: PropTypes.object.isRequired, - }, - }); - props = wrapper.find(SaveAccountButton).props(); - }); - - it('should render the SaveAccountButton with props.successToast and props.setActiveDialog', () => { - expect(wrapper.find(SaveAccountButton).exists()).to.equal(true); - expect(props.account).to.equal(account); - expect(props.savedAccounts).to.equal(savedAccounts); - expect(typeof props.accountRemoved).to.equal('function'); - }); -}); - diff --git a/src/components/saveAccountButton/saveAccountButton.js b/src/components/saveAccountButton/saveAccountButton.js deleted file mode 100644 index 1ef4098b7..000000000 --- a/src/components/saveAccountButton/saveAccountButton.js +++ /dev/null @@ -1,18 +0,0 @@ -import { MenuItem } from 'react-toolbox/lib/menu'; -import React from 'react'; -import RelativeLink from '../relativeLink'; - -const SaveAccountButton = ({ account, savedAccounts, accountRemoved, t, theme }) => - (savedAccounts.length > 0 ? - : - - - {t('Save account')} - - - ); - -export default SaveAccountButton; diff --git a/src/components/saveAccountButton/saveAccountButton.test.js b/src/components/saveAccountButton/saveAccountButton.test.js deleted file mode 100644 index 5e7239123..000000000 --- a/src/components/saveAccountButton/saveAccountButton.test.js +++ /dev/null @@ -1,48 +0,0 @@ -import React from 'react'; -import { expect } from 'chai'; -import { mount } from 'enzyme'; -import sinon from 'sinon'; -import PropTypes from 'prop-types'; -import configureMockStore from 'redux-mock-store'; -import { BrowserRouter as Router } from 'react-router-dom'; -import SaveAccountButton from './saveAccountButton'; - -describe('SaveAccountButton', () => { - const account = { publicKey: 'sampleKey' }; - const emptySavedAccounts = []; - const savedAccounts = [account]; - const props = { - theme: { - menuLink: 'some class', - menuItem: 'some other class', - }, - account, - accountRemoved: sinon.spy(), - t: key => key, - }; - - - const store = configureMockStore([])({ - account, - activePeerSet: () => {}, - }); - const options = { - context: { store }, - childContextTypes: { - store: PropTypes.object.isRequired, - }, - }; - - it('fires accountRemoved action if an account is already saved', () => { - const wrapper = mount( - , options); - wrapper.find('MenuItem').simulate('click'); - expect(props.accountRemoved).to.have.been.calledWith(); - }); - - it('Allows to open SaveAccount modal if account not yet saved', () => { - const wrapper = mount( - , options); - expect(wrapper.find('RelativeLink').exists()).to.equal(true); - }); -});