Show the error that occured when trying to reach scalar

Instead of removing the button and printing an error to console, show the error in a popup that appears next to the `Manage Integrations` button.
This commit is contained in:
Luke Barnard 2016-11-08 10:57:48 +00:00
parent 884ae0e218
commit c0c662aeaf

View file

@ -66,6 +66,7 @@ module.exports = React.createClass({
// components from uncontrolled to controlled // components from uncontrolled to controlled
isRoomPublished: this._originalIsRoomPublished || false, isRoomPublished: this._originalIsRoomPublished || false,
scalar_error: null, scalar_error: null,
showIntegrationsError: false,
}; };
}, },
@ -424,6 +425,13 @@ module.exports = React.createClass({
}, "mx_IntegrationsManager"); }, "mx_IntegrationsManager");
}, },
onShowIntegrationsError(ev) {
ev.preventDefault();
this.setState({
showIntegrationsError: !this.state.showIntegrationsError,
});
},
onLeaveClick() { onLeaveClick() {
dis.dispatch({ dis.dispatch({
action: 'leave_room', action: 'leave_room',
@ -668,6 +676,15 @@ module.exports = React.createClass({
} }
var integrationsButton; var integrationsButton;
var integrationsError;
if (this.state.showIntegrationsError && this.state.scalar_error) {
console.error(this.state.scalar_error);
integrationsError = (
<span className="mx_RoomSettings_integrationsButton_errorPopup">
{ this.state.scalar_error.message }
</span>
);
}
if (UserSettingsStore.isFeatureEnabled("integration_management")) { if (UserSettingsStore.isFeatureEnabled("integration_management")) {
if (this.scalarClient.hasCredentials()) { if (this.scalarClient.hasCredentials()) {
integrationsButton = ( integrationsButton = (
@ -676,7 +693,12 @@ module.exports = React.createClass({
</div> </div>
); );
} else if (this.state.scalar_error) { } else if (this.state.scalar_error) {
console.error("Unable to contact integrations server"); integrationsButton = (
<div className="mx_RoomSettings_integrationsButton_error" onClick={ this.onShowIntegrationsError }>
Integrations Error <img src="img/warning.svg" width="17"/>
{ integrationsError }
</div>
);
} else { } else {
integrationsButton = ( integrationsButton = (
<div className="mx_RoomSettings_integrationsButton" style={{ opacity: 0.5 }}> <div className="mx_RoomSettings_integrationsButton" style={{ opacity: 0.5 }}>