Browse Source

Merge pull request #174 from SuperNETorg/feature/settings-refactor

Feature/settings refactor
all-modes^2
pbca26 7 years ago
committed by GitHub
parent
commit
967dbc5187
  1. 124
      react/src/components/dashboard/settings/settings.addNodePanel.js
  2. 78
      react/src/components/dashboard/settings/settings.appInfoPanel.js
  3. 42
      react/src/components/dashboard/settings/settings.appSettingsPanel.js
  4. 2
      react/src/components/dashboard/settings/settings.appUpdatePanel.js
  5. 5
      react/src/components/dashboard/settings/settings.cliPanel.js
  6. 130
      react/src/components/dashboard/settings/settings.debugLogPanel.js
  7. 92
      react/src/components/dashboard/settings/settings.exportKeysPanel.js
  8. 6
      react/src/components/dashboard/settings/settings.fiatCurrencyPanel.js
  9. 69
      react/src/components/dashboard/settings/settings.importKeysPanel.js
  10. 113
      react/src/components/dashboard/settings/settings.js
  11. 86
      react/src/components/dashboard/settings/settings.panel.js
  12. 89
      react/src/components/dashboard/settings/settings.panelBody.js
  13. 48
      react/src/components/dashboard/settings/settings.panelUtils.js
  14. 316
      react/src/components/dashboard/settings/settings.render.js
  15. 32
      react/src/components/dashboard/settings/settings.scss
  16. 2
      react/src/components/dashboard/settings/settings.supportPanel.js
  17. 6
      react/src/components/dashboard/settings/settings.walletBackupPanel.js
  18. 4
      react/src/components/dashboard/settings/settings.walletInfoPanel.js

124
react/src/components/dashboard/settings/settings.addNodePanel.js

@ -96,75 +96,73 @@ class AddNodePanel extends React.Component {
render() {
return (
<div className="panel-body">
<div className="row">
<div className="col-sm-6">
<div className="col-sm-12">
<p>{ translate('INDEX.USE_THIS_SECTION') }</p>
</div>
<div className="col-sm-8 col-xs-12">
<div className="form-group">
<select
className="form-control form-material"
name="getPeersCoin"
onChange={ this.updateInput }>
<option>{ translate('INDEX.SELECT_COIN') }</option>
<AddCoinOptionsCrypto />
<AddCoinOptionsAC />
<AddCoinOptionsACFiat />
</select>
</div>
</div>
<div className="col-sm-4 col-xs-12 text-align-center">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this.checkNodes }>{ translate('INDEX.CHECK_NODES') }</button>
</div>
<div className="col-sm-12">
<h5>
SuperNET Peers:
</h5>
<div>{ this.renderSNPeersList() }</div>
<h5>
Raw Peers:
</h5>
<div>{ this.renderPeersList() }</div>
<div className="row">
<div className="col-sm-6">
<div className="col-sm-12">
<p>{ translate('INDEX.USE_THIS_SECTION') }</p>
</div>
<div className="col-sm-8 col-xs-12">
<div className="form-group">
<select
className="form-control form-material"
name="getPeersCoin"
onChange={ this.updateInput }>
<option>{ translate('INDEX.SELECT_COIN') }</option>
<AddCoinOptionsCrypto />
<AddCoinOptionsAC />
<AddCoinOptionsACFiat />
</select>
</div>
</div>
<div className="col-sm-4 col-xs-12 text-align-center">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this.checkNodes }>{ translate('INDEX.CHECK_NODES') }</button>
</div>
<div className="col-sm-12">
<h5>
SuperNET Peers:
</h5>
<div>{ this.renderSNPeersList() }</div>
<h5>
Raw Peers:
</h5>
<div>{ this.renderPeersList() }</div>
</div>
</div>
<div className="col-sm-6">
<div className="col-sm-12">
<p>{ translate('INDEX.USE_THIS_SECTION_PEER') }</p>
</div>
<div className="col-sm-8 col-xs-12">
<div className="form-group">
<select
className="form-control form-material"
name="addNodeCoin"
onChange={ this.updateInput }>
<option>{ translate('INDEX.SELECT_COIN') }</option>
<AddCoinOptionsCrypto />
<AddCoinOptionsAC />
<AddCoinOptionsACFiat />
</select>
</div>
<div className="form-group">
<input
type="text"
className="form-control"
name="addPeerIP"
placeholder={ translate('SETTINGS.ADD_PEER_IP') }
onChange={ this.updateInput } />
</div>
<div className="col-sm-6">
<div className="col-sm-12">
<p>{ translate('INDEX.USE_THIS_SECTION_PEER') }</p>
</div>
<div className="col-sm-8 col-xs-12">
<div className="form-group">
<select
className="form-control form-material"
name="addNodeCoin"
onChange={ this.updateInput }>
<option>{ translate('INDEX.SELECT_COIN') }</option>
<AddCoinOptionsCrypto />
<AddCoinOptionsAC />
<AddCoinOptionsACFiat />
</select>
</div>
<div className="col-sm-4 col-xs-12 text-align-center">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this.addNode }>{ translate('INDEX.ADD_NODE') }</button>
<div className="form-group">
<input
type="text"
className="form-control"
name="addPeerIP"
placeholder={ translate('SETTINGS.ADD_PEER_IP') }
onChange={ this.updateInput } />
</div>
</div>
<div className="col-sm-4 col-xs-12 text-align-center">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this.addNode }>{ translate('INDEX.ADD_NODE') }</button>
</div>
</div>
</div>
);

