diff --git a/src/browser/index.jsx b/src/browser/index.jsx index 059da87a..a9e4691f 100644 --- a/src/browser/index.jsx +++ b/src/browser/index.jsx @@ -10,6 +10,8 @@ const Col = ReactBootstrap.Col; const Nav = ReactBootstrap.Nav; const NavItem = ReactBootstrap.NavItem; const Badge = ReactBootstrap.Badge; +const ListGroup = ReactBootstrap.ListGroup; +const ListGroupItem = ReactBootstrap.ListGroupItem; const electron = require('electron'); const remote = electron.remote; @@ -204,6 +206,7 @@ var TabBar = React.createClass({ var MattermostView = React.createClass({ getInitialState: function() { return { + did_fail_load: null }; }, handleUnreadCountChange: function(unreadCount, mentionCount, isUnread, isMentioned) { @@ -216,6 +219,13 @@ var MattermostView = React.createClass({ var thisObj = this; var webview = ReactDOM.findDOMNode(this.refs.webview); + webview.addEventListener('did-fail-load', function(e) { + console.log(thisObj.props.name, 'webview did-fail-load', e); + thisObj.setState({ + did_fail_load: e + }); + }); + // Open link in browserWindow. for exmaple, attached files. webview.addEventListener('new-window', function(e) { var currentURL = url.parse(webview.getURL()); @@ -293,7 +303,39 @@ var MattermostView = React.createClass({ // 'disablewebsecurity' is necessary to display external images. // However, it allows also CSS/JavaScript. // So webview should use 'allowDisplayingInsecureContent' as same as BrowserWindow. - return (); + if (this.state.did_fail_load === null) { + return (); + } else { + return () + } + } +}); + +// ErrorCode: https://code.google.com/p/chromium/codesearch#chromium/src/net/base/net_error_list.h +var ErrorView = React.createClass({ + render: function() { + return ( + + Failed to load the URL + + { 'URL: ' } + { this.props.errorInfo.validatedURL } + + + { 'Error code: ' } + { this.props.errorInfo.errorCode } + + + { this.props.errorInfo.errorDescription } + + Please check below. + + Is your computer online? + Is the server alive? + Is the URL correct? + + + ); } });
+ { 'URL: ' } + { this.props.errorInfo.validatedURL } +
+ { 'Error code: ' } + { this.props.errorInfo.errorCode } +
+ { this.props.errorInfo.errorDescription } +
Please check below.