mirror of https://github.com/vector-im/riot-web
Split NewVersionBar release notes / changelog
and change the class to use React createClass syntax while I'm at it, rather than a completely different third style we use nowhere else in the project.pull/2532/head
parent
8c3fed7559
commit
e8494c3dc7
|
@ -16,8 +16,8 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var React = require('react');
|
import React from 'react';
|
||||||
var sdk = require('matrix-react-sdk');
|
import sdk from 'matrix-react-sdk';
|
||||||
import Modal from 'matrix-react-sdk/lib/Modal';
|
import Modal from 'matrix-react-sdk/lib/Modal';
|
||||||
import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg';
|
import PlatformPeg from 'matrix-react-sdk/lib/PlatformPeg';
|
||||||
|
|
||||||
|
@ -30,58 +30,71 @@ function checkVersion(ver) {
|
||||||
return parts[0] == 'vector' && parts[2] == 'react' && parts[4] == 'js';
|
return parts[0] == 'vector' && parts[2] == 'react' && parts[4] == 'js';
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function NewVersionBar(props) {
|
export default React.createClass({
|
||||||
const onChangelogClicked = () => {
|
propTypes: {
|
||||||
if (props.releaseNotes) {
|
version: React.PropTypes.string.isRequired,
|
||||||
const QuestionDialog = sdk.getComponent('dialogs.QuestionDialog');
|
newVersion: React.PropTypes.string.isRequired,
|
||||||
Modal.createDialog(QuestionDialog, {
|
releaseNotes: React.PropTypes.string,
|
||||||
title: "What's New",
|
},
|
||||||
description: <pre className="changelog_text">{props.releaseNotes}</pre>,
|
|
||||||
button: "Update",
|
onChangelogClicked: function() {
|
||||||
onFinished: (update) => {
|
// If we have release notes to display, we display them. Otherwise,
|
||||||
if(update && PlatformPeg.get()) {
|
// we display the Changelog Dialog which takes two versions and
|
||||||
PlatformPeg.get().installUpdate();
|
// automatically tells you what's changed (provided the versions
|
||||||
}
|
// are in the right format)
|
||||||
}
|
if (this.props.releaseNotes) {
|
||||||
});
|
this.displayReleaseNotes(this.props.releaseNotes);
|
||||||
} else {
|
} else if (checkVersion(this.props.version) && checkVersion(this.props.newVersion)) {
|
||||||
const ChangelogDialog = sdk.getComponent('dialogs.ChangelogDialog');
|
this.displayChangelog();
|
||||||
Modal.createDialog(ChangelogDialog, {
|
|
||||||
version: props.version,
|
|
||||||
newVersion: props.newVersion,
|
|
||||||
releaseNotes: releaseNotes,
|
|
||||||
onFinished: (update) => {
|
|
||||||
if(update && PlatformPeg.get()) {
|
|
||||||
PlatformPeg.get().installUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
};
|
},
|
||||||
|
|
||||||
const onUpdateClicked = () => {
|
displayReleaseNotes: function(releaseNotes) {
|
||||||
|
const QuestionDialog = sdk.getComponent('dialogs.QuestionDialog');
|
||||||
|
Modal.createDialog(QuestionDialog, {
|
||||||
|
title: "What's New",
|
||||||
|
description: <pre className="changelog_text">{releaseNotes}</pre>,
|
||||||
|
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();
|
PlatformPeg.get().installUpdate();
|
||||||
};
|
},
|
||||||
|
|
||||||
let action_button;
|
render: function() {
|
||||||
if (props.releaseNotes || (checkVersion(props.version) && checkVersion(props.newVersion))) {
|
let action_button;
|
||||||
action_button = <button className="mx_MatrixToolbar_action" onClick={onChangelogClicked}>What's new?</button>;
|
if (this.props.releaseNotes || (checkVersion(this.props.version) && checkVersion(this.props.newVersion))) {
|
||||||
} else if (PlatformPeg.get()) {
|
action_button = <button className="mx_MatrixToolbar_action" onClick={this.onChangelogClicked}>What's new?</button>;
|
||||||
action_button = <button className="mx_MatrixToolbar_action" onClick={onUpdateClicked}>Update</button>;
|
} else if (PlatformPeg.get()) {
|
||||||
}
|
action_button = <button className="mx_MatrixToolbar_action" onClick={this.onUpdateClicked}>Update</button>;
|
||||||
return (
|
}
|
||||||
<div className="mx_MatrixToolbar">
|
return (
|
||||||
<img className="mx_MatrixToolbar_warning" src="img/warning.svg" width="24" height="23" alt="/!\"/>
|
<div className="mx_MatrixToolbar">
|
||||||
<div className="mx_MatrixToolbar_content">
|
<img className="mx_MatrixToolbar_warning" src="img/warning.svg" width="24" height="23" alt="/!\"/>
|
||||||
A new version of Riot is available.
|
<div className="mx_MatrixToolbar_content">
|
||||||
|
A new version of Riot is available.
|
||||||
|
</div>
|
||||||
|
{action_button}
|
||||||
</div>
|
</div>
|
||||||
{action_button}
|
);
|
||||||
</div>
|
}
|
||||||
);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
NewVersionBar.propTypes = {
|
|
||||||
version: React.PropTypes.string.isRequired,
|
|
||||||
newVersion: React.PropTypes.string.isRequired,
|
|
||||||
releaseNotes: React.PropTypes.string,
|
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in New Issue