78
react/src/components/dashboard/settings/settings.appInfoPanel.js

@ -8,76 +8,58 @@ class AppInfoPanel extends React.Component {
}
render() {
return (
<div className="panel-body">
<div className="col-sm-12 padding-top-15">
<div className="row">
const releaseInfo = this.props.Settings.appInfo && this.props.Settings.appInfo.releaseInfo;
if (!releaseInfo) {
return null
} else {
return (
<div className="row">
<div className="col-sm-12 padding-top-15">
<h5>{ translate('SETTINGS.APP_RELEASE') }</h5>
<div>
<p>
{ translate('SETTINGS.NAME') }: { this.props.Settings.appInfo.releaseInfo.name }
</div>
<div>
<br />
{ translate('SETTINGS.VERSION') }: { `${this.props.Settings.appInfo.releaseInfo.version.replace('version=', '')}-beta` }
</div>
<div>
<br />
{ translate('SETTINGS.APP_SESSION') }: { this.props.Settings.appInfo.appSession }
</div>
</div>
</div>
<div className="col-sm-12 padding-top-20">
<div className="row">
</p>
<h5>{ translate('SETTINGS.SYS_INFO') }</h5>
<div>
<p>
{ translate('SETTINGS.ARCH') }: { this.props.Settings.appInfo.sysInfo.arch }
</div>
<div>
<br />
{ translate('SETTINGS.OS_TYPE') }: { this.props.Settings.appInfo.sysInfo.os_type }
</div>
<div>
<br />
{ translate('SETTINGS.OS_PLATFORM') }: { this.props.Settings.appInfo.sysInfo.platform }
</div>
<div>
<br />
{ translate('SETTINGS.OS_RELEASE') }: { this.props.Settings.appInfo.sysInfo.os_release }
</div>
<div>
<br />
{ translate('SETTINGS.CPU') }: { this.props.Settings.appInfo.sysInfo.cpu }
</div>
<div>
<br />
{ translate('SETTINGS.CPU_CORES') }: { this.props.Settings.appInfo.sysInfo.cpu_cores }
</div>
<div>
<br />
{ translate('SETTINGS.MEM') }: { this.props.Settings.appInfo.sysInfo.totalmem_readable }
</div>
</div>
</div>
<div className="col-sm-12 padding-top-20">
<div className="row">
</p>
<h5>{ translate('SETTINGS.LOCATIONS') }</h5>
<div>
<p>
{ translate('SETTINGS.CACHE') }: { this.props.Settings.appInfo.dirs.cacheLocation }
</div>
<div>
<br />
{ translate('SETTINGS.CONFIG') }: { this.props.Settings.appInfo.dirs.configLocation }
</div>
<div>
<br />
Iguana { translate('SETTINGS.BIN') }: { this.props.Settings.appInfo.dirs.iguanaBin }
</div>
<div>
<br />
Iguana { translate('SETTINGS.DIR') }: { this.props.Settings.appInfo.dirs.iguanaDir }
</div>
<div>
<br />
Komodo { translate('SETTINGS.BIN') }: { this.props.Settings.appInfo.dirs.komododBin }
</div>
<div>
<br />
Komodo { translate('SETTINGS.DIR') }: { this.props.Settings.appInfo.dirs.komodoDir }
</div>
<div>
<br />
Komodo wallet.dat: { this.props.Settings.appInfo.dirs.komodoDir }
</div>
</p>
</div>
</div>
</div>
);
);
}
};
}

42
react/src/components/dashboard/settings/settings.appSettingsPanel.js

@ -283,26 +283,30 @@ class AppSettingsPanel extends React.Component {
render() {
return (
<div className="panel-body">
<p>
<strong>{ translate('SETTINGS.CONFIG_RESTART_REQUIRED') }</strong>
</p>
<div className="col-sm-12 padding-top-15">
<table>
<tbody>
{ this.renderConfigEditForm() }
</tbody>
</table>
<div>
<div className="row">
<div className="col-sm-12 padding-top-15">
<p>
<strong>{ translate('SETTINGS.CONFIG_RESTART_REQUIRED') }</strong>
</p>
<table>
<tbody>
{ this.renderConfigEditForm() }
</tbody>
</table>
</div>
</div>
<div className="col-sm-12 col-xs-12 text-align-center padding-top-35 padding-bottom-30">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this._saveAppConfig }>{ translate('SETTINGS.SAVE_APP_CONFIG') }</button>
<button
type="button"
className="btn btn-primary waves-effect waves-light margin-left-30"
onClick={ this._resetAppConfig }>Reset to default</button>
<div className="row">
<div className="col-sm-12 col-xs-12 text-align-center padding-top-35 padding-bottom-30">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this._saveAppConfig }>{ translate('SETTINGS.SAVE_APP_CONFIG') }</button>
<button
type="button"
className="btn btn-primary waves-effect waves-light margin-left-30"
onClick={ this._resetAppConfig }>Reset to default</button>
</div>
</div>
</div>
);

2
react/src/components/dashboard/settings/settings.appUpdatePanel.js

