From 1973b2bbe78ced0c53d2c1975683f74603a3020e Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sat, 5 Aug 2017 00:00:19 +0100 Subject: [PATCH 01/17] Switch app drawer icons --- src/components/views/rooms/MessageComposer.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index 14f52706ec..7c8723e197 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -289,12 +289,12 @@ export default class MessageComposer extends React.Component { if (this.props.showApps) { hideAppsButton =
- +
; } else { showAppsButton =
- +
; } } From a22e76834336a823a739e4f69c7f2a47a8abd1f6 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sun, 6 Aug 2017 10:01:48 +0100 Subject: [PATCH 02/17] Move room settings button to RoomHeader --- src/components/views/rooms/RoomHeader.js | 83 ++++++++++++++++++++++ src/components/views/rooms/RoomSettings.js | 78 -------------------- 2 files changed, 83 insertions(+), 78 deletions(-) diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 85aedadf64..d4e390f750 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -30,6 +30,9 @@ import linkifyElement from 'linkifyjs/element'; import linkifyMatrix from '../../../linkify-matrix'; import AccessibleButton from '../elements/AccessibleButton'; import {CancelButton} from './SimpleRoomHeader'; +import SdkConfig from '../../../SdkConfig'; +import ScalarAuthClient from '../../../ScalarAuthClient'; +import ScalarMessaging from '../../../ScalarMessaging'; linkifyMatrix(linkify); @@ -57,6 +60,13 @@ module.exports = React.createClass({ }; }, + getInitialState: function() { + return { + scalar_error: null, + showIntegrationsError: false, + }; + }, + componentDidMount: function() { const cli = MatrixClientPeg.get(); cli.on("RoomState.events", this._onRoomStateEvents); @@ -75,7 +85,23 @@ module.exports = React.createClass({ } }, + componentWillMount: function() { + ScalarMessaging.startListening(); + this.scalarClient = null; + if (SdkConfig.get().integrations_ui_url && SdkConfig.get().integrations_rest_url) { + this.scalarClient = new ScalarAuthClient(); + this.scalarClient.connect().done(() => { + this.forceUpdate(); + }, (err) => { + this.setState({ + scalar_error: err, + }); + }); + } + }, + componentWillUnmount: function() { + ScalarMessaging.stopListening(); if (this.props.room) { this.props.room.removeListener("Room.name", this._onRoomNameChange); } @@ -85,6 +111,28 @@ module.exports = React.createClass({ } }, + onManageIntegrations(ev) { + ev.preventDefault(); + const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager"); + Modal.createDialog(IntegrationsManager, { + src: (this.scalarClient !== null && this.scalarClient.hasCredentials()) ? + this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) : + null, + onFinished: ()=>{ + if (this._calcSavePromises().length === 0) { + this.props.onCancelClick(ev); + } + }, + }, "mx_IntegrationsManager"); + }, + + onShowIntegrationsError(ev) { + ev.preventDefault(); + this.setState({ + showIntegrationsError: !this.state.showIntegrationsError, + }); + }, + _onRoomStateEvents: function(event, state) { if (!this.props.room || event.getRoomId() !== this.props.room.roomId) { return; @@ -320,10 +368,45 @@ module.exports = React.createClass({ } let rightRow; + let integrationsButton; + let integrationsError; + if (this.scalarClient !== null) { + if (this.state.showIntegrationsError && this.state.scalar_error) { + console.error(this.state.scalar_error); + integrationsError = ( + + { _t('Could not connect to the integration server') } + + ); + } + + if (this.scalarClient.hasCredentials()) { + integrationsButton = ( + + + + ); + } else if (this.state.scalar_error) { + integrationsButton = ( +
+ + { integrationsError } +
+ ); + } else { + integrationsButton = ( + + + + ); + } + } + if (!this.props.editing) { rightRow =
{ settingsButton } + { integrationsButton } { forgetButton } { searchButton } { rightPanelButtons } diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index d6a973f648..1baaf3aaa9 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -24,8 +24,6 @@ import sdk from '../../../index'; import Modal from '../../../Modal'; import ObjectUtils from '../../../ObjectUtils'; import dis from '../../../dispatcher'; -import ScalarAuthClient from '../../../ScalarAuthClient'; -import ScalarMessaging from '../../../ScalarMessaging'; import UserSettingsStore from '../../../UserSettingsStore'; import AccessibleButton from '../elements/AccessibleButton'; @@ -118,14 +116,10 @@ module.exports = React.createClass({ // Default to false if it's undefined, otherwise react complains about changing // components from uncontrolled to controlled isRoomPublished: this._originalIsRoomPublished || false, - scalar_error: null, - showIntegrationsError: false, }; }, componentWillMount: function() { - ScalarMessaging.startListening(); - MatrixClientPeg.get().on("RoomMember.membership", this._onRoomMemberMembership); MatrixClientPeg.get().getRoomDirectoryVisibility( @@ -137,18 +131,6 @@ module.exports = React.createClass({ console.error("Failed to get room visibility: " + err); }); - this.scalarClient = null; - if (SdkConfig.get().integrations_ui_url && SdkConfig.get().integrations_rest_url) { - this.scalarClient = new ScalarAuthClient(); - this.scalarClient.connect().done(() => { - this.forceUpdate(); - }, (err) => { - this.setState({ - scalar_error: err - }); - }); - } - dis.dispatch({ action: 'ui_opacity', sideOpacity: 0.3, @@ -157,8 +139,6 @@ module.exports = React.createClass({ }, componentWillUnmount: function() { - ScalarMessaging.stopListening(); - const cli = MatrixClientPeg.get(); if (cli) { cli.removeListener("RoomMember.membership", this._onRoomMemberMembership); @@ -513,28 +493,6 @@ module.exports = React.createClass({ roomState.mayClientSendStateEvent("m.room.guest_access", cli)); }, - onManageIntegrations(ev) { - ev.preventDefault(); - var IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager"); - Modal.createDialog(IntegrationsManager, { - src: (this.scalarClient !== null && this.scalarClient.hasCredentials()) ? - this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) : - null, - onFinished: ()=>{ - if (this._calcSavePromises().length === 0) { - this.props.onCancelClick(ev); - } - }, - }, "mx_IntegrationsManager"); - }, - - onShowIntegrationsError(ev) { - ev.preventDefault(); - this.setState({ - showIntegrationsError: !this.state.showIntegrationsError, - }); - }, - onLeaveClick() { dis.dispatch({ action: 'leave_room', @@ -796,46 +754,10 @@ module.exports = React.createClass({
; } - let integrationsButton; - let integrationsError; - - if (this.scalarClient !== null) { - if (this.state.showIntegrationsError && this.state.scalar_error) { - console.error(this.state.scalar_error); - integrationsError = ( - - { _t('Could not connect to the integration server') } - - ); - } - - if (this.scalarClient.hasCredentials()) { - integrationsButton = ( -
- { _t('Manage Integrations') } -
- ); - } else if (this.state.scalar_error) { - integrationsButton = ( -
- Integrations Error - { integrationsError } -
- ); - } else { - integrationsButton = ( -
- { _t('Manage Integrations') } -
- ); - } - } - return (
{ leaveButton } - { integrationsButton } { tagsSection } From 308d932b2f02c6ed2120828af1f22e4401b4bd41 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sun, 6 Aug 2017 10:29:43 +0100 Subject: [PATCH 03/17] CancelClick prop. --- src/components/views/rooms/RoomHeader.js | 6 +++--- src/components/views/rooms/RoomSettings.js | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index d4e390f750..66b0eab3e7 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -50,6 +50,7 @@ module.exports = React.createClass({ onSaveClick: React.PropTypes.func, onSearchClick: React.PropTypes.func, onLeaveClick: React.PropTypes.func, + onCancelClick: React.PropTypes.func, }, getDefaultProps: function() { @@ -57,6 +58,7 @@ module.exports = React.createClass({ editing: false, inRoom: false, onSaveClick: function() {}, + onCancelClick: function() {}, }; }, @@ -119,9 +121,7 @@ module.exports = React.createClass({ this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) : null, onFinished: ()=>{ - if (this._calcSavePromises().length === 0) { - this.props.onCancelClick(ev); - } + this.props.onCancelClick(ev); }, }, "mx_IntegrationsManager"); }, diff --git a/src/components/views/rooms/RoomSettings.js b/src/components/views/rooms/RoomSettings.js index 1baaf3aaa9..0c1372f54e 100644 --- a/src/components/views/rooms/RoomSettings.js +++ b/src/components/views/rooms/RoomSettings.js @@ -90,7 +90,6 @@ module.exports = React.createClass({ propTypes: { room: React.PropTypes.object.isRequired, onSaveClick: React.PropTypes.func, - onCancelClick: React.PropTypes.func, }, getInitialState: function() { From 18ae5fd129ae49bfddeab4be050db73031c2fac7 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Sun, 6 Aug 2017 11:01:14 +0100 Subject: [PATCH 04/17] Send messages on widget addition and deletion --- src/ScalarMessaging.js | 6 ++++++ src/components/views/rooms/RoomHeader.js | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index d14d439d66..cb6e79f5e6 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -338,6 +338,12 @@ function setWidget(event, roomId) { sendResponse(event, { success: true, }); + + if (widgetUrl !== null) { + client.sendTextMessage(roomId, `Added ${widgetType} widget - ${widgetUrl}`); + } else { + client.sendTextMessage(roomId, `Removed ${widgetType} widget`); + } }, (err) => { sendError(event, _t('Failed to send request.'), err); }); diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 66b0eab3e7..f26aa29d31 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -121,7 +121,9 @@ module.exports = React.createClass({ this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) : null, onFinished: ()=>{ - this.props.onCancelClick(ev); + if (this.props.onCancelClick) { + this.props.onCancelClick(ev); + } }, }, "mx_IntegrationsManager"); }, From 9f8e8ae1fd58ccaf75505f5c0350e8b6585d87f9 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Tue, 8 Aug 2017 17:34:54 +0100 Subject: [PATCH 05/17] Split timeline updates in to different PR. --- src/ScalarMessaging.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/ScalarMessaging.js b/src/ScalarMessaging.js index cb6e79f5e6..d14d439d66 100644 --- a/src/ScalarMessaging.js +++ b/src/ScalarMessaging.js @@ -338,12 +338,6 @@ function setWidget(event, roomId) { sendResponse(event, { success: true, }); - - if (widgetUrl !== null) { - client.sendTextMessage(roomId, `Added ${widgetType} widget - ${widgetUrl}`); - } else { - client.sendTextMessage(roomId, `Removed ${widgetType} widget`); - } }, (err) => { sendError(event, _t('Failed to send request.'), err); }); From 4bc25f12cb792fccd79d1598346c5c9d57ba2d10 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Wed, 9 Aug 2017 11:44:24 +0100 Subject: [PATCH 06/17] Move manage integrations button in to stand-alone component --- .../views/elements/ManageIntegsButton.js | 127 ++++++++++++++++++ src/components/views/rooms/RoomHeader.js | 87 +----------- 2 files changed, 132 insertions(+), 82 deletions(-) create mode 100644 src/components/views/elements/ManageIntegsButton.js diff --git a/src/components/views/elements/ManageIntegsButton.js b/src/components/views/elements/ManageIntegsButton.js new file mode 100644 index 0000000000..8d4c9d8b85 --- /dev/null +++ b/src/components/views/elements/ManageIntegsButton.js @@ -0,0 +1,127 @@ +/* +Copyright 2017 Vector Creations Ltd + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +import React from 'react'; +import PropTypes from 'prop-types'; +import sdk from '../../../index'; +import SdkConfig from '../../../SdkConfig'; +import ScalarAuthClient from '../../../ScalarAuthClient'; +import ScalarMessaging from '../../../ScalarMessaging'; +import Modal from "../../../Modal"; +import { _t } from '../../../languageHandler'; +import AccessibleButton from './AccessibleButton'; +import TintableSvg from './TintableSvg'; + +export default class ManageIntegsButton extends React.Component { + constructor(props) { + super(props); + + this.state = { + scalar_error: null, + showIntegrationsError: false, + }; + + this.onManageIntegrations = this.onManageIntegrations.bind(this); + this.onShowIntegrationsError = this.onShowIntegrationsError.bind(this); + } + + componentWillMount() { + ScalarMessaging.startListening(); + this.scalarClient = null; + + if (SdkConfig.get().integrations_ui_url && SdkConfig.get().integrations_rest_url) { + this.scalarClient = new ScalarAuthClient(); + this.scalarClient.connect().done(() => { + this.forceUpdate(); + }, (err) => { + this.setState({ scalar_error: err}); + }); + } + } + + componentWillUnmount() { + ScalarMessaging.stopListening(); + } + + onManageIntegrations(ev) { + ev.preventDefault(); + const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager"); + Modal.createDialog(IntegrationsManager, { + src: (this.scalarClient !== null && this.scalarClient.hasCredentials()) ? + this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) : + null, + onFinished: ()=>{ + if (this.props.onCancelClick) { + this.props.onCancelClick(ev); + } + }, + }, "mx_IntegrationsManager"); + } + + onShowIntegrationsError(ev) { + ev.preventDefault(); + this.setState({ + showIntegrationsError: !this.state.showIntegrationsError, + }); + } + + render() { + let integrationsButton; + let integrationsError; + if (this.scalarClient !== null) { + if (this.state.showIntegrationsError && this.state.scalar_error) { + console.error(this.state.scalar_error); + integrationsError = ( + + { _t('Could not connect to the integration server') } + + ); + } + + if (this.scalarClient.hasCredentials()) { + integrationsButton = ( + + + + ); + } else if (this.state.scalar_error) { + integrationsButton = ( +
+ + { integrationsError } +
+ ); + } else { + integrationsButton = ( + + + + ); + } + } + + return integrationsButton; + } +} + +ManageIntegsButton.propTypes = { + room: PropTypes.object.isRequired, + onCancelClick: PropTypes.func, +}; + +ManageIntegsButton.defaultProps = { + onCancelClick: function() {}, +}; diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index f26aa29d31..ed354017b2 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -29,10 +29,8 @@ import * as linkify from 'linkifyjs'; import linkifyElement from 'linkifyjs/element'; import linkifyMatrix from '../../../linkify-matrix'; import AccessibleButton from '../elements/AccessibleButton'; +import ManageIntegsButton from '../elements/ManageIntegsButton'; import {CancelButton} from './SimpleRoomHeader'; -import SdkConfig from '../../../SdkConfig'; -import ScalarAuthClient from '../../../ScalarAuthClient'; -import ScalarMessaging from '../../../ScalarMessaging'; linkifyMatrix(linkify); @@ -62,13 +60,6 @@ module.exports = React.createClass({ }; }, - getInitialState: function() { - return { - scalar_error: null, - showIntegrationsError: false, - }; - }, - componentDidMount: function() { const cli = MatrixClientPeg.get(); cli.on("RoomState.events", this._onRoomStateEvents); @@ -87,23 +78,7 @@ module.exports = React.createClass({ } }, - componentWillMount: function() { - ScalarMessaging.startListening(); - this.scalarClient = null; - if (SdkConfig.get().integrations_ui_url && SdkConfig.get().integrations_rest_url) { - this.scalarClient = new ScalarAuthClient(); - this.scalarClient.connect().done(() => { - this.forceUpdate(); - }, (err) => { - this.setState({ - scalar_error: err, - }); - }); - } - }, - componentWillUnmount: function() { - ScalarMessaging.stopListening(); if (this.props.room) { this.props.room.removeListener("Room.name", this._onRoomNameChange); } @@ -113,28 +88,6 @@ module.exports = React.createClass({ } }, - onManageIntegrations(ev) { - ev.preventDefault(); - const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager"); - Modal.createDialog(IntegrationsManager, { - src: (this.scalarClient !== null && this.scalarClient.hasCredentials()) ? - this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) : - null, - onFinished: ()=>{ - if (this.props.onCancelClick) { - this.props.onCancelClick(ev); - } - }, - }, "mx_IntegrationsManager"); - }, - - onShowIntegrationsError(ev) { - ev.preventDefault(); - this.setState({ - showIntegrationsError: !this.state.showIntegrationsError, - }); - }, - _onRoomStateEvents: function(event, state) { if (!this.props.room || event.getRoomId() !== this.props.room.roomId) { return; @@ -370,45 +323,15 @@ module.exports = React.createClass({ } let rightRow; - let integrationsButton; - let integrationsError; - if (this.scalarClient !== null) { - if (this.state.showIntegrationsError && this.state.scalar_error) { - console.error(this.state.scalar_error); - integrationsError = ( - - { _t('Could not connect to the integration server') } - - ); - } - - if (this.scalarClient.hasCredentials()) { - integrationsButton = ( - - - - ); - } else if (this.state.scalar_error) { - integrationsButton = ( -
- - { integrationsError } -
- ); - } else { - integrationsButton = ( - - - - ); - } - } if (!this.props.editing) { rightRow =
{ settingsButton } - { integrationsButton } + { forgetButton } { searchButton } { rightPanelButtons } From 0323151bee584434be0dd7a699c1ffc465aa0c3a Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 10 Aug 2017 23:53:43 +0100 Subject: [PATCH 07/17] Show a dialog if the maximum number of widgets allowed has been reached. --- src/components/views/rooms/AppsDrawer.js | 33 +++++++++++++++++------- src/i18n/strings/en_EN.json | 2 ++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index 5427d4ec6d..9071a5bcab 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -28,6 +28,8 @@ import ScalarMessaging from '../../../ScalarMessaging'; import { _t } from '../../../languageHandler'; import WidgetUtils from '../../../WidgetUtils'; +// The maximum number of widgets that can be added in a room +const MAX_WIDGETS = 2; module.exports = React.createClass({ displayName: 'AppsDrawer', @@ -162,6 +164,18 @@ module.exports = React.createClass({ e.preventDefault(); } + // Display a warning dialog if the max number of widgets have already been added to the room + if (this.state.apps && this.state.apps.length >= MAX_WIDGETS) { + const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); + const errorMsg = `The maximum number of ${MAX_WIDGETS} widgets have already been added to this room.`; + console.error(errorMsg); + Modal.createDialog(ErrorDialog, { + title: _t("Cannot add any more widgets"), + description: _t("The maximum permitted number of widgets have already been added to this room."), + }); + return; + } + const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager"); const src = (this.scalarClient !== null && this.scalarClient.hasCredentials()) ? this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId, 'add_integ') : @@ -186,21 +200,22 @@ module.exports = React.createClass({ />); }); - const addWidget = this.state.apps && this.state.apps.length < 2 && this._canUserModify() && - (
- [+] {_t('Add a widget')} -
); + const addWidget = ( +
+ [+] {_t('Add a widget')} +
+ ); return (
{apps}
- {addWidget} + {this._canUserModify() && addWidget}
); }, diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 0d5b7d9d96..784ca54bb7 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -190,6 +190,7 @@ "Can't connect to homeserver - please check your connectivity, ensure your homeserver's SSL certificate is trusted, and that a browser extension is not blocking requests.": "Can't connect to homeserver - please check your connectivity, ensure your homeserver's SSL certificate is trusted, and that a browser extension is not blocking requests.", "Can't connect to homeserver via HTTP when an HTTPS URL is in your browser bar. Either use HTTPS or enable unsafe scripts.": "Can't connect to homeserver via HTTP when an HTTPS URL is in your browser bar. Either use HTTPS or enable unsafe scripts.", "Can't load user settings": "Can't load user settings", + "Cannot add any more widgets": "Cannot add any more widgets", "Change Password": "Change Password", "%(senderName)s changed their display name from %(oldDisplayName)s to %(displayName)s.": "%(senderName)s changed their display name from %(oldDisplayName)s to %(displayName)s.", "%(senderName)s changed their profile picture.": "%(senderName)s changed their profile picture.", @@ -546,6 +547,7 @@ "Tagged as: ": "Tagged as: ", "The default role for new room members is": "The default role for new room members is", "The main address for this room is": "The main address for this room is", + "The maximum permitted number of widgets have already been added to this room.": "The maximum permitted number of widgets have already been added to this room.", "The phone number entered looks invalid": "The phone number entered looks invalid", "The signing key you provided matches the signing key you received from %(userId)s's device %(deviceId)s. Device marked as verified.": "The signing key you provided matches the signing key you received from %(userId)s's device %(deviceId)s. Device marked as verified.", "This action cannot be performed by a guest user. Please register to be able to do this.": "This action cannot be performed by a guest user. Please register to be able to do this.", From 2c25639a616e761c43fe0039c68123a3de537ce3 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 17 Aug 2017 11:22:42 +0100 Subject: [PATCH 08/17] Fix copyright header --- src/components/views/elements/ManageIntegsButton.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/elements/ManageIntegsButton.js b/src/components/views/elements/ManageIntegsButton.js index 8d4c9d8b85..158efd579f 100644 --- a/src/components/views/elements/ManageIntegsButton.js +++ b/src/components/views/elements/ManageIntegsButton.js @@ -1,5 +1,5 @@ /* -Copyright 2017 Vector Creations Ltd +Copyright 2017 New Vector Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From eb77dcc8e3a9288a1e025cfc36431ae477f18e75 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 17 Aug 2017 11:24:25 +0100 Subject: [PATCH 09/17] Camel case variable name --- src/components/views/elements/ManageIntegsButton.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/views/elements/ManageIntegsButton.js b/src/components/views/elements/ManageIntegsButton.js index 158efd579f..8ff0631ce2 100644 --- a/src/components/views/elements/ManageIntegsButton.js +++ b/src/components/views/elements/ManageIntegsButton.js @@ -30,7 +30,7 @@ export default class ManageIntegsButton extends React.Component { super(props); this.state = { - scalar_error: null, + scalarError: null, showIntegrationsError: false, }; @@ -47,7 +47,7 @@ export default class ManageIntegsButton extends React.Component { this.scalarClient.connect().done(() => { this.forceUpdate(); }, (err) => { - this.setState({ scalar_error: err}); + this.setState({ scalarError: err}); }); } } @@ -82,8 +82,8 @@ export default class ManageIntegsButton extends React.Component { let integrationsButton; let integrationsError; if (this.scalarClient !== null) { - if (this.state.showIntegrationsError && this.state.scalar_error) { - console.error(this.state.scalar_error); + if (this.state.showIntegrationsError && this.state.scalarError) { + console.error(this.state.scalarError); integrationsError = ( { _t('Could not connect to the integration server') } @@ -97,7 +97,7 @@ export default class ManageIntegsButton extends React.Component { ); - } else if (this.state.scalar_error) { + } else if (this.state.scalarError) { integrationsButton = (
From d1ee257b5ad7adc9d9e75b2f71fb4697d68e9783 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 17 Aug 2017 12:15:01 +0100 Subject: [PATCH 10/17] Pass roomId rather than whole room object. --- src/components/views/elements/ManageIntegsButton.js | 4 ++-- src/components/views/rooms/RoomHeader.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/views/elements/ManageIntegsButton.js b/src/components/views/elements/ManageIntegsButton.js index 8ff0631ce2..3ceda73074 100644 --- a/src/components/views/elements/ManageIntegsButton.js +++ b/src/components/views/elements/ManageIntegsButton.js @@ -61,7 +61,7 @@ export default class ManageIntegsButton extends React.Component { const IntegrationsManager = sdk.getComponent("views.settings.IntegrationsManager"); Modal.createDialog(IntegrationsManager, { src: (this.scalarClient !== null && this.scalarClient.hasCredentials()) ? - this.scalarClient.getScalarInterfaceUrlForRoom(this.props.room.roomId) : + this.scalarClient.getScalarInterfaceUrlForRoom(this.props.roomId) : null, onFinished: ()=>{ if (this.props.onCancelClick) { @@ -118,7 +118,7 @@ export default class ManageIntegsButton extends React.Component { } ManageIntegsButton.propTypes = { - room: PropTypes.object.isRequired, + roomId: PropTypes.string.isRequired, onCancelClick: PropTypes.func, }; diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 319ce92f4f..64d971f878 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -330,7 +330,7 @@ module.exports = React.createClass({ { settingsButton } { forgetButton } { searchButton } From 02edadbd15994d02b14ced729bbfe6526c04067f Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 17 Aug 2017 12:21:44 +0100 Subject: [PATCH 11/17] Don't bubble cancel click to room header. --- src/components/views/rooms/RoomHeader.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 64d971f878..b202cefda3 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -329,7 +329,6 @@ module.exports = React.createClass({
{ settingsButton } { forgetButton } From 120a4f4f44480f7ded7b78ea0e993ca949abef35 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 17 Aug 2017 18:10:50 +0100 Subject: [PATCH 12/17] Check for valid roomId before renering manageIntegsButton. --- src/components/views/rooms/RoomHeader.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index b202cefda3..499fdf21cc 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -323,14 +323,18 @@ module.exports = React.createClass({ } let rightRow; + let manageIntegsButton; + if(this.props.room && this.props.room.roomId) { + manageIntegsButton = ; + } if (!this.props.editing) { rightRow =
{ settingsButton } - + { manageIntegsButton } { forgetButton } { searchButton } { rightPanelButtons } From 95d1c3746e4831752c02d8445ff9ba9ac2aaf4ec Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 17 Aug 2017 18:22:52 +0100 Subject: [PATCH 13/17] Kick travis From 96900e76a0637adb5b944eb47f24f67584614875 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Fri, 18 Aug 2017 11:51:32 +0100 Subject: [PATCH 14/17] Move error logging to where it is first caught. --- src/components/views/elements/ManageIntegsButton.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/elements/ManageIntegsButton.js b/src/components/views/elements/ManageIntegsButton.js index 3ceda73074..8def6379ec 100644 --- a/src/components/views/elements/ManageIntegsButton.js +++ b/src/components/views/elements/ManageIntegsButton.js @@ -48,6 +48,7 @@ export default class ManageIntegsButton extends React.Component { this.forceUpdate(); }, (err) => { this.setState({ scalarError: err}); + console.error(err); }); } } @@ -83,7 +84,6 @@ export default class ManageIntegsButton extends React.Component { let integrationsError; if (this.scalarClient !== null) { if (this.state.showIntegrationsError && this.state.scalarError) { - console.error(this.state.scalarError); integrationsError = ( { _t('Could not connect to the integration server') } From 84f5e5aad26c891c9495017deaf5a4a9a431fe85 Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Fri, 18 Aug 2017 12:21:48 +0100 Subject: [PATCH 15/17] REmove unused onCancelClick --- src/components/views/elements/ManageIntegsButton.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/components/views/elements/ManageIntegsButton.js b/src/components/views/elements/ManageIntegsButton.js index 8def6379ec..bb302dc37c 100644 --- a/src/components/views/elements/ManageIntegsButton.js +++ b/src/components/views/elements/ManageIntegsButton.js @@ -64,11 +64,6 @@ export default class ManageIntegsButton extends React.Component { src: (this.scalarClient !== null && this.scalarClient.hasCredentials()) ? this.scalarClient.getScalarInterfaceUrlForRoom(this.props.roomId) : null, - onFinished: ()=>{ - if (this.props.onCancelClick) { - this.props.onCancelClick(ev); - } - }, }, "mx_IntegrationsManager"); } @@ -119,9 +114,7 @@ export default class ManageIntegsButton extends React.Component { ManageIntegsButton.propTypes = { roomId: PropTypes.string.isRequired, - onCancelClick: PropTypes.func, }; ManageIntegsButton.defaultProps = { - onCancelClick: function() {}, }; From 857a8c95194457102d80b9ce9c4e947f8f12a03a Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Fri, 18 Aug 2017 13:28:47 +0100 Subject: [PATCH 16/17] Remove empty defaultProps. --- src/components/views/elements/ManageIntegsButton.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/components/views/elements/ManageIntegsButton.js b/src/components/views/elements/ManageIntegsButton.js index bb302dc37c..a5f6eb7982 100644 --- a/src/components/views/elements/ManageIntegsButton.js +++ b/src/components/views/elements/ManageIntegsButton.js @@ -115,6 +115,3 @@ export default class ManageIntegsButton extends React.Component { ManageIntegsButton.propTypes = { roomId: PropTypes.string.isRequired, }; - -ManageIntegsButton.defaultProps = { -}; From 1c36e4740317ab96cc4aeb8bff5d06f023f54a1d Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Fri, 18 Aug 2017 15:59:12 +0100 Subject: [PATCH 17/17] Fix add widget link --- src/components/views/rooms/AppsDrawer.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index 0099e8a9fc..3a3ec06c5c 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -220,8 +220,6 @@ module.exports = React.createClass({ let addWidget; if (this.props.showApps && - this.state.apps && - this.state.apps.length < 2 && this._canUserModify() ) { addWidget =