From 11efb1ede459a0ec9d5535bbc4d79392e338659e Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Thu, 26 Nov 2015 17:49:39 +0000 Subject: [PATCH] Move and merge MemberInfo --- .../views/rooms}/MemberInfo.js | 86 +++++++++++++++++-- 1 file changed, 79 insertions(+), 7 deletions(-) rename src/{controllers/molecules => components/views/rooms}/MemberInfo.js (78%) diff --git a/src/controllers/molecules/MemberInfo.js b/src/components/views/rooms/MemberInfo.js similarity index 78% rename from src/controllers/molecules/MemberInfo.js rename to src/components/views/rooms/MemberInfo.js index 913e36a4ce..02dea43aa7 100644 --- a/src/controllers/molecules/MemberInfo.js +++ b/src/components/views/rooms/MemberInfo.js @@ -25,13 +25,15 @@ limitations under the License. * 'muted': boolean, * 'isTargetMod': boolean */ +var React = require('react'); +var MatrixClientPeg = require("../../../MatrixClientPeg"); +var dis = require("../../../dispatcher"); +var Modal = require("../../../Modal"); +var sdk = require('../../../index'); -var MatrixClientPeg = require("../../MatrixClientPeg"); -var dis = require("../../dispatcher"); -var Modal = require("../../Modal"); -var sdk = require('../../index'); +module.exports = React.createClass({ + displayName: 'MemberInfo', -module.exports = { componentDidMount: function() { // work out the current state if (this.props.member) { @@ -320,6 +322,76 @@ module.exports = { powerLevelContent.events_default ); return member.powerLevel < levelToSend; - } -}; + }, + + onCancel: function(e) { + dis.dispatch({ + action: "view_user", + member: null + }); + }, + + render: function() { + var interactButton, kickButton, banButton, muteButton, giveModButton, spinner; + if (this.props.member.userId === MatrixClientPeg.get().credentials.userId) { + interactButton =
Leave room
; + } + else { + interactButton =
Start chat
; + } + + if (this.state.creatingRoom) { + var Loader = sdk.getComponent("elements.Spinner"); + spinner = ; + } + + if (this.state.can.kick) { + kickButton =
+ Kick +
; + } + if (this.state.can.ban) { + banButton =
+ Ban +
; + } + if (this.state.can.mute) { + var muteLabel = this.state.muted ? "Unmute" : "Mute"; + muteButton =
+ {muteLabel} +
; + } + if (this.state.can.modifyLevel) { + var giveOpLabel = this.state.isTargetMod ? "Revoke Mod" : "Make Mod"; + giveModButton =
+ {giveOpLabel} +
+ } + + var MemberAvatar = sdk.getComponent('avatars.MemberAvatar'); + return ( +
+ +
+ +
+

{ this.props.member.name }

+
+ { this.props.member.userId } +
+
+ power: { this.props.member.powerLevelNorm }% +
+
+ {interactButton} + {muteButton} + {kickButton} + {banButton} + {giveModButton} + {spinner} +
+
+ ); + } +});