Only show version bar if on develop

Or rather, if the version string is in the right format it to work.
This commit is contained in:
David Baker 2016-09-20 14:33:25 +01:00
parent c10b11a22c
commit 5011d3b158
1 changed files with 14 additions and 1 deletions

View File

@ -20,6 +20,15 @@ var React = require('react');
var sdk = require('matrix-react-sdk');
import Modal from 'matrix-react-sdk/lib/Modal';
/**
* Check a version string is compatible with the Changelog
* dialog
*/
function checkVersion(ver) {
const parts = ver.split('-');
return parts[0] == 'vector' && parts[2] == 'react' && parts[4] == 'js';
}
export default function NewVersionBar(props) {
const onChangelogClicked = () => {
const ChangelogDialog = sdk.getComponent('dialogs.ChangelogDialog');
@ -35,13 +44,17 @@ export default function NewVersionBar(props) {
});
};
let changelog_button;
if (checkVersion(props.version) && checkVersion(props.newVersion)) {
changelog_button = <button className="mx_MatrixToolbar_action" onClick={onChangelogClicked}>Changelog</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.
</div>
<button className="mx_MatrixToolbar_action" onClick={onChangelogClicked}>Changelog</button>
{changelog_button}
</div>
);
}