Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Oct 27, 2017
2 parents 26aa020 + bc03067 commit f22be1a
Show file tree
Hide file tree
Showing 25 changed files with 121 additions and 92 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
]
}
],
"linebreak-style": 0,
"no-param-reassign": "off"
}
}
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ node('lisk-nano') {
stage ('Run Eslint') {
try {
ansiColor('xterm') {
sh 'npm run --silent clean && npm run --silent copy-files && npm run --silent eslint'
sh 'npm run --silent clean-build && npm run --silent copy-files && npm run --silent eslint'
}
} catch (err) {
echo "Error: ${err}"
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,26 +58,26 @@ npm run start

### Windows

Build package for Windows.
Build package for Windows (on Windows in [Git BASH](https://git-for-windows.github.io/)).

```
npm run dist:win
npm run pack:win
```

### macOS

Build package for macOS.
Build package for macOS (on macOs)

```
npm run dist:mac
npm run pack
```

### Linux

Build package for Linux.
Build package for Linux (on Linux).

```
npm run dist:linux
npm run pack
```

## Run unit tests
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lisk-nano",
"version": "1.2.0",
"version": "1.2.1",
"description": "Lisk Nano",
"main": "./build/main.js",
"author":{
Expand Down
8 changes: 4 additions & 4 deletions app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ function createWindow() {
win.on('blur', () => win.webContents.send('blur'));
win.on('focus', () => win.webContents.send('focus'));

if (process.platform === 'win32') {
sendUrlToRouter(process.argv.slice(1));
if (process.platform !== 'darwin') {
sendUrlToRouter(process.argv[1] || '/');
}

Menu.setApplicationMenu(buildMenu(app, copyright, i18n));
Expand Down Expand Up @@ -142,8 +142,8 @@ app.setAsDefaultProtocolClient(protocolName);

// Force single instance application
const isSecondInstance = app.makeSingleInstance((argv) => {
if (process.platform === 'win32') {
sendUrlToRouter(argv.slice(1));
if (process.platform !== 'darwin') {
sendUrlToRouter(argv[1] || '/');
}
if (win) {
if (win.isMinimized()) win.restore();
Expand Down
2 changes: 1 addition & 1 deletion app/src/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ module.exports = (app, copyright, i18n) => {
if (focusedWindow) {
const options = {
buttons: ['OK'],
icon: `${__dirname}/assets/images/lisk.png`,
icon: `${__dirname}/assets/images/LISK.png`,
message: `${i18n.t('Lisk Nano')}\n${i18n.t('Version')} ${app.getVersion()}\n${copyright}`,
};
electron.dialog.showMessageBox(focusedWindow, options, () => {});
Expand Down
8 changes: 1 addition & 7 deletions features/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"extends": "airbnb-base",
"plugins": [
"import"
],
"extends": "../.eslintrc",
"env": {
"protractor": true
},
"rules": {
"no-underscore-dangle": "off"
}
}
21 changes: 15 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
{
"name": "lisk-nano",
"version": "1.2.0",
"version": "1.2.1",
"description": "Lisk Nano",
"homepage": "https://github.com/LiskHQ/lisk-nano",
"bugs": "https://github.com/LiskHQ/lisk-nano/issues",
"main": "main.js",
"scripts": {
"build": "npm run clean && npm run copy-files && npm run build-prod && npm run build-electron",
"build": "npm run clean-build && npm run copy-files && npm run build-prod && npm run build-electron",
"dev": "webpack-dev-server --config ./config/webpack.config.dev --env.dev --hot",
"build-prod": "webpack --config ./config/webpack.config.prod --env.prod",
"build-electron": "webpack --config ./config/webpack.config.electron",
"e2e-test": "protractor protractor.conf.js",
"test": "karma start",
"test-live": "npm test -- --auto-watch --no-single-run",
"start": "electron ./app/",
"dist": "build --ia32 --x64 --armv7l",
"dist:win": "build --win --ia32 --x64",
"dist:mac": "build --mac",
"dist:linux": "build --linux --ia32 --x64 --armv7l",
"copy-files": "mkdir app/build && cp -r ./src/index.html ./src/assets ./src/locales ./app/build",
"clean": "del app/build -f",
"copy-files": "cpx \"./src/{index.html,assets/**/*,locales/**/*}\" ./app/build/",
"clean-build": "rm -rf app/build",
"clean-dist": "rm -rf dist",
"eslint": "eslint ./src/ ./app/src/ ./app/config/ ./features/",
"pack": "npm install && npm run build && npm run clean-dist && npm run dist",
"pack:win": "cmd /c npm install && npm run clean-build && npm run copy-files && npm run build-prod && npm run build-electron && npm run clean-dist && npm run dist:win",
"storybook": "start-storybook -p 6006 -s ./src/",
"i18n-scanner": "node ./src/i18n-scanner.js",
"build-storybook": "build-storybook"
Expand Down Expand Up @@ -75,11 +79,12 @@
"chai": "4.1.2",
"chai-as-promised": "7.1.1",
"chai-enzyme": "0.8.0",
"cpx": "=1.5.0",
"css-hot-loader": "=1.3.1",
"css-loader": "0.28.7",
"cucumber": "2.2.0",
"del-cli": "1.1.0",
"electron": "1.7.8",
"electron": "1.8.1",
"electron-builder": "19.32.2",
"electron-json-storage": "^3.2.0",
"enzyme": "2.9.1",
Expand Down Expand Up @@ -149,7 +154,11 @@
"deb",
"rpm",
"tar.gz"
]
],
"desktop": {
"MimeType": "application/lisk;x-scheme-handler/lisk"
},
"category": "Network"
},
"win": {
"target": "nsis"
Expand Down
10 changes: 7 additions & 3 deletions src/actions/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Lisk from 'lisk-js';
import actionTypes from '../constants/actions';
import { getNethash } from './../utils/api/nethash';
import { errorToastDisplayed } from './toaster';
import netHashes from '../constants/netHashes';

const peerSet = (data, config) => ({
data: Object.assign({
Expand Down Expand Up @@ -33,15 +34,18 @@ export const activePeerSet = data =>
const { hostname, port, protocol } = new URL(addHttp(config.address));

config.node = hostname;
config.port = port;
config.ssl = protocol === 'https';
config.ssl = protocol === 'https:';
config.port = port || (config.ssl ? 443 : 80);
}
if (config.testnet === undefined && config.port !== undefined) {
config.testnet = config.port === '7000';
}
if (config.custom) {
getNethash(Lisk.api(config)).then((response) => {
config.nethash = response.nethash;
config.testnet = response.nethash === netHashes.testnet;
if (!config.testnet && response.nethash !== netHashes.mainnet) {
config.nethash = response.nethash;
}
dispatch(peerSet(data, config));
}).catch(() => {
dispatch(errorToastDisplayed({ label: i18next.t('Unable to connect to the node') }));
Expand Down
20 changes: 17 additions & 3 deletions src/actions/peers.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { expect } from 'chai';
import { spy, stub, match } from 'sinon';
import actionTypes from '../constants/actions';
import netHashes from '../constants/netHashes';
import { activePeerSet, activePeerUpdate } from './peers';
import * as nethashApi from './../utils/api/nethash';

Expand Down Expand Up @@ -63,17 +64,30 @@ describe('actions: peers', () => {
expect(dispatch).to.have.been.calledWith(match.hasNested('data.activePeer.options.address', 'localhost:8000'));
});

it('dispatch activePeerSet with nethash from response when the network is a custom node', () => {
it('dispatch activePeerSet with testnet config set to true when the network is a custom node and nethash is testnet', () => {
getNetHash.returnsPromise();
const network = {
address: 'http://localhost:4000',
custom: true,
};

activePeerSet({ passphrase, network })(dispatch);
getNetHash.resolves({ nethash: 'nethash from response' });
getNetHash.resolves({ nethash: netHashes.testnet });

expect(dispatch).to.have.been.calledWith(match.hasNested('data.activePeer.nethash.nethash', 'nethash from response'));
expect(dispatch).to.have.been.calledWith(match.hasNested('data.activePeer.testnet', true));
});

it('dispatch activePeerSet with testnet config set to false when the network is a custom node and nethash is testnet', () => {
getNetHash.returnsPromise();
const network = {
address: 'http://localhost:4000',
custom: true,
};

activePeerSet({ passphrase, network })(dispatch);
getNetHash.resolves({ nethash: 'some other nethash' });

expect(dispatch).to.have.been.calledWith(match.hasNested('data.activePeer.testnet', false));
});

it('dispatch activePeerSet action even if network is undefined', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/account/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Account = ({
{status}
</span>
<p className="inner primary peer-network">
{peers.data.options.name}
{t(peers.data.options.name)}
</p>
<p className="inner secondary peer">
{peers.data.currentPeer}
Expand Down
14 changes: 11 additions & 3 deletions src/components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import grid from 'flexboxgrid/dist/flexboxgrid.css';
import Input from 'react-toolbox/lib/input';
import Dropdown from 'react-toolbox/lib/dropdown';
import Button from 'react-toolbox/lib/button';
import i18next from 'i18next';
import getNetworks from './networks';
import PassphraseInput from '../passphraseInput';
import styles from './login.css';
Expand Down Expand Up @@ -33,12 +34,19 @@ class Login extends React.Component {
}

componentWillMount() {
this.getNetworksList();
i18next.on('languageChanged', () => {
this.getNetworksList();
});

this.props.accountsRetrieved();
}

getNetworksList() {
this.networks = getNetworks().map((network, index) => ({
label: network.name,
label: i18next.t(network.name),
value: index,
}));

this.props.accountsRetrieved();
}

componentDidUpdate() {
Expand Down
14 changes: 6 additions & 8 deletions src/components/login/networks.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import i18next from 'i18next';

export default () => ([
{
name: i18next.t('Mainnet'),
{// network name translation t('Mainnet');
name: 'Mainnet',
ssl: true,
port: 443,
}, {
name: i18next.t('Testnet'),
}, {// network name translation t('Testnet');
name: 'Testnet',
testnet: true,
ssl: true,
port: 443,
}, {
name: i18next.t('Custom Node'),
}, {// network name translation t('Custom Node');
name: 'Custom Node',
custom: true,
address: 'http://localhost:4000',
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/passphraseInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class PassphraseInput extends React.Component {
return (
<div className={styles.wrapper}>
<Input label={this.props.label} required={true}
className={this.props.className}
className={`${this.props.className} ${styles.inputWrapper}`}
error={this.props.error}
value={this.props.value || ''}
type={this.state.inputType}
Expand Down
4 changes: 4 additions & 0 deletions src/components/passphraseInput/passphraseInput.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
height: 24px;
cursor: pointer;
}

.inputWrapper input {
padding-right: 35px;
}
14 changes: 5 additions & 9 deletions src/components/voteDialog/voteDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import InfoParagraph from '../infoParagraph';
import VoteUrlProcessor from '../voteUrlProcessor';
import styles from './voteDialog.css';
import votingConst from '../../constants/voting';
import { getTotalVotesCount, getNewVotesCount } from '../../utils/voting';

const { maxCountOfVotes, maxCountOfVotesInOneTurn } = votingConst;

Expand Down Expand Up @@ -43,12 +44,7 @@ export default class VoteDialog extends React.Component {

render() {
const { votes } = this.props;
let totalVotes = 0;
const votesList = [];
Object.keys(votes).forEach((item) => {
if (votes[item].confirmed || votes[item].unconfirmed) totalVotes++;
if (votes[item].confirmed !== votes[item].unconfirmed) votesList.push(item);
});
const countOfVotesInOneTurn = getNewVotesCount(votes);
return (
<article>
<form id='voteform'>
Expand Down Expand Up @@ -83,9 +79,9 @@ export default class VoteDialog extends React.Component {
fee: Fees.vote,
type: 'button',
disabled: (
totalVotes > maxCountOfVotes ||
votesList.length === 0 ||
votesList.length > maxCountOfVotesInOneTurn ||
getTotalVotesCount(votes) > maxCountOfVotes ||
countOfVotesInOneTurn === 0 ||
countOfVotesInOneTurn > maxCountOfVotesInOneTurn ||
!authStateIsValid(this.state)
),
}} />
Expand Down
4 changes: 0 additions & 4 deletions src/components/voteUrlProcessor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { withRouter } from 'react-router';
import {
urlVotesFound,
voteLookupStatusCleared,
voteToggled,
votesAdded,
} from '../../actions/voting';
import VoteUrlProcessor from './voteUrlProcessor';

Expand All @@ -28,8 +26,6 @@ const mapStateToProps = state => ({
});

const mapDispatchToProps = dispatch => ({
voteToggled: data => dispatch(voteToggled(data)),
votesAdded: data => dispatch(votesAdded(data)),
urlVotesFound: data => dispatch(urlVotesFound(data)),
clearVoteLookupStatus: () => dispatch(voteLookupStatusCleared()),
});
Expand Down
14 changes: 0 additions & 14 deletions src/components/voteUrlProcessor/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ describe('VoteUrlProcessorHOC', () => {
expect(wrapper.find(VoteUrlProcessor)).to.have.lengthOf(1);
});

it('should bind voteToggled action to VoteUrlProcessor props.voteToggled', () => {
const actionsSpy = sinon.spy(votingActions, 'voteToggled');
wrapper.find(VoteUrlProcessor).props().voteToggled(actionData);
expect(actionsSpy).to.be.calledWith(actionData);
actionsSpy.restore();
});

it('should bind votesAdded action to VoteUrlProcessor props.votesAdded', () => {
const actionsSpy = sinon.spy(votingActions, 'votesAdded');
wrapper.find(VoteUrlProcessor).props().votesAdded(actionData);
expect(actionsSpy).to.be.calledWith(actionData);
actionsSpy.restore();
});

it('should bind urlVotesFound action to VoteUrlProcessor props.urlVotesFound', () => {
const actionMock = sinon.mock(votingActions);
actionMock.expects('urlVotesFound').withExactArgs(actionData).returns({ type: 'DUMMY' });
Expand Down
Loading

0 comments on commit f22be1a

Please sign in to comment.