From 20a1693c7173f2ec486524e4109984d556c4199a Mon Sep 17 00:00:00 2001 From: Richard Lewis Date: Thu, 27 Jul 2017 23:38:02 +0100 Subject: [PATCH] Only display add app link if user has permission to add widgets in the room. --- src/components/views/rooms/AppsDrawer.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/AppsDrawer.js b/src/components/views/rooms/AppsDrawer.js index f1c881ec85..5427d4ec6d 100644 --- a/src/components/views/rooms/AppsDrawer.js +++ b/src/components/views/rooms/AppsDrawer.js @@ -26,6 +26,7 @@ import SdkConfig from '../../../SdkConfig'; import ScalarAuthClient from '../../../ScalarAuthClient'; import ScalarMessaging from '../../../ScalarMessaging'; import { _t } from '../../../languageHandler'; +import WidgetUtils from '../../../WidgetUtils'; module.exports = React.createClass({ @@ -147,6 +148,15 @@ module.exports = React.createClass({ }); }, + _canUserModify: function() { + try { + return WidgetUtils.canUserModifyWidgets(this.props.room.roomId); + } catch(err) { + console.error(err); + return false; + } + }, + onClickAddWidget: function(e) { if (e) { e.preventDefault(); @@ -176,7 +186,7 @@ module.exports = React.createClass({ />); }); - const addWidget = this.state.apps && this.state.apps.length < 2 && + const addWidget = this.state.apps && this.state.apps.length < 2 && this._canUserModify() && (