From 8f992ee6e84d21c3e6306b27856e4ba90accc1f2 Mon Sep 17 00:00:00 2001 From: elijah Date: Fri, 30 Dec 2016 17:12:21 -0800 Subject: [bug] For now, disable UI for supporting multiple accounts. It does not currently work with API tokens. --- ui/app/app.js | 25 +++++------ ui/app/components/error_panel.js | 66 +++++++++++++++++++++++----- ui/app/components/main_panel/index.js | 11 ++++- ui/app/components/main_panel/user_section.js | 17 ++++--- ui/app/components/panel_switcher.js | 16 ++++++- 5 files changed, 103 insertions(+), 32 deletions(-) (limited to 'ui/app') diff --git a/ui/app/app.js b/ui/app/app.js index 95e4283f..05dadf1f 100644 --- a/ui/app/app.js +++ b/ui/app/app.js @@ -10,13 +10,9 @@ class Application { // main entry point for the application // initialize() { - window.addEventListener("error", this.handleError.bind(this)) - window.addEventListener("unhandledrejection", this.handleError.bind(this)) - if (this.debugging()) { - this.show(this.debug_panel) - } else { - this.start() - } + window.addEventListener("error", this.showError.bind(this)) + window.addEventListener("unhandledrejection", this.showError.bind(this)) + this.start() } start() { @@ -30,10 +26,10 @@ class Application { this.show('main', {initialAccount: account}) } }, error => { - this.show('error', {error: error}) + this.showError(error) }) }, error => { - this.show('error', {error: error}) + this.showError(error) }) } @@ -41,13 +37,14 @@ class Application { this.switcher.show(panel, properties) } - debugging() { - this.debug_panel = window.location.hash.replace('#', '') - return this.debug_panel && this.debug_panel != 'main' + showError(e) { + this.switcher.showError(e) + return true } - handleError(e) { - this.show('error', {error: e}) + hideError() { + this.switcher.hideError() + return true } } diff --git a/ui/app/components/error_panel.js b/ui/app/components/error_panel.js index 7b360448..f5d33e8f 100644 --- a/ui/app/components/error_panel.js +++ b/ui/app/components/error_panel.js @@ -1,6 +1,37 @@ import React from 'react' import Center from './center' import Area from './area' +import { Modal } from 'react-bootstrap' + +import App from 'app' + +class ErrorMessage extends React.Component { + static get defaultProps() {return{ + message: null, + stack: null + }} + + constructor(props) { + super(props) + } + + render() { + let stack = null + if (this.props.stack) { + stack = + } + return( +
+

{this.props.message}

+ {stack} +
+ ) + } +} export default class ErrorPanel extends React.Component { @@ -8,24 +39,39 @@ export default class ErrorPanel extends React.Component { super(props) } + hide() { + App.hideError() + } + render () { var error_msg = null var error = this.props.error + console.log(error) - if (error instanceof Error && error.stack) { - error_msg = error.stack - } else if (error instanceof PromiseRejectionEvent) { - error_msg = "Error connecting to bitmaskd" + + if (error.error) { + error = error + } else if (error.reason) { + error = error.reason + } + + if (error.stack && error.message) { + error_msg = + } else if (error.message) { + error_msg = } else { - error_msg = error.toString() + error_msg = } + return ( -
- -

Error

+ + + Error + + {error_msg} - -
+ + ) } } diff --git a/ui/app/components/main_panel/index.js b/ui/app/components/main_panel/index.js index 2949b1b3..05a1e903 100644 --- a/ui/app/components/main_panel/index.js +++ b/ui/app/components/main_panel/index.js @@ -68,6 +68,7 @@ export default class MainPanel extends React.Component { render() { let emailSection = null let vpnSection = null + let sidePanel = null if (this.state.account.authenticated) { if (this.state.account.hasEmail) { @@ -75,12 +76,18 @@ export default class MainPanel extends React.Component { } } - return ( -
+ if (false) { + sidePanel = ( + ) + } + + return ( +
+ {sidePanel}
{vpnSection} diff --git a/ui/app/components/main_panel/user_section.js b/ui/app/components/main_panel/user_section.js index 317f9931..b792bb43 100644 --- a/ui/app/components/main_panel/user_section.js +++ b/ui/app/components/main_panel/user_section.js @@ -9,6 +9,8 @@ import Account from 'models/account' import bitmask from 'lib/bitmask' +import App from 'app' + export default class UserSection extends React.Component { static get defaultProps() {return{ @@ -87,11 +89,16 @@ export default class UserSection extends React.Component { address = this.props.account.address } let header = ( - + ) return ( diff --git a/ui/app/components/panel_switcher.js b/ui/app/components/panel_switcher.js index d707a602..9a06b49f 100644 --- a/ui/app/components/panel_switcher.js +++ b/ui/app/components/panel_switcher.js @@ -19,17 +19,31 @@ export default class PanelSwitcher extends React.Component { this.state = { panel: null, panel_properties: null, - debug: true + debug: true, + error: null } App.switcher = this } + showError(error) { + this.setState({error: error}) + } + + hideError() { + this.setState({error: null}) + } + show(component_name, properties={}) { this.setState({panel: component_name, panel_properties: properties}) } render() { let elems = [] + if (this.state.error) { + elems.push( + + ) + } if (this.panelExist(this.state.panel)) { elems.push( this.panelRender(this.state.panel, this.state.panel_properties) -- cgit v1.2.3