From 7c9dd5047799c0cbd11f0edb9bc46a60b940bc31 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Tue, 28 Mar 2017 00:52:59 +0900 Subject: [PATCH 1/3] Hide webview with the recommended approach https://electron.atom.io/docs/api/webview-tag/#css-styling-notes --- src/browser/components/ErrorView.jsx | 12 ++++++++++-- src/browser/components/MainPage.jsx | 14 +------------- src/browser/components/MattermostView.jsx | 16 ++++++++++++---- src/browser/css/components/ErrorView.css | 15 +++++++++++++++ src/browser/css/components/MattermostView.css | 17 +++++++++++++++++ src/browser/css/index.css | 2 ++ 6 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 src/browser/css/components/ErrorView.css create mode 100644 src/browser/css/components/MattermostView.css diff --git a/src/browser/components/ErrorView.jsx b/src/browser/components/ErrorView.jsx index f36a0ef4dbf..0ba0401ecda 100644 --- a/src/browser/components/ErrorView.jsx +++ b/src/browser/components/ErrorView.jsx @@ -31,10 +31,17 @@ const errorPage = { }; function ErrorView(props) { + const classNames = ['errorView']; + if (!props.active) { + classNames.push('errorView-hidden'); + } + if (props.withTab) { + classNames.push('errorView-with-tab'); + } return (
@@ -87,7 +94,8 @@ function ErrorView(props) { ErrorView.propTypes = { errorInfo: React.PropTypes.object, id: React.PropTypes.number, - style: React.PropTypes.object + active: React.PropTypes.bool, + withTab: React.PropTypes.bool }; module.exports = ErrorView; diff --git a/src/browser/components/MainPage.jsx b/src/browser/components/MainPage.jsx index be2d06a16a6..d0322dd86c9 100644 --- a/src/browser/components/MainPage.jsx +++ b/src/browser/components/MainPage.jsx @@ -201,18 +201,6 @@ const MainPage = React.createClass({ this.markReadAtActive(index); }, - visibleStyle(visible) { - var visibility = visible ? 'visible' : 'hidden'; - return { - position: 'absolute', - top: (this.props.teams.length > 1) ? 32 : 0, - right: 0, - bottom: 0, - left: 0, - visibility - }; - }, - handleLogin(request, username, password) { ipcRenderer.send('login-credentials', request, username, password); const loginQueue = this.state.loginQueue; @@ -275,7 +263,7 @@ const MainPage = React.createClass({ 1} src={team.url} name={team.name} onTargetURLChange={self.handleTargetURLChange} diff --git a/src/browser/components/MattermostView.jsx b/src/browser/components/MattermostView.jsx index 530b0307ea0..85c434248e6 100644 --- a/src/browser/components/MattermostView.jsx +++ b/src/browser/components/MattermostView.jsx @@ -15,7 +15,8 @@ const MattermostView = React.createClass({ onTargetURLChange: React.PropTypes.func, onUnreadCountChange: React.PropTypes.func, src: React.PropTypes.string, - style: React.PropTypes.object + active: React.PropTypes.bool, + withTab: React.PropTypes.bool }, getInitialState() { @@ -185,19 +186,26 @@ const MattermostView = React.createClass({ const errorView = this.state.errorInfo ? ( ) : null; // Need to keep webview mounted when failed to load. + const classNames = ['mattermostView']; + if (this.props.withTab) { + classNames.push('mattermostView-with-tab'); + } + if (!this.props.active) { + classNames.push('mattermostView-hidden'); + } return (
{ errorView } Date: Fri, 31 Mar 2017 00:33:46 +0900 Subject: [PATCH 2/3] Fix tests due to webview indices --- test/specs/browser/index_test.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/specs/browser/index_test.js b/test/specs/browser/index_test.js index 789cd0418d0..fc0fc76bb9c 100644 --- a/test/specs/browser/index_test.js +++ b/test/specs/browser/index_test.js @@ -126,14 +126,16 @@ describe('browser/index.html', function desc() { return this.app.restart().then(() => { return this.app.client.waitUntilWindowLoaded().pause(500); }).then(() => { + // Note: Indices of webview are correct. + // Somehow they are swapped. return this.app.client. - windowByIndex(1). + windowByIndex(2). execute(() => { document.title = 'Title 0'; }). windowByIndex(0). browserWindow.getTitle().then((title) => title.should.equal('Title 0')). - windowByIndex(2). + windowByIndex(1). execute(() => { document.title = 'Title 1'; }). @@ -154,14 +156,16 @@ describe('browser/index.html', function desc() { }] })); return this.app.restart().then(() => { + // Note: Indices of webview are correct. + // Somehow they are swapped. return this.app.client. waitUntilWindowLoaded(). pause(500). - windowByIndex(1). + windowByIndex(2). execute(() => { document.title = 'Title 0'; }). - windowByIndex(2). + windowByIndex(1). execute(() => { document.title = 'Title 1'; }). From 8c8f67889e79815c20d6029ba0a72a063bc5d487 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Sat, 8 Apr 2017 22:09:56 +0900 Subject: [PATCH 3/3] Fix view position for new tab height --- src/browser/css/components/ErrorView.css | 2 +- src/browser/css/components/MattermostView.css | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/browser/css/components/ErrorView.css b/src/browser/css/components/ErrorView.css index a240e0e59ea..8a11f1e1442 100644 --- a/src/browser/css/components/ErrorView.css +++ b/src/browser/css/components/ErrorView.css @@ -7,7 +7,7 @@ } .errorView-with-tab { - top: 42px; + top: 32px; } .errorView-hidden { diff --git a/src/browser/css/components/MattermostView.css b/src/browser/css/components/MattermostView.css index cdb8b886643..8530511cb4c 100644 --- a/src/browser/css/components/MattermostView.css +++ b/src/browser/css/components/MattermostView.css @@ -7,7 +7,7 @@ } .mattermostView-with-tab { - top: 42px; + top: 32px; } .mattermostView-hidden {