[MM-18552] Autoupdater (#1714)
* wip * background download * various fixes * wip * wokring autoupgrade * fix menu * fix windows * cleanup * add publishername * fix messages and titles * Test updates * Moved module and added functionality to click icon to install (instead of just download) * Add auto update setting, update on close app if downloaded * Tests, changes for security fixes, update version number * Update E2E tests * Lint fix * Update to latest electron-updater * Revert to stable electron-builder (only needed to update electron-updater) * Fix package-lock * skip flaky test * Update package * Fix E2E test * Fixes for enabling/disabled autoupdater * Fixed GPO definitions * [MM-38300] Set localhost as the test server * blank * Switch to s3 bucket for testing * Update icons to match spec * Add menu items for download/update actions * Type and test fixes * Fix notification circle * Fix macOS app not restarting on Restart/Update * Update dialog box titles * Turn off file system check for Linux * Changes to support deployments * Testing autoupdater deployments to s3 * disable tests for now * asfrehwf * fine no windows WHATEVER * remove windows again * Try universal all in one * pffftttngggguhhhh * make sure it's working * Missed artifacts script * Modify destination as well * one more time! * Update yml files * Oops * add yq manually * oof * Fix the script to work properly * Fix release script * Fix script again so it runs in time * Build version 2 * Revert build specific changes * Lint override * Fix build apps for PR builds * One more change * Add file generation for .deb repo * Deb repo test * skip tests for now * Fix artifact push * Persist after repo creation * Put tests back * Fix unit tests * Enable mac generated builds temp * Temporarily disable tests * Fix issue where notification doesn't pop dialog box * Try version 2 again * Put the version back * Attempting to debug mac app path issue * Fix issue where Mac app will quarantine itself after first update * Lock versions of yq * Fix yq for mac * As usual, Mac is difficult :P * Add quotes to anti-quarantine command * Change to spawn to avoid command injection * Oops * Nightly deployment changes (#2005) * Test nightly deploy * I fixed a some things * aaaaaaaaa * Restore old bucket * Added progress indicator via tooltip * Ship nightly builds to main S3 bucket * PR feedback * Fix a couple security exploits * Fix opacity on light mode button * Use large app icon * Resize icon for Windows * Resize icon for Mac * Update to electron-updater final * Remove Mac support and deb repo * Typo * Remove deb script * Remove checksum function * Removed autoUpdateSettingsPath * Update URL Co-authored-by: = <=> Co-authored-by: Devin Binnie <devin.binnie@mattermost.com> Co-authored-by: Mattermod <mattermod@users.noreply.github.com> Co-authored-by: Devin Binnie <52460000+devinbinnie@users.noreply.github.com>
This commit is contained in:
@@ -2,11 +2,13 @@
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
import classNames from 'classnames';
|
||||
import React, {Fragment} from 'react';
|
||||
import {Container, Row} from 'react-bootstrap';
|
||||
import {DropResult} from 'react-beautiful-dnd';
|
||||
import DotsVerticalIcon from 'mdi-react/DotsVerticalIcon';
|
||||
import {IpcRendererEvent} from 'electron/renderer';
|
||||
import prettyBytes from 'pretty-bytes';
|
||||
|
||||
import {TeamWithTabs} from 'types/config';
|
||||
|
||||
@@ -36,6 +38,11 @@ import {
|
||||
CLOSE_TEAMS_DROPDOWN,
|
||||
OPEN_TEAMS_DROPDOWN,
|
||||
SWITCH_TAB,
|
||||
UPDATE_AVAILABLE,
|
||||
UPDATE_DOWNLOADED,
|
||||
UPDATE_PROGRESS,
|
||||
START_UPGRADE,
|
||||
START_DOWNLOAD,
|
||||
CLOSE_TAB,
|
||||
} from 'common/communication';
|
||||
|
||||
@@ -50,6 +57,7 @@ import TabBar from './TabBar';
|
||||
import ExtraBar from './ExtraBar';
|
||||
import ErrorView from './ErrorView';
|
||||
import TeamDropdownButton from './TeamDropdownButton';
|
||||
import '../css/components/UpgradeButton.scss';
|
||||
|
||||
enum Status {
|
||||
LOADING = 1,
|
||||
@@ -59,6 +67,13 @@ enum Status {
|
||||
NOSERVERS = -2,
|
||||
}
|
||||
|
||||
enum UpgradeStatus {
|
||||
NONE = 0,
|
||||
AVAILABLE = 1,
|
||||
DOWNLOADING = 2,
|
||||
DOWNLOADED = 3,
|
||||
}
|
||||
|
||||
type Props = {
|
||||
teams: TeamWithTabs[];
|
||||
lastActiveTeam?: number;
|
||||
@@ -82,6 +97,14 @@ type State = {
|
||||
fullScreen?: boolean;
|
||||
showExtraBar?: boolean;
|
||||
isMenuOpen: boolean;
|
||||
upgradeStatus: UpgradeStatus;
|
||||
upgradeProgress?: {
|
||||
total: number;
|
||||
delta: number;
|
||||
transferred: number;
|
||||
percent: number;
|
||||
bytesPerSecond: number;
|
||||
};
|
||||
};
|
||||
|
||||
type TabViewStatus = {
|
||||
@@ -119,6 +142,7 @@ export default class MainPage extends React.PureComponent<Props, State> {
|
||||
tabViewStatus: new Map(this.props.teams.map((team) => team.tabs.map((tab) => getTabViewName(team.name, tab.name))).flat().map((tabViewName) => [tabViewName, {status: Status.LOADING}])),
|
||||
darkMode: this.props.darkMode,
|
||||
isMenuOpen: false,
|
||||
upgradeStatus: UpgradeStatus.NONE,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -221,6 +245,27 @@ export default class MainPage extends React.PureComponent<Props, State> {
|
||||
this.setState({isMenuOpen: true});
|
||||
});
|
||||
|
||||
window.ipcRenderer.on(UPDATE_AVAILABLE, () => {
|
||||
this.setState({upgradeStatus: UpgradeStatus.AVAILABLE});
|
||||
});
|
||||
|
||||
window.ipcRenderer.on(UPDATE_DOWNLOADED, () => {
|
||||
this.setState({upgradeStatus: UpgradeStatus.DOWNLOADED});
|
||||
});
|
||||
|
||||
window.ipcRenderer.on(UPDATE_PROGRESS, (event, total, delta, transferred, percent, bytesPerSecond) => {
|
||||
this.setState({
|
||||
upgradeStatus: UpgradeStatus.DOWNLOADING,
|
||||
upgradeProgress: {
|
||||
total,
|
||||
delta,
|
||||
transferred,
|
||||
percent,
|
||||
bytesPerSecond,
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
if (window.process.platform !== 'darwin') {
|
||||
window.ipcRenderer.on(FOCUS_THREE_DOT_MENU, () => {
|
||||
if (this.threeDotMenu.current) {
|
||||
@@ -334,16 +379,11 @@ export default class MainPage extends React.PureComponent<Props, State> {
|
||||
/>
|
||||
);
|
||||
|
||||
let topBarClassName = 'topBar';
|
||||
if (window.process.platform === 'darwin') {
|
||||
topBarClassName += ' macOS';
|
||||
}
|
||||
if (this.state.darkMode) {
|
||||
topBarClassName += ' darkMode';
|
||||
}
|
||||
if (this.state.fullScreen) {
|
||||
topBarClassName += ' fullScreen';
|
||||
}
|
||||
const topBarClassName = classNames('topBar', {
|
||||
macOS: window.process.platform === 'darwin',
|
||||
darkMode: this.state.darkMode,
|
||||
fullScreen: this.state.fullScreen,
|
||||
});
|
||||
|
||||
let maxButton;
|
||||
if (this.state.maximized || this.state.fullScreen) {
|
||||
@@ -366,11 +406,46 @@ export default class MainPage extends React.PureComponent<Props, State> {
|
||||
);
|
||||
}
|
||||
|
||||
let overlayGradient;
|
||||
if (window.process.platform !== 'darwin') {
|
||||
overlayGradient = (
|
||||
<span className='overlay-gradient'/>
|
||||
);
|
||||
let upgradeTooltip;
|
||||
switch (this.state.upgradeStatus) {
|
||||
case UpgradeStatus.AVAILABLE:
|
||||
upgradeTooltip = 'Update available';
|
||||
break;
|
||||
case UpgradeStatus.DOWNLOADED:
|
||||
upgradeTooltip = 'Update ready to install';
|
||||
break;
|
||||
case UpgradeStatus.DOWNLOADING:
|
||||
upgradeTooltip = `Downloading update. ${String(this.state.upgradeProgress?.percent).split('.')[0]}% of ${prettyBytes(this.state.upgradeProgress?.total || 0)} @ ${prettyBytes(this.state.upgradeProgress?.bytesPerSecond || 0)}/s`;
|
||||
break;
|
||||
}
|
||||
|
||||
let upgradeIcon;
|
||||
if (this.state.upgradeStatus !== UpgradeStatus.NONE) {
|
||||
upgradeIcon = (
|
||||
<span className={classNames('upgrade-btns', {darkMode: this.state.darkMode})}>
|
||||
<div
|
||||
className={classNames('button upgrade-button', {
|
||||
rotate: this.state.upgradeStatus === UpgradeStatus.DOWNLOADING,
|
||||
})}
|
||||
title={upgradeTooltip}
|
||||
onClick={() => {
|
||||
if (this.state.upgradeStatus === UpgradeStatus.DOWNLOADING) {
|
||||
return;
|
||||
}
|
||||
|
||||
window.ipcRenderer.send(this.state.upgradeStatus === UpgradeStatus.DOWNLOADED ? START_UPGRADE : START_DOWNLOAD);
|
||||
}}
|
||||
>
|
||||
<i
|
||||
className={classNames({
|
||||
'icon-arrow-down-bold-circle-outline': this.state.upgradeStatus === UpgradeStatus.AVAILABLE,
|
||||
'icon-sync': this.state.upgradeStatus === UpgradeStatus.DOWNLOADING,
|
||||
'icon-arrow-up-bold-circle-outline': this.state.upgradeStatus === UpgradeStatus.DOWNLOADED,
|
||||
})}
|
||||
/>
|
||||
{(this.state.upgradeStatus !== UpgradeStatus.DOWNLOADING) && <div className={'circle'}/>}
|
||||
</div>
|
||||
</span>);
|
||||
}
|
||||
|
||||
let titleBarButtons;
|
||||
@@ -435,7 +510,7 @@ export default class MainPage extends React.PureComponent<Props, State> {
|
||||
darkMode={this.state.darkMode}
|
||||
/>
|
||||
{tabsRow}
|
||||
{overlayGradient}
|
||||
{upgradeIcon}
|
||||
{titleBarButtons}
|
||||
</div>
|
||||
</Row>
|
||||
|
Reference in New Issue
Block a user