Merge pull request #2777 from matrix-org/jaywink/ensure-scalar-token
Ensure scalar_token is valid before opening integrations manager
This commit is contained in:
commit
bc0806581c
5 changed files with 46 additions and 21 deletions
|
@ -51,6 +51,11 @@ export default class IntegrationManager {
|
||||||
*/
|
*/
|
||||||
static async open(integName, integId, onFinished) {
|
static async open(integName, integId, onFinished) {
|
||||||
await IntegrationManager._init();
|
await IntegrationManager._init();
|
||||||
|
if (global.mxIntegrationManager.client) {
|
||||||
|
await global.mxIntegrationManager.client.connect();
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
|
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
|
||||||
if (global.mxIntegrationManager.error ||
|
if (global.mxIntegrationManager.error ||
|
||||||
!(global.mxIntegrationManager.client && global.mxIntegrationManager.client.hasCredentials())) {
|
!(global.mxIntegrationManager.client && global.mxIntegrationManager.client.hasCredentials())) {
|
||||||
|
|
|
@ -241,11 +241,18 @@ export default class AppTile extends React.Component {
|
||||||
this.props.onEditClick();
|
this.props.onEditClick();
|
||||||
} else {
|
} else {
|
||||||
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
|
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
|
||||||
|
this._scalarClient.connect().done(() => {
|
||||||
const src = this._scalarClient.getScalarInterfaceUrlForRoom(
|
const src = this._scalarClient.getScalarInterfaceUrlForRoom(
|
||||||
this.props.room, 'type_' + this.props.type, this.props.id);
|
this.props.room, 'type_' + this.props.type, this.props.id);
|
||||||
Modal.createTrackedDialog('Integrations Manager', '', IntegrationsManager, {
|
Modal.createTrackedDialog('Integrations Manager', '', IntegrationsManager, {
|
||||||
src: src,
|
src: src,
|
||||||
}, "mx_IntegrationsManager");
|
}, "mx_IntegrationsManager");
|
||||||
|
}, (err) => {
|
||||||
|
this.setState({
|
||||||
|
error: err.message,
|
||||||
|
});
|
||||||
|
console.error('Error ensuring a valid scalar_token exists', err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,11 +61,16 @@ export default class ManageIntegsButton extends React.Component {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
|
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
|
||||||
|
this.scalarClient.connect().done(() => {
|
||||||
Modal.createDialog(IntegrationsManager, {
|
Modal.createDialog(IntegrationsManager, {
|
||||||
src: (this.scalarClient !== null && this.scalarClient.hasCredentials()) ?
|
src: (this.scalarClient !== null && this.scalarClient.hasCredentials()) ?
|
||||||
this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room) :
|
this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room) :
|
||||||
null,
|
null,
|
||||||
}, "mx_IntegrationsManager");
|
}, "mx_IntegrationsManager");
|
||||||
|
}, (err) => {
|
||||||
|
this.setState({scalarError: err});
|
||||||
|
console.error('Error ensuring a valid scalar_token exists', err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -144,12 +144,16 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
_launchManageIntegrations: function() {
|
_launchManageIntegrations: function() {
|
||||||
const IntegrationsManager = sdk.getComponent('views.settings.IntegrationsManager');
|
const IntegrationsManager = sdk.getComponent('views.settings.IntegrationsManager');
|
||||||
|
this._scalarClient.connect().done(() => {
|
||||||
const src = (this.scalarClient !== null && this.scalarClient.hasCredentials()) ?
|
const src = (this.scalarClient !== null && this.scalarClient.hasCredentials()) ?
|
||||||
this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room, 'add_integ') :
|
this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room, 'add_integ') :
|
||||||
null;
|
null;
|
||||||
Modal.createTrackedDialog('Integrations Manager', '', IntegrationsManager, {
|
Modal.createTrackedDialog('Integrations Manager', '', IntegrationsManager, {
|
||||||
src: src,
|
src: src,
|
||||||
}, 'mx_IntegrationsManager');
|
}, 'mx_IntegrationsManager');
|
||||||
|
}, (err) => {
|
||||||
|
console.error('Error ensuring a valid scalar_token exists', err);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onClickAddWidget: function(e) {
|
onClickAddWidget: function(e) {
|
||||||
|
|
|
@ -310,6 +310,7 @@ export default class Stickerpicker extends React.Component {
|
||||||
*/
|
*/
|
||||||
_launchManageIntegrations() {
|
_launchManageIntegrations() {
|
||||||
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
|
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
|
||||||
|
this.scalarClient.connect().done(() => {
|
||||||
const src = (this.scalarClient !== null && this.scalarClient.hasCredentials()) ?
|
const src = (this.scalarClient !== null && this.scalarClient.hasCredentials()) ?
|
||||||
this.scalarClient.getScalarInterfaceUrlForRoom(
|
this.scalarClient.getScalarInterfaceUrlForRoom(
|
||||||
this.props.room,
|
this.props.room,
|
||||||
|
@ -320,8 +321,11 @@ export default class Stickerpicker extends React.Component {
|
||||||
Modal.createTrackedDialog('Integrations Manager', '', IntegrationsManager, {
|
Modal.createTrackedDialog('Integrations Manager', '', IntegrationsManager, {
|
||||||
src: src,
|
src: src,
|
||||||
}, "mx_IntegrationsManager");
|
}, "mx_IntegrationsManager");
|
||||||
|
|
||||||
this.setState({showStickers: false});
|
this.setState({showStickers: false});
|
||||||
|
}, (err) => {
|
||||||
|
this.setState({imError: err});
|
||||||
|
console.error('Error ensuring a valid scalar_token exists', err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
Loading…
Reference in a new issue