Iterate upon the room upgrade warning bar

This lessens the warning for unstable-but-not-official versions while still communicating that the version is unstable. In the future, we may want to make this state dismissable.
This commit is contained in:
Travis Ralston 2019-01-28 17:21:33 -07:00
parent c204cd7be3
commit f8de4ba2b0
4 changed files with 51 additions and 12 deletions

View file

@ -151,6 +151,10 @@ module.exports = React.createClass({
auxPanelMaxHeight: undefined, auxPanelMaxHeight: undefined,
statusBarVisible: false, statusBarVisible: false,
// We load this later by asking the js-sdk to suggest a version for us.
// This object is the result of Room#getRecommendedVersion()
upgradeRecommendation: null,
}; };
}, },
@ -637,6 +641,13 @@ module.exports = React.createClass({
this._calculatePeekRules(room); this._calculatePeekRules(room);
this._updatePreviewUrlVisibility(room); this._updatePreviewUrlVisibility(room);
this._loadMembersIfJoined(room); this._loadMembersIfJoined(room);
this._calculateRecommendedVersion(room);
},
_calculateRecommendedVersion: async function(room) {
this.setState({
upgradeRecommendation: await room.getRecommendedVersion(),
});
}, },
_loadMembersIfJoined: async function(room) { _loadMembersIfJoined: async function(room) {
@ -1661,8 +1672,10 @@ module.exports = React.createClass({
/>; />;
} }
const roomVersionRecommendation = this.state.upgradeRecommendation;
const showRoomUpgradeBar = ( const showRoomUpgradeBar = (
this.state.room.shouldUpgradeToVersion() && roomVersionRecommendation &&
roomVersionRecommendation.needsUpgrade &&
this.state.room.userMayUpgradeRoom(MatrixClientPeg.get().credentials.userId) this.state.room.userMayUpgradeRoom(MatrixClientPeg.get().credentials.userId)
); );
@ -1685,7 +1698,7 @@ module.exports = React.createClass({
hideCancel = true; // has own cancel hideCancel = true; // has own cancel
aux = <SearchBar ref="search_bar" searchInProgress={this.state.searchInProgress} onCancelClick={this.onCancelSearchClick} onSearch={this.onSearch} />; aux = <SearchBar ref="search_bar" searchInProgress={this.state.searchInProgress} onCancelClick={this.onCancelSearchClick} onSearch={this.onSearch} />;
} else if (showRoomUpgradeBar) { } else if (showRoomUpgradeBar) {
aux = <RoomUpgradeWarningBar room={this.state.room} />; aux = <RoomUpgradeWarningBar room={this.state.room} recommendation={roomVersionRecommendation} />;
hideCancel = true; hideCancel = true;
} else if (showRoomRecoveryReminder) { } else if (showRoomRecoveryReminder) {
aux = <RoomRecoveryReminder onDontAskAgainSet={this.onRoomRecoveryReminderDontAskAgain} />; aux = <RoomRecoveryReminder onDontAskAgainSet={this.onRoomRecoveryReminderDontAskAgain} />;

View file

@ -29,13 +29,15 @@ export default React.createClass({
onFinished: PropTypes.func.isRequired, onFinished: PropTypes.func.isRequired,
}, },
componentWillMount: function() { componentWillMount: async function() {
this._targetVersion = this.props.room.shouldUpgradeToVersion(); const recommended = await this.props.room.getRecommendedVersion();
this._targetVersion = recommended.version;
this.setState({busy: false});
}, },
getInitialState: function() { getInitialState: function() {
return { return {
busy: false, busy: true,
}; };
}, },

View file

@ -26,6 +26,7 @@ module.exports = React.createClass({
propTypes: { propTypes: {
room: PropTypes.object.isRequired, room: PropTypes.object.isRequired,
recommendation: PropTypes.object.isRequired,
}, },
onUpgradeClick: function() { onUpgradeClick: function() {
@ -35,19 +36,40 @@ module.exports = React.createClass({
render: function() { render: function() {
const AccessibleButton = sdk.getComponent('elements.AccessibleButton'); const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
return (
<div className="mx_RoomUpgradeWarningBar"> let upgradeText = (
<div className="mx_RoomUpgradeWarningBar_header"> <div>
{_t("There is a known vulnerability affecting this room.")}
</div>
<div className="mx_RoomUpgradeWarningBar_body"> <div className="mx_RoomUpgradeWarningBar_body">
{_t("This room version is vulnerable to malicious modification of room state.")} {_t("This room is using an unstable room version. If you aren't expecting this, please upgrade the room.")}
</div> </div>
<p className="mx_RoomUpgradeWarningBar_upgradelink"> <p className="mx_RoomUpgradeWarningBar_upgradelink">
<AccessibleButton onClick={this.onUpgradeClick}> <AccessibleButton onClick={this.onUpgradeClick}>
{_t("Click here to upgrade to the latest room version and ensure room integrity is protected.")} {_t("Click here to upgrade to the latest room version.")}
</AccessibleButton> </AccessibleButton>
</p> </p>
</div>
);
if (this.props.recommendation.urgent) {
upgradeText = (
<div>
<div className="mx_RoomUpgradeWarningBar_header">
{_t("There is a known vulnerability affecting this room.")}
</div>
<div className="mx_RoomUpgradeWarningBar_body">
{_t("This room version is vulnerable to malicious modification of room state.")}
</div>
<p className="mx_RoomUpgradeWarningBar_upgradelink">
<AccessibleButton onClick={this.onUpgradeClick}>
{_t("Click here to upgrade to the latest room version and ensure room integrity is protected.")}
</AccessibleButton>
</p>
</div>
);
}
return (
<div className="mx_RoomUpgradeWarningBar">
{upgradeText}
<div className="mx_RoomUpgradeWarningBar_small"> <div className="mx_RoomUpgradeWarningBar_small">
{_t("Only room administrators will see this warning")} {_t("Only room administrators will see this warning")}
</div> </div>

View file

@ -743,6 +743,8 @@
"Internal room ID: ": "Internal room ID: ", "Internal room ID: ": "Internal room ID: ",
"Room version number: ": "Room version number: ", "Room version number: ": "Room version number: ",
"Add a topic": "Add a topic", "Add a topic": "Add a topic",
"This room is using an unstable room version. If you aren't expecting this, please upgrade the room.": "This room is using an unstable room version. If you aren't expecting this, please upgrade the room.",
"Click here to upgrade to the latest room version.": "Click here to upgrade to the latest room version.",
"There is a known vulnerability affecting this room.": "There is a known vulnerability affecting this room.", "There is a known vulnerability affecting this room.": "There is a known vulnerability affecting this room.",
"This room version is vulnerable to malicious modification of room state.": "This room version is vulnerable to malicious modification of room state.", "This room version is vulnerable to malicious modification of room state.": "This room version is vulnerable to malicious modification of room state.",
"Click here to upgrade to the latest room version and ensure room integrity is protected.": "Click here to upgrade to the latest room version and ensure room integrity is protected.", "Click here to upgrade to the latest room version and ensure room integrity is protected.": "Click here to upgrade to the latest room version and ensure room integrity is protected.",