Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 6597e0b

Browse files
authored
Merge pull request #3646 from matrix-org/travis/integration-manager-opt
Add an option to disable the use of integration managers for provisioning
2 parents 86783e4 + 670c14b commit 6597e0b

15 files changed

+215
-228
lines changed

res/css/_components.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
@import "./views/rooms/_WhoIsTypingTile.scss";
174174
@import "./views/settings/_DevicesPanel.scss";
175175
@import "./views/settings/_EmailAddresses.scss";
176-
@import "./views/settings/_IntegrationsManager.scss";
176+
@import "./views/settings/_IntegrationManager.scss";
177177
@import "./views/settings/_KeyBackupPanel.scss";
178178
@import "./views/settings/_Notifications.scss";
179179
@import "./views/settings/_PhoneNumbers.scss";

res/css/views/dialogs/_TermsDialog.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ limitations under the License.
1616

1717
/*
1818
* To avoid visual glitching of two modals stacking briefly, we customise the
19-
* terms dialog sizing when it will appear for the integrations manager so that
19+
* terms dialog sizing when it will appear for the integration manager so that
2020
* it gets the same basic size as the IM's own modal.
2121
*/
22-
.mx_TermsDialog_forIntegrationsManager .mx_Dialog {
22+
.mx_TermsDialog_forIntegrationManager .mx_Dialog {
2323
width: 60%;
2424
height: 70%;
2525
box-sizing: border-box;

res/css/views/settings/_IntegrationsManager.scss renamed to res/css/views/settings/_IntegrationManager.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
.mx_IntegrationsManager .mx_Dialog {
17+
.mx_IntegrationManager .mx_Dialog {
1818
width: 60%;
1919
height: 70%;
2020
overflow: hidden;
@@ -23,22 +23,22 @@ limitations under the License.
2323
max-height: initial;
2424
}
2525

26-
.mx_IntegrationsManager iframe {
26+
.mx_IntegrationManager iframe {
2727
background-color: #fff;
2828
border: 0px;
2929
width: 100%;
3030
height: 100%;
3131
}
3232

33-
.mx_IntegrationsManager_loading h3 {
33+
.mx_IntegrationManager_loading h3 {
3434
text-align: center;
3535
}
3636

37-
.mx_IntegrationsManager_error {
37+
.mx_IntegrationManager_error {
3838
text-align: center;
3939
padding-top: 20px;
4040
}
4141

42-
.mx_IntegrationsManager_error h3 {
42+
.mx_IntegrationManager_error h3 {
4343
color: $warning-color;
4444
}

res/css/views/settings/_SetIntegrationManager.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
.mx_SetIntegrationManager .mx_Field_input {
18-
@mixin mx_Settings_fullWidthField;
19-
}
20-
2117
.mx_SetIntegrationManager {
2218
margin-top: 10px;
2319
margin-bottom: 10px;
@@ -32,6 +28,10 @@ limitations under the License.
3228
padding-left: 5px;
3329
}
3430

35-
.mx_SetIntegrationManager_tooltip {
36-
@mixin mx_Settings_tooltip;
31+
.mx_SetIntegrationManager .mx_ToggleSwitch {
32+
display: inline-block;
33+
float: right;
34+
top: 9px;
35+
36+
@mixin mx_Settings_fullWidthField;
3737
}

src/CallHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ function _onAction(payload) {
382382
}
383383

384384
async function _startCallApp(roomId, type) {
385-
// check for a working integrations manager. Technically we could put
385+
// check for a working integration manager. Technically we could put
386386
// the state event in anyway, but the resulting widget would then not
387387
// work for us. Better that the user knows before everyone else in the
388388
// room sees it.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
Copyright 2019 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import React from 'react';
18+
import PropTypes from 'prop-types';
19+
import {_t} from "../../../languageHandler";
20+
import sdk from "../../../index";
21+
import dis from '../../../dispatcher';
22+
23+
export default class IntegrationsDisabledDialog extends React.Component {
24+
static propTypes = {
25+
onFinished: PropTypes.func.isRequired,
26+
};
27+
28+
_onAcknowledgeClick = () => {
29+
this.props.onFinished();
30+
};
31+
32+
_onOpenSettingsClick = () => {
33+
this.props.onFinished();
34+
dis.dispatch({action: "view_user_settings"});
35+
};
36+
37+
render() {
38+
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
39+
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
40+
41+
return (
42+
<BaseDialog className='mx_IntegrationsDisabledDialog' hasCancel={true}
43+
onFinished={this.props.onFinished}
44+
title={_t("Integrations are disabled")}>
45+
<div className='mx_IntegrationsDisabledDialog_content'>
46+
<p>{_t("Enable 'Manage Integrations' in Settings to do this.")}</p>
47+
</div>
48+
<DialogButtons
49+
primaryButton={_t("Settings")}
50+
onPrimaryButtonClick={this._onOpenSettingsClick}
51+
cancelButton={_t("OK")}
52+
onCancel={this._onAcknowledgeClick}
53+
/>
54+
</BaseDialog>
55+
);
56+
}
57+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
Copyright 2019 The Matrix.org Foundation C.I.C.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
import React from 'react';
18+
import PropTypes from 'prop-types';
19+
import {_t} from "../../../languageHandler";
20+
import sdk from "../../../index";
21+
22+
export default class IntegrationsImpossibleDialog extends React.Component {
23+
static propTypes = {
24+
onFinished: PropTypes.func.isRequired,
25+
};
26+
27+
_onAcknowledgeClick = () => {
28+
this.props.onFinished();
29+
};
30+
31+
render() {
32+
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
33+
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
34+
35+
return (
36+
<BaseDialog className='mx_IntegrationsImpossibleDialog' hasCancel={false}
37+
onFinished={this.props.onFinished}
38+
title={_t("Integrations not allowed")}>
39+
<div className='mx_IntegrationsImpossibleDialog_content'>
40+
<p>
41+
{_t(
42+
"Your Riot doesn't allow you to use an Integration Manager to do this. " +
43+
"Please contact an admin.",
44+
)}
45+
</p>
46+
</div>
47+
<DialogButtons
48+
primaryButton={_t("OK")}
49+
onPrimaryButtonClick={this._onAcknowledgeClick}
50+
hasCancel={false}
51+
/>
52+
</BaseDialog>
53+
);
54+
}
55+
}

src/components/views/dialogs/TabbedIntegrationManagerDialog.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ export default class TabbedIntegrationManagerDialog extends React.Component {
8282

8383
client.setTermsInteractionCallback((policyInfo, agreedUrls) => {
8484
// To avoid visual glitching of two modals stacking briefly, we customise the
85-
// terms dialog sizing when it will appear for the integrations manager so that
85+
// terms dialog sizing when it will appear for the integration manager so that
8686
// it gets the same basic size as the IM's own modal.
8787
return dialogTermsInteractionCallback(
88-
policyInfo, agreedUrls, 'mx_TermsDialog_forIntegrationsManager',
88+
policyInfo, agreedUrls, 'mx_TermsDialog_forIntegrationManager',
8989
);
9090
});
9191

@@ -139,7 +139,7 @@ export default class TabbedIntegrationManagerDialog extends React.Component {
139139
}
140140

141141
_renderTab() {
142-
const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager");
142+
const IntegrationManager = sdk.getComponent("views.settings.IntegrationManager");
143143
let uiUrl = null;
144144
if (this.state.currentScalarClient) {
145145
uiUrl = this.state.currentScalarClient.getScalarInterfaceUrlForRoom(
@@ -148,7 +148,7 @@ export default class TabbedIntegrationManagerDialog extends React.Component {
148148
this.props.integrationId,
149149
);
150150
}
151-
return <IntegrationsManager
151+
return <IntegrationManager
152152
configured={true}
153153
loading={this.state.currentLoading}
154154
connected={this.state.currentConnected}

src/components/views/dialogs/TermsDialog.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export default class TermsDialog extends React.PureComponent {
8686
case Matrix.SERVICE_TYPES.IS:
8787
return <div>{_t("Identity Server")}<br />({host})</div>;
8888
case Matrix.SERVICE_TYPES.IM:
89-
return <div>{_t("Integrations Manager")}<br />({host})</div>;
89+
return <div>{_t("Integration Manager")}<br />({host})</div>;
9090
}
9191
}
9292

src/components/views/rooms/Stickerpicker.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ export default class Stickerpicker extends React.Component {
7474
this.forceUpdate();
7575
return this.scalarClient;
7676
}).catch((e) => {
77-
this._imError(_td("Failed to connect to integrations server"), e);
77+
this._imError(_td("Failed to connect to integration manager"), e);
7878
});
7979
} else {
80-
this._imError(_td("No integrations server is configured to manage stickers with"));
80+
IntegrationManagers.sharedInstance().openNoManagerDialog();
8181
}
8282
}
8383

@@ -287,12 +287,17 @@ export default class Stickerpicker extends React.Component {
287287
return stickersContent;
288288
}
289289

290-
/**
290+
// Dev note: this isn't jsdoc because it's angry.
291+
/*
291292
* Show the sticker picker overlay
292293
* If no stickerpacks have been added, show a link to the integration manager add sticker packs page.
293-
* @param {Event} e Event that triggered the function
294294
*/
295295
_onShowStickersClick(e) {
296+
if (!SettingsStore.getValue("integrationProvisioning")) {
297+
// Intercept this case and spawn a warning.
298+
return IntegrationManagers.sharedInstance().showDisabledDialog();
299+
}
300+
296301
// XXX: Simplify by using a context menu that is positioned relative to the sticker picker button
297302

298303
const buttonRect = e.target.getBoundingClientRect();
@@ -346,7 +351,7 @@ export default class Stickerpicker extends React.Component {
346351
}
347352

348353
/**
349-
* Launch the integrations manager on the stickers integration page
354+
* Launch the integration manager on the stickers integration page
350355
*/
351356
_launchManageIntegrations() {
352357
// TODO: Open the right integration manager for the widget

0 commit comments

Comments
 (0)