Prototype updater window
This commit is contained in:
53
src/browser/components/UpdaterPage.jsx
Normal file
53
src/browser/components/UpdaterPage.jsx
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
const React = require('react');
|
||||||
|
const propTypes = require('prop-types');
|
||||||
|
const {Button, Navbar} = require('react-bootstrap');
|
||||||
|
|
||||||
|
function UpdaterPage(props) {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<Navbar>
|
||||||
|
<h1 className='UpdaterPage-heading'>{'New update is available'}</h1>
|
||||||
|
</Navbar>
|
||||||
|
<div className='container-fluid'>
|
||||||
|
<p>{'A new version of the Mattermost Desktop App is available!'}</p>
|
||||||
|
<p>{'Read the '}
|
||||||
|
<a
|
||||||
|
href='#'
|
||||||
|
onClick={props.onClickReleaseNotes}
|
||||||
|
>{'release notes'}</a>
|
||||||
|
{' to learn more.'}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<Navbar
|
||||||
|
className='UpdaterPage-footer'
|
||||||
|
fixedBottom={true}
|
||||||
|
fluid={true}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
className='UpdaterPage-skipButton'
|
||||||
|
bsStyle='link'
|
||||||
|
onClick={props.onClickSkip}
|
||||||
|
>{'Skip this version'}</Button>
|
||||||
|
<div className='pull-right'>
|
||||||
|
<Button
|
||||||
|
bsStyle='link'
|
||||||
|
onClick={props.onClickRemind}
|
||||||
|
>{'Remind me in 2 days'}</Button>
|
||||||
|
<Button
|
||||||
|
bsStyle='primary'
|
||||||
|
onClick={props.onClickInstall}
|
||||||
|
>{'Install Update'}</Button>
|
||||||
|
</div>
|
||||||
|
</Navbar>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdaterPage.propTypes = {
|
||||||
|
onClickInstall: propTypes.func.isRequired,
|
||||||
|
onClickReleaseNotes: propTypes.func.isRequired,
|
||||||
|
onClickRemind: propTypes.func.isRequired,
|
||||||
|
onClickSkip: propTypes.func.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = UpdaterPage;
|
12
src/browser/css/components/UpdaterPage.css
Normal file
12
src/browser/css/components/UpdaterPage.css
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
.UpdaterPage-heading {
|
||||||
|
font-size: 20pt;
|
||||||
|
margin: 10px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.UpdaterPage-skipButton {
|
||||||
|
padding-left: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.UpdaterPage-footer {
|
||||||
|
padding: 1em 0;
|
||||||
|
}
|
@@ -7,3 +7,4 @@
|
|||||||
@import url("TabBar.css");
|
@import url("TabBar.css");
|
||||||
@import url("TeamListItem.css");
|
@import url("TeamListItem.css");
|
||||||
@import url("Finder.css");
|
@import url("Finder.css");
|
||||||
|
@import url("UpdaterPage.css");
|
||||||
|
13
src/browser/updater.html
Normal file
13
src/browser/updater.html
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Updater</title>
|
||||||
|
<link rel="stylesheet" href="../node_modules/bootstrap/dist/css/bootstrap.min.css">
|
||||||
|
<link rel="stylesheet" href="css/components/index.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="content"></div>
|
||||||
|
<script src="updater_bundle.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
22
src/browser/updater.jsx
Normal file
22
src/browser/updater.jsx
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
const React = require('react');
|
||||||
|
const ReactDOM = require('react-dom');
|
||||||
|
const {ipcRenderer} = require('electron');
|
||||||
|
const UpdaterPage = require('./components/UpdaterPage.jsx');
|
||||||
|
|
||||||
|
ReactDOM.render(
|
||||||
|
<UpdaterPage
|
||||||
|
onClickReleaseNotes={() => {
|
||||||
|
ipcRenderer.send('click-release-notes');
|
||||||
|
}}
|
||||||
|
onClickSkip={() => {
|
||||||
|
ipcRenderer.send('click-skip');
|
||||||
|
}}
|
||||||
|
onClickRemind={() => {
|
||||||
|
ipcRenderer.send('click-remind');
|
||||||
|
}}
|
||||||
|
onClickInstall={() => {
|
||||||
|
ipcRenderer.send('click-install');
|
||||||
|
}}
|
||||||
|
/>,
|
||||||
|
document.getElementById('content')
|
||||||
|
);
|
17
src/main.js
17
src/main.js
@@ -26,6 +26,7 @@ import {protocols} from '../electron-builder.json';
|
|||||||
|
|
||||||
import CriticalErrorHandler from './main/CriticalErrorHandler';
|
import CriticalErrorHandler from './main/CriticalErrorHandler';
|
||||||
import {upgradeAutoLaunch} from './main/autoLaunch';
|
import {upgradeAutoLaunch} from './main/autoLaunch';
|
||||||
|
import {createUpdaterWindow} from './main/autoUpdater';
|
||||||
|
|
||||||
autoUpdater.on('error', (err) => {
|
autoUpdater.on('error', (err) => {
|
||||||
console.log('autoUpdater.on error');
|
console.log('autoUpdater.on error');
|
||||||
@@ -77,6 +78,7 @@ const assetsDir = path.resolve(app.getAppPath(), 'assets');
|
|||||||
// Keep a global reference of the window object, if you don't, the window will
|
// Keep a global reference of the window object, if you don't, the window will
|
||||||
// be closed automatically when the JavaScript object is garbage collected.
|
// be closed automatically when the JavaScript object is garbage collected.
|
||||||
var mainWindow = null;
|
var mainWindow = null;
|
||||||
|
let updaterWindow;
|
||||||
let spellChecker = null;
|
let spellChecker = null;
|
||||||
let deeplinkingUrl = null;
|
let deeplinkingUrl = null;
|
||||||
let scheme = null;
|
let scheme = null;
|
||||||
@@ -440,6 +442,21 @@ app.on('ready', () => {
|
|||||||
catch((err) => console.log('An error occurred: ', err));
|
catch((err) => console.log('An error occurred: ', err));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updaterWindow = createUpdaterWindow({linuxAppIcon: path.join(assetsDir, 'appicon.png'), nextVersion: '0.0.0'});
|
||||||
|
updaterWindow.
|
||||||
|
on('click-skip', () => {
|
||||||
|
console.log('click-skip');
|
||||||
|
}).
|
||||||
|
on('click-remind', () => {
|
||||||
|
console.log('click-remind');
|
||||||
|
}).
|
||||||
|
on('click-install', () => {
|
||||||
|
console.log('click-install');
|
||||||
|
}).
|
||||||
|
on('click-release-notes', () => {
|
||||||
|
console.log('click-release-notes');
|
||||||
|
});
|
||||||
|
|
||||||
// Protocol handler for win32
|
// Protocol handler for win32
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
// Keep only command line / deep linked argument. Make sure it's not squirrel command
|
// Keep only command line / deep linked argument. Make sure it's not squirrel command
|
||||||
|
44
src/main/autoUpdater.js
Normal file
44
src/main/autoUpdater.js
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
const {app, BrowserWindow, ipcMain} = require('electron');
|
||||||
|
|
||||||
|
function setEvent(win, eventName) {
|
||||||
|
ipcMain.on(eventName, (event) => {
|
||||||
|
if (event.sender === win.webContents) {
|
||||||
|
win.emit(eventName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function createUpdaterWindow(options) {
|
||||||
|
const windowWidth = 480;
|
||||||
|
const windowHeight = 240;
|
||||||
|
const windowOptions = {
|
||||||
|
title: `${app.getName()} Updater`,
|
||||||
|
maximizable: false,
|
||||||
|
show: false,
|
||||||
|
width: windowWidth,
|
||||||
|
height: windowHeight,
|
||||||
|
resizable: false,
|
||||||
|
autoHideMenuBar: true
|
||||||
|
};
|
||||||
|
if (process.platform === 'linux') {
|
||||||
|
windowOptions.icon = options.linuxAppIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
const win = new BrowserWindow(windowOptions);
|
||||||
|
win.once('ready-to-show', () => {
|
||||||
|
win.show();
|
||||||
|
});
|
||||||
|
const updaterURL = (global.isDev ? 'http://localhost:8080' : `file://${app.getAppPath()}`) + '/browser/updater.html';
|
||||||
|
win.loadURL(updaterURL);
|
||||||
|
|
||||||
|
setEvent(win, 'click-release-notes');
|
||||||
|
setEvent(win, 'click-skip');
|
||||||
|
setEvent(win, 'click-remind');
|
||||||
|
setEvent(win, 'click-install');
|
||||||
|
|
||||||
|
return win;
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
createUpdaterWindow
|
||||||
|
};
|
@@ -15,6 +15,7 @@ module.exports = merge(base, {
|
|||||||
entry: {
|
entry: {
|
||||||
index: './src/browser/index.jsx',
|
index: './src/browser/index.jsx',
|
||||||
settings: './src/browser/settings.jsx',
|
settings: './src/browser/settings.jsx',
|
||||||
|
updater: './src/browser/updater.jsx',
|
||||||
'webview/mattermost': './src/browser/webview/mattermost.js',
|
'webview/mattermost': './src/browser/webview/mattermost.js',
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
Reference in New Issue
Block a user