@ -107,7 +107,7 @@ class AppUpdatePanel extends React.Component {
render() {
return (
<div className="panel-body">
<div className="row">
<div className="col-sm-4 padding-top-15">
<h5>{ translate('INDEX.UI_UPDATE') }</h5>
<div className="padding-top-15">

5
react/src/components/dashboard/settings/settings.cliPanel.js

@ -143,9 +143,9 @@ class CliPanel extends React.Component {
render() {
return (
<div className="panel-body">
<div className="row">
<div className="col-sm-12">
<p>{ translate('INDEX.CLI_SELECT_A_COIN') }</p>
<div className="col-sm-12"></div>
<form
className="execute-cli-cmd-form"
method="post"
@ -189,6 +189,7 @@ class CliPanel extends React.Component {
</div>
</div>
</form>
</div>
</div>
);
};

130
react/src/components/dashboard/settings/settings.debugLogPanel.js

@ -102,70 +102,74 @@ class DebugLogPanel extends React.Component {
render() {
return (
<div className="panel-body">
<p>{ translate('INDEX.DEBUG_LOG_DESC') }</p>
<div className="margin-top-30">
<span className="pointer toggle">
<label className="switch">
<input
type="checkbox"
name="settings-app-debug-toggle"
value={ this.state.toggleAppRuntimeLog }
checked={ this.state.toggleAppRuntimeLog } />
<div
className="slider"
onClick={ this.toggleAppRuntimeLog }></div>
</label>
<span
className="title"
onClick={ this.toggleAppRuntimeLog }>Show app runtime log</span>
</span>
<div className="row">
<div className="col-sm-12">
<p>{ translate('INDEX.DEBUG_LOG_DESC') }</p>
<div className="margin-top-30">
<span className="pointer toggle">
<label className="switch">
<input
type="checkbox"
name="settings-app-debug-toggle"
value={ this.state.toggleAppRuntimeLog }
checked={ this.state.toggleAppRuntimeLog } />
<div
className="slider"
onClick={ this.toggleAppRuntimeLog }></div>
</label>
<span
className="title"
onClick={ this.toggleAppRuntimeLog }>Show app runtime log</span>
</span>
</div>
{ !this.state.toggleAppRuntimeLog &&
<form
className="read-debug-log-import-form"
method="post"
action="javascript:"
autoComplete="off">
<div className="form-group form-material floating">
<input
type="text"
className="form-control"
name="debugLinesCount"
id="readDebugLogLines"
value={ this.state.debugLinesCount }
onChange={ this.updateInput } />
<label
className="floating-label"
htmlFor="readDebugLogLines">{ translate('INDEX.DEBUG_LOG_LINES') }</label>
</div>
<div className="form-group form-material floating">
<select
className="form-control form-material"
name="debugTarget"
id="settingsDelectDebugLogOptions"
onChange={ this.updateInput }>
<option value="iguana" className={ this.state.nativeOnly ? 'hide' : '' }>Iguana</option>
<option value="komodo">Komodo</option>
</select>
<label
className="floating-label"
htmlFor="settingsDelectDebugLogOptions">{ translate('INDEX.TARGET') }</label>
</div>
<div className="col-sm-12 col-xs-12 text-align-center">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this.readDebugLog }>{ translate('INDEX.LOAD_DEBUG_LOG') }</button>
</div>
<div className="row">
<div className="col-sm-12 col-xs-12 text-align-left">
<div className="padding-top-40 padding-bottom-20 horizontal-padding-0">{ this.renderDebugLogData() }</div>
</div>
</div>
</form>
}
{ this.state.toggleAppRuntimeLog &&
<div className="margin-top-20">{ this.renderAppRuntimeLog() }</div>
}
</div>
{ !this.state.toggleAppRuntimeLog &&
<form
className="read-debug-log-import-form"
method="post"
action="javascript:"
autoComplete="off">
<div className="form-group form-material floating">
<input
type="text"
className="form-control"
name="debugLinesCount"
id="readDebugLogLines"
value={ this.state.debugLinesCount }
onChange={ this.updateInput } />
<label
className="floating-label"
htmlFor="readDebugLogLines">{ translate('INDEX.DEBUG_LOG_LINES') }</label>
</div>
<div className="form-group form-material floating">
<select
className="form-control form-material"
name="debugTarget"
id="settingsDelectDebugLogOptions"
onChange={ this.updateInput }>
<option value="iguana" className={ this.state.nativeOnly ? 'hide' : '' }>Iguana</option>
<option value="komodo">Komodo</option>
</select>
<label
className="floating-label"
htmlFor="settingsDelectDebugLogOptions">{ translate('INDEX.TARGET') }</label>
</div>
<div className="col-sm-12 col-xs-12 text-align-center">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this.readDebugLog }>{ translate('INDEX.LOAD_DEBUG_LOG') }</button>
</div>
<div className="col-sm-12 col-xs-12 text-align-left">
<div className="padding-top-40 padding-bottom-20 horizontal-padding-0">{ this.renderDebugLogData() }</div>
</div>
</form>
}
{ this.state.toggleAppRuntimeLog &&
<div className="margin-top-20">{ this.renderAppRuntimeLog() }</div>
}
</div>
);
};

92
react/src/components/dashboard/settings/settings.exportKeysPanel.js

@ -157,53 +157,57 @@ class ExportKeysPanel extends React.Component {
render() {
return (
<div className="panel-body">
<div>
<div className="padding-bottom-20">{ this.renderLB('INDEX.ONLY_ACTIVE_WIF_KEYS') }</div>
<div className="padding-bottom-20">
<i>{ this.renderLB('SETTINGS.EXPORT_KEYS_NOTE') }</i>
<div>
<div className="row">
<div className="col-sm-12">
<div className="padding-bottom-20">{ this.renderLB('INDEX.ONLY_ACTIVE_WIF_KEYS') }</div>
<div className="padding-bottom-20">
<i>{ this.renderLB('SETTINGS.EXPORT_KEYS_NOTE') }</i>
</div>
<strong>
<i>{ translate('INDEX.PLEASE_KEEP_KEYS_SAFE') }</i>
</strong>
</div>
<strong>
<i>{ translate('INDEX.PLEASE_KEEP_KEYS_SAFE') }</i>
</strong>
</div>
<div className="col-sm-12"></div>
<form
className="wifkeys-form"
method="post"
action="javascript:"
autoComplete="off">
<div className="form-group form-material floating">
<input
type="password"
className={ !this.state.seedInputVisibility ? 'form-control' : 'hide' }
name="wifkeysPassphrase"
id="wifkeysPassphrase"
onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase } />
<textarea
className={ this.state.seedInputVisibility ? 'form-control' : 'hide' }
id="wifkeysPassphraseTextarea"
name="wifkeysPassphrase"
onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase }></textarea>
<i
className={ 'seed-toggle fa fa-eye' + (!this.state.seedInputVisibility ? '-slash' : '') }
onClick={ this.toggleSeedInputVisibility }></i>
<label
className="floating-label"
htmlFor="wifkeysPassphrase">{ translate('INDEX.PASSPHRASE') }</label>
</div>
<div className="col-sm-12 col-xs-12 text-align-center">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this.exportWifKeys }>{ translate('INDEX.GET_WIF_KEYS') }</button>
<div className="row">
<div className="col-sm-12">
<form
className="wifkeys-form"
method="post"
action="javascript:"
autoComplete="off">
<div className="form-group form-material floating">
<input
type="password"
className={ !this.state.seedInputVisibility ? 'form-control' : 'hide' }
name="wifkeysPassphrase"
id="wifkeysPassphrase"
onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase } />
<textarea
className={ this.state.seedInputVisibility ? 'form-control' : 'hide' }
id="wifkeysPassphraseTextarea"
name="wifkeysPassphrase"
onChange={ this.updateInput }
value={ this.state.wifkeysPassphrase }></textarea>
<i
className={ 'seed-toggle fa fa-eye' + (!this.state.seedInputVisibility ? '-slash' : '') }
onClick={ this.toggleSeedInputVisibility }></i>
<label
className="floating-label"
htmlFor="wifkeysPassphrase">{ translate('INDEX.PASSPHRASE') }</label>
</div>
<div className="col-sm-12 col-xs-12 text-align-center">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this.exportWifKeys }>{ translate('INDEX.GET_WIF_KEYS') }</button>
</div>
</form>
</div>
</form>
<div className="col-sm-12 padding-top-15">
<div className="row">
</div>
<div className="row">
<div className="col-sm-12 padding-top-15">
<table className="table">
{ this.renderWifKeys() }
</table>

6
react/src/components/dashboard/settings/settings.fiatCurrencyPanel.js

@ -9,7 +9,11 @@ class FiatCurrencyPanel extends React.Component {
render() {
return (
<div className="panel-body">Fiat currency settings section to be updated soon.</div>
<div className="row">
<div className="col-sm-12">
<p>Fiat currency settings section to be updated soon.</p>
</div>
</div>
);
};
}

69
react/src/components/dashboard/settings/settings.importKeysPanel.js

@ -26,39 +26,46 @@ class ImportKeysPanel extends React.Component {
render() {
return (
<div className="panel-body">
<div>{ translate('INDEX.IMPORT_KEYS_DESC_P1') }</div><br/>
<div>{ translate('INDEX.IMPORT_KEYS_DESC_P2') }</div><br/>
<div>{ translate('INDEX.IMPORT_KEYS_DESC_P3') }</div><br/>
<div>
<strong>
<i>{ translate('INDEX.PLEASE_KEEP_KEYS_SAFE') }</i>
</strong>
</div>
<div className="col-sm-12"></div>
<form
className="wifkeys-import-form"
method="post"
action="javascript:"
autoComplete="off">
<div className="form-group form-material floating">
<input
type="text"
className="form-control"
name="importWifKey"
id="importWifkey"
onChange={ this.updateInput } />
<label
className="floating-label"
htmlFor="importWifkey">{ translate('INDEX.INPUT_PRIV_KEY') }</label>
<div>
<div className="row">
<div className="col-sm-12">
<p>{ translate('INDEX.IMPORT_KEYS_DESC_P1') }</p>
<p>{ translate('INDEX.IMPORT_KEYS_DESC_P2') }</p>
<p>{ translate('INDEX.IMPORT_KEYS_DESC_P3') }</p>
<p>
<strong>
<i>{ translate('INDEX.PLEASE_KEEP_KEYS_SAFE') }</i>
</strong>
</p>
</div>
<div className="col-sm-12 col-xs-12 text-align-center">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this.importWifKey }>{ translate('INDEX.IMPORT_PRIV_KEY') }</button>
</div>
<div className="row">
<div className="col-sm-12">
<form
className="wifkeys-import-form"
method="post"
action="javascript:"
autoComplete="off">
<div className="form-group form-material floating">
<input
type="text"
className="form-control"
name="importWifKey"
id="importWifkey"
onChange={ this.updateInput } />
<label
className="floating-label"
htmlFor="importWifkey">{ translate('INDEX.INPUT_PRIV_KEY') }</label>
</div>
<div className="col-sm-12 col-xs-12 text-align-center">
<button
type="button"
className="btn btn-primary waves-effect waves-light"
onClick={ this.importWifKey }>{ translate('INDEX.IMPORT_PRIV_KEY') }</button>
</div>
</form>
</div>
</form>
</div>
</div>
);
}

113
react/src/components/dashboard/settings/settings.js

@ -1,15 +1,10 @@
import React from 'react';
import { connect } from 'react-redux';
import { translate } from '../../../translate/translate';
import Config from '../../../config';
import {
iguanaActiveHandle,
getAppConfig,
getPeersList,
addPeerNode,
getAppInfo,
shepherdCli,
triggerToaster,
} from '../../../actions/actionCreators';
import Store from '../../../store';
@ -17,19 +12,6 @@ import {
SettingsRender,
} from './settings.render';
import AppUpdatePanel from './settings.appUpdatePanel';
import AppInfoPanel from './settings.appInfoPanel';
import AddNodePanel from './settings.addNodePanel';
import AppSettingsPanel from './settings.appSettingsPanel';
import CliPanel from './settings.cliPanel';
import DebugLogPanel from './settings.debugLogPanel';
import FiatCurrencyPanel from './settings.fiatCurrencyPanel';
import ExportKeysPanel from './settings.exportKeysPanel';
import ImportKeysPanel from './settings.importKeysPanel';
import SupportPanel from './settings.supportPanel';
import WalletInfoPanel from './settings.walletInfoPanel';
import WalletBackupPanel from './settings.walletBackupPanel';
/*
TODO:
1) pre-select active coin in add node tab
@ -38,105 +20,20 @@ import WalletBackupPanel from './settings.walletBackupPanel';
4) batch export/import wallet addresses
*/
class Settings extends React.Component {
constructor() {
super();
this.state = {
activeTab: 0,
tabElId: null,
seedInputVisibility: false,
nativeOnly: Config.iguanaLessMode,
disableWalletSpecificUI: false,
};
this.updateInput = this.updateInput.bind(this);
constructor(props) {
super(props);
}
componentDidMount(props) {
if (!this.props.disableWalletSpecificUI) {
Store.dispatch(iguanaActiveHandle());
}
Store.dispatch(getAppConfig());
Store.dispatch(getAppInfo());
document.getElementById('section-iguana-wallet-settings').setAttribute('style', 'height:auto; min-height: 100%');
}
componentWillReceiveProps(props) {
if (this.state.tabElId) {
this.setState(Object.assign({}, this.state, {
activeTab: this.state.activeTab,
tabElId: this.state.tabElId,
disableWalletSpecificUI: this.props.disableWalletSpecificUI,
}));
}
}
openTab(elemId, tab) {
this.setState(Object.assign({}, this.state, {
activeTab: tab,
tabElId: elemId,
}));
}
updateInput(e) {
this.setState({
[e.target.name]: e.target.value,
});
}
renderAppInfoTab() {
const releaseInfo = this.props.Settings.appInfo && this.props.Settings.appInfo.releaseInfo;
if (releaseInfo) {
return <AppInfoPanel />
}
return null;
}
renderAppUpdateTab() {
return <AppUpdatePanel />
}
renderWalletInfo() {
return <WalletInfoPanel />
}
renderAddNode() {
return <AddNodePanel />
}
renderWalletBackup() {
return <WalletBackupPanel />
}
renderFiatCurrency() {
return <FiatCurrencyPanel />
}
renderExportKeys() {
return <ExportKeysPanel />
}
renderImportKeys() {
return <ImportKeysPanel />
}
renderDebugLog() {
return <DebugLogPanel />
}
renderAppSettings() {
return <AppSettingsPanel />
}
renderCliPanel() {
return <CliPanel />
}
renderSupportPanel() {
return <SupportPanel />
}
render() {
return SettingsRender.call(this);
}
@ -146,13 +43,7 @@ const mapStateToProps = (state) => {
return {
Main: {
coins: state.Main.coins,
activeHandle: state.Main.activeHandle,
},
ActiveCoin: {
coin: state.ActiveCoin.coin,
},
Settings: state.Settings,
Dashboard: state.Dashboard,
};
};

86
react/src/components/dashboard/settings/settings.panel.js

@ -0,0 +1,86 @@
import React from 'react';
import className from 'classnames';
import * as Utils from './settings.panelUtils';
class Panel extends React.Component {
constructor(props) {
super(props);
this.toggleSection = this.toggleSection.bind(this);
this.state = {
singleOpen: this.props.singleOpen,
openByDefault: this.props.openByDefault,
activeSections: [],
};
}
componentWillMount() {
const {
singleOpen,
openByDefault,
uniqId,
children } = this.props;
const settings = {
singleOpen,
openByDefault,
uniqId,
kids: children
};
const initialStateSections = Utils.setupAccordion(settings).activeSections;
this.setState({ activeSections: initialStateSections });
}
getChildrenWithProps() {
const {
children,
} = this.props;
const kids = React.Children.map(children, (child, i) => {
if(child) {
const unqId = `panel-sec-${i}`;
return React.cloneElement(child, {
toggle: (acId) => this.toggleSection(acId),
key: unqId,
unq: unqId,
active: (this.state.activeSections && this.state.activeSections.lastIndexOf(unqId) !== -1)
});
}
});
return kids;
}
toggleSection(sectionId) {
const newActive = Utils.toggleSection(
sectionId,
this.state.activeSections,
this.state.singleOpen);
this.setState({
activeSections: newActive
});
}
render() {
const {
className: propClasses,
uniqId: propId
} = this.props;
const childrenWithProps = this.getChildrenWithProps();
const accordionClasses = className('panel-group', propClasses);
const uniqId = propId || '';
return(
<div className={accordionClasses} id={uniqId}>
{childrenWithProps}
</div>
);
}
}
export default Panel;

89
react/src/components/dashboard/settings/settings.panelBody.js

@ -0,0 +1,89 @@
import React from 'react';
import className from 'classnames';
class PanelSection extends React.Component {
constructor(props) {
super(props);
this.state = {
sectionHeight: 0,
}
this.toggleSection = this.toggleSection.bind(this);
}
componentDidMount() {
const { active } = this.props;
if (active) this.setState({sectionHeight: this.accordionContent.scrollHeight});
}
componentWillReceiveProps(nextProps) {
if(this.props.active) {
this.setState({
sectionHeight: 'auto',
});
}
if (nextProps.active !== this.props.active) {
this.toggleOpen(nextProps.active);
}
}
getHeight() {
const { active } = this.props;
return (active) ? this.accordionContent.scrollHeight : 0;
}
toggleSection() {
const {
unq,
toggle
} = this.props;
toggle(unq);
}
toggleOpen(active) {
const height = (active) ? `${this.accordionContent.scrollHeight}px` : 0;
this.setState({
sectionHeight: height,
});
}
render() {
const {
title,
icon,
children,
active,
className: propClasses
} = this.props;
const contentStyles = {
height: this.state.sectionHeight,
overflow: 'hidden',
transition: 'height .25s ease',
};
const triggerClasses = className('panel', {
active
});
const contentClasses = className('panel-collapse', {
active
});
return(
<div className={triggerClasses} onClick={() => this.toggleSection()}>
<div className="panel-heading">
<a className='panel-title'>
<i className={icon}></i> {title}
</a>
</div>
<div className={contentClasses} style={contentStyles} ref={(ref) => this.accordionContent = ref}>
<div className="panel-body">
{children}
</div>
</div>
</div>
);
}
}
export default PanelSection;

48
react/src/components/dashboard/settings/settings.panelUtils.js

@ -0,0 +1,48 @@
export function checkUndef(item) {
return (typeof item !== 'undefined');
}
export function toggleSection(sectionId, activeSections, singleOpen) {
let present = null;
let newActiveSections = activeSections;
newActiveSections.map((section) => {
if (section === sectionId) present = true;
return true;
});
if (!singleOpen) {
if (present) {
const pos = newActiveSections.indexOf(sectionId);
newActiveSections.splice(pos, 1);
} else {
newActiveSections.push(sectionId);
}
} else {
newActiveSections = [sectionId];
}
return newActiveSections;
}
export function setupAccordion(info) {
const singleOpen = (checkUndef(info.singleOpen)) ? info.singleOpen : false;
const activeSections = [];
const singleChild = typeof info.kids.length === 'undefined';
if (!singleChild) {
info.kids.forEach((child, i) => {
const { openByDefault } = child ? child.props : false;
if (singleOpen && activeSections.length === 0 && openByDefault) {
activeSections.push(`panel-sec-${i}`);
}
if (!singleOpen && openByDefault) {
activeSections.push(`panel-sec-${i}`);
}
});
}
return {
activeSections,
};
}

316
react/src/components/dashboard/settings/settings.render.js

@ -1,227 +1,111 @@
import React from 'react';
import { translate } from '../../../translate/translate';
import PanelSection from './settings.panelBody';
import Panel from './settings.panel';
import AppUpdatePanel from './settings.appUpdatePanel';
import AppInfoPanel from './settings.appInfoPanel';
import AddNodePanel from './settings.addNodePanel';
import AppSettingsPanel from './settings.appSettingsPanel';
import CliPanel from './settings.cliPanel';
import DebugLogPanel from './settings.debugLogPanel';
import FiatCurrencyPanel from './settings.fiatCurrencyPanel';
import ExportKeysPanel from './settings.exportKeysPanel';
import ImportKeysPanel from './settings.importKeysPanel';
import SupportPanel from './settings.supportPanel';
import WalletInfoPanel from './settings.walletInfoPanel';
import WalletBackupPanel from './settings.walletBackupPanel';
export const SettingsRender = function() {
return (
<div className="margin-left-0 full-height">
<div
className="page-content full-height"
id="section-iguana-wallet-settings">
<div
id="section-iguana-wallet-settings"
className="padding-30">
<div className="row">
<div className="col-xlg-12 col-md-12">
<div className="row">
<div className="col-xlg-12 col-md-12">
<h4 className="font-size-14 text-uppercase">{ translate('INDEX.WALLET_SETTINGS') }</h4>
<div
className="panel-group"
id="SettingsAccordion">
{ !this.props.disableWalletSpecificUI &&
<div
id="WalletInfo"
onClick={ () => this.openTab('WalletInfo', 0) }
className={ 'panel' + (this.state.nativeOnly ? ' hide' : '') }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 0 ? '' : ' collapsed') }>
<i className="icon md-balance-wallet"></i>{ translate('INDEX.WALLET_INFO') }
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 0 ? ' in' : '') }
style={{ height: this.state.activeTab === 0 ? `auto` : '0' }}>
{ this.renderWalletInfo() }
</div>
</div>
}
{ !this.props.disableWalletSpecificUI &&
<div
id="AddNodeforCoin"
onClick={ () => this.openTab('AddNodeforCoin', 1) }
className={ 'panel' + (this.state.nativeOnly ? ' hide' : '') }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 1 ? '' : ' collapsed') }>
<i className="icon md-plus-square"></i>{ translate('INDEX.ADD_NODE') }
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 1 ? ' in' : '') }
style={{ height: this.state.activeTab === 1 ? `auto` : '0' }}>
{ this.renderAddNode() }
</div>
</div>
}
{ !this.props.disableWalletSpecificUI &&
<div
id="DumpWallet"
onClick={ () => this.openTab('DumpWallet', 2) }
className={ 'hide panel' + (this.state.nativeOnly ? ' hide' : '') }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 2 ? '' : ' collapsed') }>
<i className="icon wb-briefcase"></i>{ translate('INDEX.WALLET_BACKUP') }
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 2 ? ' in' : '') }
style={{ height: this.state.activeTab === 2 ? `auto` : '0' }}>
{ this.renderWalletBackup() }
</div>
</div>
}
{ !this.props.disableWalletSpecificUI &&
<div
id="FiatCurrencySettings"
onClick={ () => this.openTab('FiatCurrencySettings', 3) }
className={ 'hide panel' + (this.state.nativeOnly ? ' hide' : '') }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 3 ? '' : ' collapsed') }>
<i className="icon fa-money"></i>{ translate('INDEX.FIAT_CURRENCY') }
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 3 ? ' in' : '') }
style={{ height: this.state.activeTab === 3 ? `auto` : '0' }}>
{ this.renderFiatCurrency() }
</div>
</div>
}
{ !this.props.disableWalletSpecificUI &&
<div
id="ExportKeys"
onClick={ () => this.openTab('ExportKeys', 4) }
className={ 'panel' + (this.state.nativeOnly ? ' hide' : '') }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 4 ? '' : ' collapsed') }>
<i className="icon md-key"></i>{ translate('INDEX.EXPORT_KEYS') }
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 4 ? ' in' : '') }
style={{ height: this.state.activeTab === 4 ? `auto` : '0' }}>
{ this.renderExportKeys() }
</div>
</div>
}
{ !this.props.disableWalletSpecificUI &&
<div
id="ImportKeys"
onClick={ () => this.openTab('ImportKeys', 5) }
className={ 'panel' + (this.state.nativeOnly ? ' hide' : '') }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 5 ? '' : ' collapsed') }>
<i className="icon md-key"></i>{ translate('INDEX.IMPORT_KEYS') }
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 5 ? ' in' : '') }
style={{ height: this.state.activeTab === 5 ? `auto` : '0' }}>
{ this.renderImportKeys() }
</div>
</div>
}
<div
className="panel"
id="DebugLog"
onClick={ () => this.openTab('DebugLog', 6) }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 6 ? '' : ' collapsed') }>
<i className="icon fa-bug"></i>{ translate('INDEX.DEBUG_LOG') }
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 6 ? ' in' : '') }
style={{ height: this.state.activeTab === 6 ? `auto` : '0' }}>
{ this.renderDebugLog() }
</div>
</div>
<div
className="panel"
id="AppSettings"
onClick={ () => this.openTab('AppSettings', 7) }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 7 ? '' : ' collapsed') }>
<i className="icon fa-wrench"></i>{ translate('SETTINGS.APP_CONFIG') } (config.json)
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 7 ? ' in' : '') }
style={{ height: this.state.activeTab === 7 ? `auto` : '0' }}>
{ this.renderAppSettings() }
</div>
</div>
<div
className="panel"
id="AppInfo"
onClick={ () => this.openTab('AppInfo', 8) }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 8 ? '' : ' collapsed') }>
<i className="icon md-info"></i>{ translate('SETTINGS.APP_INFO') }
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 8 ? ' in' : '') }
style={{ height: this.state.activeTab === 8 ? `auto` : '0' }}>
{ this.renderAppInfoTab() }
</div>
</div>
{ this.props.Main && this.props.Main.coins.native &&
<div
id="Cli"
onClick={ () => this.openTab('Cli', 9) }
className={ 'panel' + (!this.props.Main.coins.native.length ? ' hide' : '') }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 9 ? '' : ' collapsed') }>
<i className="icon fa-code"></i> CLI
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 9 ? ' in' : '') }
style={{ height: this.state.activeTab === 9 ? `auto` : '0' }}>
{ this.renderCliPanel() }
</div>
</div>
}
<div
className="panel"
id="AppUpdate"
onClick={ () => this.openTab('AppUpdate', 10) }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 10 ? '' : ' collapsed') }>
<i className="icon fa fa-cloud-download"></i> { translate('INDEX.UPDATE') }
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 10 ? ' in' : '') }
style={{ height: this.state.activeTab === 10 ? `auto` : '0' }}>
{ this.renderAppUpdateTab() }
</div>
</div>
<div
className="panel"
id="Support"
onClick={ () => this.openTab('Support', 11) }>
<div className="panel-heading">
<a className={ 'panel-title' + (this.state.activeTab === 11 ? '' : ' collapsed') }>
<i className="icon fa fa-life-ring"></i> Support
</a>
</div>
<div
className={ 'panel-collapse collapse' + (this.state.activeTab === 11 ? ' in' : '') }
style={{ height: this.state.activeTab === 11 ? `auto` : '0' }}>
{ this.renderSupportPanel() }
</div>
</div>
</div>
</div>
</div>
<div className="col-sm-12">
<h4 className="font-size-14 text-uppercase">{ translate('INDEX.WALLET_SETTINGS') }</h4>
<Panel
uniqId={'SettingsAccordion'}
singleOpen={true}>
{ !this.props.disableWalletSpecificUI &&
<PanelSection
title={ translate('INDEX.WALLET_INFO') }
icon="icon md-balance-wallet"
openByDefault={!this.props.disableWalletSpecificUI}>
<WalletInfoPanel />
</PanelSection>
}
{ !this.props.disableWalletSpecificUI &&
<PanelSection
title={ translate('INDEX.ADD_NODE') }
icon="icon md-plus-square">
<AddNodePanel />
</PanelSection>
}
{ !this.props.disableWalletSpecificUI &&
<PanelSection
title={ translate('INDEX.WALLET_BACKUP') }
icon="icon wb-briefcase">
<WalletBackupPanel />
</PanelSection>
}
{ !this.props.disableWalletSpecificUI &&
<PanelSection
title={ translate('INDEX.FIAT_CURRENCY') }
icon="icon fa-money">
<FiatCurrencyPanel />
</PanelSection>
}
{ !this.props.disableWalletSpecificUI &&
<PanelSection
title={ translate('INDEX.EXPORT_KEYS') }
icon="icon md-key">
<ExportKeysPanel />
</PanelSection>
}
{ !this.props.disableWalletSpecificUI &&
<PanelSection
title={ translate('INDEX.IMPORT_KEYS') }
icon="icon md-key">
<ImportKeysPanel />
</PanelSection>
}
<PanelSection
title={ translate('INDEX.DEBUG_LOG') }
icon="icon fa-bug"
openByDefault={this.props.disableWalletSpecificUI}>
<DebugLogPanel />
</PanelSection>
<PanelSection
title={ translate('SETTINGS.APP_CONFIG') + ' (config.json)' }
icon="icon fa-bug">
<AppSettingsPanel />
</PanelSection>
<PanelSection
title={ translate('SETTINGS.APP_INFO') }
icon="icon md-info">
<AppInfoPanel />
</PanelSection>
{ this.props.Main && this.props.Main.coins.native &&
<PanelSection
title="CLI"
icon="icon fa-code">
<CliPanel />
</PanelSection>
}
<PanelSection
title={ translate('INDEX.UPDATE') }
icon="icon fa fa-cloud-download">
<AppUpdatePanel />
</PanelSection>
<PanelSection
title="Support"
icon="icon fa fa-life-ring">
<SupportPanel />
</PanelSection>
</Panel>
</div>
</div>
</div>
</div>
);
};

