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 ( -