Disable Scalar Integrations if urls passed to it are falsey

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-04-21 19:46:19 +01:00
parent b0288ebd89
commit 8e9f52e217

View file

@ -129,14 +129,17 @@ module.exports = React.createClass({
console.error("Failed to get room visibility: " + err); console.error("Failed to get room visibility: " + err);
}); });
this.scalarClient = new ScalarAuthClient(); this.scalarClient = null;
this.scalarClient.connect().done(() => { if (SdkConfig.get().integrations_ui_url && SdkConfig.get().integrations_rest_url) {
this.forceUpdate(); this.scalarClient = new ScalarAuthClient();
}, (err) => { this.scalarClient.connect().done(() => {
this.setState({ this.forceUpdate();
scalar_error: err }, (err) => {
this.setState({
scalar_error: err
});
}); });
}); }
dis.dispatch({ dis.dispatch({
action: 'ui_opacity', action: 'ui_opacity',
@ -490,7 +493,7 @@ module.exports = React.createClass({
ev.preventDefault(); ev.preventDefault();
var IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager"); var IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
Modal.createDialog(IntegrationsManager, { Modal.createDialog(IntegrationsManager, {
src: this.scalarClient.hasCredentials() ? src: (this.scalarClient !== null && this.scalarClient.hasCredentials()) ?
this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) : this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) :
null, null,
onFinished: ()=>{ onFinished: ()=>{
@ -765,36 +768,39 @@ module.exports = React.createClass({
</div>; </div>;
} }
var integrationsButton; let integrationsButton;
var integrationsError; let integrationsError;
if (this.state.showIntegrationsError && this.state.scalar_error) {
console.error(this.state.scalar_error);
integrationsError = (
<span className="mx_RoomSettings_integrationsButton_errorPopup">
Could not connect to the integration server
</span>
);
}
if (this.scalarClient.hasCredentials()) { if (this.scalarClient !== null) {
integrationsButton = ( if (this.state.showIntegrationsError && this.state.scalar_error) {
console.error(this.state.scalar_error);
integrationsError = (
<span className="mx_RoomSettings_integrationsButton_errorPopup">
Could not connect to the integration server
</span>
);
}
if (this.scalarClient.hasCredentials()) {
integrationsButton = (
<div className="mx_RoomSettings_integrationsButton" onClick={ this.onManageIntegrations }> <div className="mx_RoomSettings_integrationsButton" onClick={ this.onManageIntegrations }>
Manage Integrations Manage Integrations
</div> </div>
); );
} else if (this.state.scalar_error) { } else if (this.state.scalar_error) {
integrationsButton = ( integrationsButton = (
<div className="mx_RoomSettings_integrationsButton_error" onClick={ this.onShowIntegrationsError }> <div className="mx_RoomSettings_integrationsButton_error" onClick={ this.onShowIntegrationsError }>
Integrations Error <img src="img/warning.svg" width="17"/> Integrations Error <img src="img/warning.svg" width="17"/>
{ integrationsError } { integrationsError }
</div> </div>
); );
} else { } else {
integrationsButton = ( integrationsButton = (
<div className="mx_RoomSettings_integrationsButton" style={{ opacity: 0.5 }}> <div className="mx_RoomSettings_integrationsButton" style={{opacity: 0.5}}>
Manage Integrations Manage Integrations
</div> </div>
); );
}
} }
return ( return (