diff --git a/src/components/views/globals/NewVersionBar.js b/src/components/views/globals/NewVersionBar.js index 3ae9580411..36d6bc71bd 100644 --- a/src/components/views/globals/NewVersionBar.js +++ b/src/components/views/globals/NewVersionBar.js @@ -16,8 +16,8 @@ limitations under the License. 'use strict'; -var React = require('react'); -var sdk = require('matrix-react-sdk'); +import React from 'react'; +import sdk from 'matrix-react-sdk'; import Modal from 'matrix-react-sdk/lib/Modal'; import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg'; @@ -30,58 +30,65 @@ function checkVersion(ver) { return parts[0] == 'vector' && parts[2] == 'react' && parts[4] == 'js'; } -export default function NewVersionBar(props) { - const onChangelogClicked = () => { - if (props.releaseNotes) { - const QuestionDialog = sdk.getComponent('dialogs.QuestionDialog'); - Modal.createDialog(QuestionDialog, { - title: "What's New", - description:
{props.releaseNotes}
, - 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, - onFinished: (update) => { - if(update && PlatformPeg.get()) { - PlatformPeg.get().installUpdate(); - } - } - }); - } - }; +export default React.createClass({ + propTypes: { + version: React.PropTypes.string.isRequired, + newVersion: React.PropTypes.string.isRequired, + releaseNotes: React.PropTypes.string, + }, - const onUpdateClicked = () => { + displayReleaseNotes: function(releaseNotes) { + const QuestionDialog = sdk.getComponent('dialogs.QuestionDialog'); + Modal.createDialog(QuestionDialog, { + title: "What's New", + description:
{releaseNotes}
, + button: "Update", + onFinished: (update) => { + if(update && PlatformPeg.get()) { + PlatformPeg.get().installUpdate(); + } + } + }); + }, + + displayChangelog: function() { + const ChangelogDialog = sdk.getComponent('dialogs.ChangelogDialog'); + Modal.createDialog(ChangelogDialog, { + version: this.props.version, + newVersion: this.props.newVersion, + onFinished: (update) => { + if(update && PlatformPeg.get()) { + PlatformPeg.get().installUpdate(); + } + } + }); + }, + + onUpdateClicked: function() { PlatformPeg.get().installUpdate(); - }; + }, - let action_button; - if (props.releaseNotes || (checkVersion(props.version) && checkVersion(props.newVersion))) { - action_button = ; - } else if (PlatformPeg.get()) { - action_button = ; - } - return ( -
- /!\ -
- A new version of Riot is available. + render: function() { + let action_button; + // If we have release notes to display, we display them. Otherwise, + // we display the Changelog Dialog which takes two versions and + // automatically tells you what's changed (provided the versions + // are in the right format) + if (this.props.releaseNotes) { + action_button = ; + } else if (checkVersion(this.props.version) && checkVersion(this.props.newVersion)) { + action_button = ; + } else if (PlatformPeg.get()) { + action_button = ; + } + return ( +
+ /!\ +
+ A new version of Riot is available. +
+ {action_button}
- {action_button} -
- ); -} - -NewVersionBar.propTypes = { - version: React.PropTypes.string.isRequired, - newVersion: React.PropTypes.string.isRequired, - releaseNotes: React.PropTypes.string, -}; + ); + } +}); diff --git a/src/vector/platform/VectorBasePlatform.js b/src/vector/platform/VectorBasePlatform.js index a988a4c7a4..d2ed8c344c 100644 --- a/src/vector/platform/VectorBasePlatform.js +++ b/src/vector/platform/VectorBasePlatform.js @@ -1,7 +1,8 @@ // @flow /* -Copyright 2016 Aviral Dasgupta and OpenMarket Ltd +Copyright 2016 Aviral Dasgupta +Copyright 2016 OpenMarket Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/vector/platform/WebPlatform.js b/src/vector/platform/WebPlatform.js index 1536db6193..4d99496729 100644 --- a/src/vector/platform/WebPlatform.js +++ b/src/vector/platform/WebPlatform.js @@ -1,7 +1,8 @@ // @flow /* -Copyright 2016 Aviral Dasgupta and OpenMarket Ltd +Copyright 2016 Aviral Dasgupta +Copyright 2016 OpenMarket Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/src/vector/platform/index.js b/src/vector/platform/index.js index 652d2455b1..d2ed1bc9a7 100644 --- a/src/vector/platform/index.js +++ b/src/vector/platform/index.js @@ -1,7 +1,8 @@ // @flow /* -Copyright 2016 Aviral Dasgupta and OpenMarket Ltd +Copyright 2016 Aviral Dasgupta +Copyright 2016 OpenMarket Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.