32
react/src/components/dashboard/settings/settings.scss

@ -93,10 +93,17 @@
#SettingsAccordion {
.panel {
.panel-collapse {
transition: all .3s;
&.collapse {
height: 0;
max-height: 0;
overflow: hidden;
}
&.in {
animation-name: max-height;
animation-duration: 1s;
animation-iteration-count: 1;
max-height: none;
}
}
}
@ -110,7 +117,7 @@
cursor: hand;
&:before {
content: '\F273';
content: '\F278';
}
&.collapsed {
&:before {
@ -118,4 +125,21 @@
}
}
}
.panel.active {
.panel-title:before {
content: '\F273';
}
}
}
@keyframes max-height {
from {
max-height: 0;
}
99% {
max-height: 2000px;
}
100% {
max-height: none;
}
}

2
react/src/components/dashboard/settings/settings.supportPanel.js

@ -27,7 +27,7 @@ class SupportPanel extends React.Component {
render() {
return (
<div className="panel-body">
<div className="row">
<div className="col-sm-12 no-padding-left">
<div className="support-box-wrapper">
<div

6
react/src/components/dashboard/settings/settings.walletBackupPanel.js

@ -9,7 +9,11 @@ class WalletBackupPanel extends React.Component {
render() {
return (
<div className="panel-body">Wallet Backup section to be updated soon.</div>
<div className="row">
<div className="col-sm-12">
<p>Wallet Backup section to be updated soon.</p>
</div>
</div>
);
};
}

4
react/src/components/dashboard/settings/settings.walletInfoPanel.js

@ -9,8 +9,7 @@ class WalletInfoPanel extends React.Component {
render() {
return (
<div className="panel-body">
<table className="table">
<table className="table">
<thead>
<tr>
<th width="10%">{ translate('INDEX.KEY') }</th>
@ -44,7 +43,6 @@ class WalletInfoPanel extends React.Component {
</tr>
</tbody>
</table>
</div>
);
};
}

Loading…
Cancel
Save