@@ -19,6 +19,7 @@ limitations under the License.
1919var React = require ( 'react' ) ;
2020var sdk = require ( 'matrix-react-sdk' ) ;
2121import Modal from 'matrix-react-sdk/lib/Modal' ;
22+ import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg' ;
2223
2324/**
2425 * Check a version string is compatible with the Changelog
@@ -31,35 +32,56 @@ function checkVersion(ver) {
3132
3233export default function NewVersionBar ( props ) {
3334 const onChangelogClicked = ( ) => {
34- const ChangelogDialog = sdk . getComponent ( 'dialogs.ChangelogDialog' ) ;
35-
36- Modal . createDialog ( ChangelogDialog , {
37- version : props . version ,
38- newVersion : props . newVersion ,
39- onFinished : ( update ) => {
40- if ( update ) {
41- window . location . reload ( ) ;
35+ if ( props . releaseNotes ) {
36+ const QuestionDialog = sdk . getComponent ( 'dialogs.QuestionDialog' ) ;
37+ Modal . createDialog ( QuestionDialog , {
38+ title : "What's New" ,
39+ description : < pre className = "changelog_text" > { props . releaseNotes } </ pre > ,
40+ button : "Update" ,
41+ onFinished : ( update ) => {
42+ if ( update && PlatformPeg . get ( ) ) {
43+ PlatformPeg . get ( ) . installUpdate ( ) ;
44+ }
45+ }
46+ } ) ;
47+ } else {
48+ const ChangelogDialog = sdk . getComponent ( 'dialogs.ChangelogDialog' ) ;
49+ Modal . createDialog ( ChangelogDialog , {
50+ version : props . version ,
51+ newVersion : props . newVersion ,
52+ releaseNotes : releaseNotes ,
53+ onFinished : ( update ) => {
54+ if ( update && PlatformPeg . get ( ) ) {
55+ PlatformPeg . get ( ) . installUpdate ( ) ;
56+ }
4257 }
43- }
44- } ) ;
58+ } ) ;
59+ }
60+ } ;
61+
62+ const onUpdateClicked = ( ) => {
63+ PlatformPeg . get ( ) . installUpdate ( ) ;
4564 } ;
4665
47- let changelog_button ;
48- if ( checkVersion ( props . version ) && checkVersion ( props . newVersion ) ) {
49- changelog_button = < button className = "mx_MatrixToolbar_action" onClick = { onChangelogClicked } > Changelog</ button > ;
66+ let action_button ;
67+ if ( props . releaseNotes || ( checkVersion ( props . version ) && checkVersion ( props . newVersion ) ) ) {
68+ action_button = < button className = "mx_MatrixToolbar_action" onClick = { onChangelogClicked } > What's new?</ button > ;
69+ } else if ( PlatformPeg . get ( ) ) {
70+ action_button = < button className = "mx_MatrixToolbar_action" onClick = { onUpdateClicked } > Update</ button > ;
5071 }
5172 return (
5273 < div className = "mx_MatrixToolbar" >
5374 < img className = "mx_MatrixToolbar_warning" src = "img/warning.svg" width = "24" height = "23" alt = "/!\" />
5475 < div className = "mx_MatrixToolbar_content" >
55- A new version of Riot is available. Refresh your browser.
76+ A new version of Riot is available.
5677 </ div >
57- { changelog_button }
78+ { action_button }
5879 </ div >
5980 ) ;
6081}
6182
6283NewVersionBar . propTypes = {
6384 version : React . PropTypes . string . isRequired ,
6485 newVersion : React . PropTypes . string . isRequired ,
86+ releaseNotes : React . PropTypes . string ,
6587} ;
0 commit comments