-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move 'new version' support into Platform #2532
Changes from 4 commits
64fdb29
c75118c
17bb476
8c3fed7
e8494c3
108af83
4d0b492
f1b72df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ limitations under the License. | |
var React = require('react'); | ||
var sdk = require('matrix-react-sdk'); | ||
import Modal from 'matrix-react-sdk/lib/Modal'; | ||
import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg'; | ||
|
||
/** | ||
* Check a version string is compatible with the Changelog | ||
|
@@ -31,35 +32,56 @@ function checkVersion(ver) { | |
|
||
export default function NewVersionBar(props) { | ||
const onChangelogClicked = () => { | ||
const ChangelogDialog = sdk.getComponent('dialogs.ChangelogDialog'); | ||
|
||
Modal.createDialog(ChangelogDialog, { | ||
version: props.version, | ||
newVersion: props.newVersion, | ||
onFinished: (update) => { | ||
if(update) { | ||
window.location.reload(); | ||
if (props.releaseNotes) { | ||
const QuestionDialog = sdk.getComponent('dialogs.QuestionDialog'); | ||
Modal.createDialog(QuestionDialog, { | ||
title: "What's New", | ||
description: <pre className="changelog_text">{props.releaseNotes}</pre>, | ||
button: "Update", | ||
onFinished: (update) => { | ||
if(update && PlatformPeg.get()) { | ||
PlatformPeg.get().installUpdate(); | ||
} | ||
} | ||
}); | ||
} else { | ||
const ChangelogDialog = sdk.getComponent('dialogs.ChangelogDialog'); | ||
Modal.createDialog(ChangelogDialog, { | ||
version: props.version, | ||
newVersion: props.newVersion, | ||
releaseNotes: releaseNotes, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
onFinished: (update) => { | ||
if(update && PlatformPeg.get()) { | ||
PlatformPeg.get().installUpdate(); | ||
} | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
}; | ||
|
||
const onUpdateClicked = () => { | ||
PlatformPeg.get().installUpdate(); | ||
}; | ||
|
||
let changelog_button; | ||
if (checkVersion(props.version) && checkVersion(props.newVersion)) { | ||
changelog_button = <button className="mx_MatrixToolbar_action" onClick={onChangelogClicked}>Changelog</button>; | ||
let action_button; | ||
if (props.releaseNotes || (checkVersion(props.version) && checkVersion(props.newVersion))) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could do with a comment here explaining that we show a questiondialog if we have releasenotes, or a changelogdialog if we don't. |
||
action_button = <button className="mx_MatrixToolbar_action" onClick={onChangelogClicked}>What's new?</button>; | ||
} else if (PlatformPeg.get()) { | ||
action_button = <button className="mx_MatrixToolbar_action" onClick={onUpdateClicked}>Update</button>; | ||
} | ||
return ( | ||
<div className="mx_MatrixToolbar"> | ||
<img className="mx_MatrixToolbar_warning" src="img/warning.svg" width="24" height="23" alt="/!\"/> | ||
<div className="mx_MatrixToolbar_content"> | ||
A new version of Riot is available. Refresh your browser. | ||
A new version of Riot is available. | ||
</div> | ||
{changelog_button} | ||
{action_button} | ||
</div> | ||
); | ||
} | ||
|
||
NewVersionBar.propTypes = { | ||
version: React.PropTypes.string.isRequired, | ||
newVersion: React.PropTypes.string.isRequired, | ||
releaseNotes: React.PropTypes.string, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// @flow | ||
|
||
/* | ||
Copyright 2016 Aviral Dasgupta and OpenMarket Ltd | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import BasePlatform from 'matrix-react-sdk/lib/BasePlatform' | ||
|
||
/** | ||
* Vector-specific extensions to the BasePlatform template | ||
*/ | ||
export default class VectorBasePlatform extends BasePlatform { | ||
/** | ||
* Check for the availability of an update to the version of the | ||
* app that's currently running. | ||
* If an update is available, this function should dispatch the | ||
* 'new_version' action. | ||
*/ | ||
pollForUpdate() { | ||
} | ||
|
||
/** | ||
* Update the currently running app to the latest available | ||
* version and replace this instance of the app with the | ||
* new version. | ||
*/ | ||
installUpdate() { | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I feel like this should be two separate functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still think this needs splitting