Update notifications

Summary: Instead of showing a modal alert, we are now showing a notification, when an update is available. Clicking the notification will restart Sonar and install the plugin. Otherwise, the update will be installed on the next start of Sonar.

Reviewed By: jknoxville, priteshrnandgaonkar

Differential Revision: D8732743

fbshipit-source-id: b9e73a0d5b0866ab79b1e17274c501eac2ef41cc
This commit is contained in:
Daniel Büchele
2018-07-05 04:44:38 -07:00
committed by Facebook Github Bot
parent 2a46f93eab
commit 0ddeb076bb

View File

@@ -45,17 +45,11 @@ export default class AutoUpdateVersion extends Component<{}, State> {
remote.autoUpdater.on('update-downloaded', () => { remote.autoUpdater.on('update-downloaded', () => {
this.setState({updater: 'update-downloaded'}); this.setState({updater: 'update-downloaded'});
remote.dialog.showMessageBox( const notification = new window.Notification('Update available', {
{ body: 'Restart Sonar to update to the latest version.',
title: 'Update available', requireInteraction: true,
message: 'A new version of Sonar is available!', });
detail: `You have Sonar ${version} which is outdated. Update to the latest version now.`, notification.onclick = remote.autoUpdater.quitAndInstall;
buttons: ['Install and Restart'],
},
() => {
remote.autoUpdater.quitAndInstall();
},
);
}); });
remote.autoUpdater.on('error', error => { remote.autoUpdater.on('error', error => {
@@ -92,7 +86,9 @@ export default class AutoUpdateVersion extends Component<{}, State> {
</span> </span>
)} )}
{this.state.updater === 'update-downloaded' && ( {this.state.updater === 'update-downloaded' && (
<span title="Update available. Restart Sonar."> <span
title="Update available. Restart Sonar."
onClick={remote.autoUpdater.quitAndInstall}>
<Glyph color={colors.light30} name="breaking-news" /> <Glyph color={colors.light30} name="breaking-news" />
</span> </span>
)} )}