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

Commit

Permalink
Merge branch '1.2.1' into 907-fix-error-in-about-dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Oct 27, 2017
2 parents fbdb2ec + 5bf5b69 commit 36afb37
Show file tree
Hide file tree
Showing 21 changed files with 97 additions and 73 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"
}
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ 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 pack:win
```

### macOS

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

```
npm run pack
```

### Linux

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

```
npm run pack
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
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"
}
}
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"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 @@ -154,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;
}
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
8 changes: 4 additions & 4 deletions src/components/voteUrlProcessor/voteUrlProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class VoteUrlProcessor extends React.Component {
}
}

getProccessedCount() {
getProcessedCount() {
return this.props.urlVoteCount - this.props.pending.length;
}

Expand All @@ -42,13 +42,13 @@ export default class VoteUrlProcessor extends React.Component {
};
return (
<div>
{this.getProccessedCount() < this.props.urlVoteCount ?
{this.getProcessedCount() < this.props.urlVoteCount ?
(<div>
<ProgressBar type='linear' mode='determinate'
value={this.getProccessedCount()} max={this.props.urlVoteCount}/>
value={this.getProcessedCount()} max={this.props.urlVoteCount}/>
<div className={styles.center}>
{this.props.t('Processing delegate names: ')}
{this.getProccessedCount()} / {this.props.urlVoteCount}
{this.getProcessedCount()} / {this.props.urlVoteCount}
</div>
</div>) :
(<span>{Object.keys(errorMessages).map(list => (
Expand Down
9 changes: 4 additions & 5 deletions src/components/voting/voting.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ class Voting extends React.Component {
}

componentWillUpdate(nextProps) {
setTimeout(() => {
if (this.props.refreshDelegates) {
this.loadVotedDelegates(true);
}
}, 1);
if (!this.props.refreshDelegates && nextProps.refreshDelegates) {
this.loadVotedDelegates(true);
}

if (this.props.delegates.length < nextProps.delegates.length) {
setTimeout(() => {
this.freezeLoading = false;
Expand Down
10 changes: 4 additions & 6 deletions src/components/voting/votingBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ import grid from 'flexboxgrid/dist/flexboxgrid.css';

import style from './votingBar.css';
import votingConst from '../../constants/voting';
import { getTotalVotesCount, getVoteList, getUnvoteList } from './../../utils/voting';

const VotingBar = ({ votes, t }) => {
const { maxCountOfVotes, maxCountOfVotesInOneTurn } = votingConst;
const votedList = Object.keys(votes).filter(key => votes[key].confirmed);
const voteList = Object.keys(votes).filter(
key => votes[key].unconfirmed && !votes[key].confirmed);
const unvoteList = Object.keys(votes).filter(
key => !votes[key].unconfirmed && votes[key].confirmed);
const totalVotesCount = (votedList.length - unvoteList.length) + voteList.length;
const voteList = getVoteList(votes);
const unvoteList = getUnvoteList(votes);
const totalVotesCount = getTotalVotesCount(votes);
const totalNewVotesCount = voteList.length + unvoteList.length;

return (voteList.length + unvoteList.length ?
Expand Down
6 changes: 6 additions & 0 deletions src/constants/netHashes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const netHash = {
testnet: 'da3ed6a45429278bac2666961289ca17ad86595d33b31037615d4b8e8f158bba',
mainnet: 'ed14889723f24ecc54871d058d98ce91ff2f973192075c0155ba2b7b70ad2511',
};

export default netHash;
5 changes: 2 additions & 3 deletions src/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,15 @@
"Zero not allowed": "Zero not allowed",
"confirmation": "confirmation",
"confirmations": "confirmations",
"key": "key",
"logout": "logout",
"my votes": "my votes",
"send": "send",
"your passphrase will be required for logging in to your account.": "your passphrase will be required for logging in to your account.",
"your second passphrase will be required for all transactions sent from this account": "your second passphrase will be required for all transactions sent from this account",
"{{count}} delegate names were successfully resolved for voting.": "{{count}} delegate name successfully resolved to add vote to.",
"{{count}} delegate names were successfully resolved for voting._plural": "{{count}} delegate names were successfully resolved for voting.",
"{{count}} delegate names were successfully resolved for unvoting.": "{{count}} delegate name successfully resolved to remove vote from.",
"{{count}} delegate names were successfully resolved for unvoting._plural": "{{count}} delegate names were successfully resolved for unvoting.",
"{{count}} delegate names were successfully resolved for voting.": "{{count}} delegate name successfully resolved to add vote to.",
"{{count}} delegate names were successfully resolved for voting._plural": "{{count}} delegate names were successfully resolved for voting.",
"{{count}} of the delegate names selected for unvoting was not currently voted for:": "{{count}} of the delegate names selected for unvoting was not currently voted for:",
"{{count}} of the delegate names selected for unvoting was not currently voted for:_plural": "{{count}} of the delegate names selected for unvoting were not currently voted for:",
"{{count}} of the delegate names selected for voting was already voted for for:": "{{count}} of the delegate names selected for voting was already voted for for:",
Expand Down
4 changes: 2 additions & 2 deletions src/store/middlewares/voting.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getDelegate } from '../../utils/api/delegate';
import { voteLookupStatusUpdated, voteToggled } from '../../actions/voting';
import actionTypes from '../../constants/actions';
import votingConst from '../../constants/voting';
import { getTotalVotesCount } from './../../utils/voting';

const updateLookupStatus = (store, list, username) => {
store.dispatch(voteLookupStatusUpdated({
Expand Down Expand Up @@ -68,8 +69,7 @@ const checkVoteLimits = (store, action) => {
store.dispatch(newAction);
}

const voteCount = Object.keys(votes).filter(
key => (votes[key].confirmed && !votes[key].unconfirmed) || votes[key].unconfirmed).length;
const voteCount = getTotalVotesCount(votes);
if (voteCount === votingConst.maxCountOfVotes + 1 &&
currentVote.unconfirmed !== currentVote.confirmed) {
const label = i18next.t('Maximum of {{n}} votes exceeded.', { n: votingConst.maxCountOfVotes });
Expand Down
Loading

0 comments on commit 36afb37

Please sign in to comment.