Merge pull request #1556 from matrix-org/luke/groups-disinvite

Alter UI for disinviting a group member
This commit is contained in:
David Baker 2017-10-30 18:23:11 +00:00 committed by GitHub
commit deebd4cbcf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -37,6 +37,7 @@ module.exports = React.createClass({
propTypes: { propTypes: {
groupId: PropTypes.string, groupId: PropTypes.string,
groupMember: GroupMemberType, groupMember: GroupMemberType,
isInvited: PropTypes.bool,
}, },
getInitialState: function() { getInitialState: function() {
@ -72,6 +73,9 @@ module.exports = React.createClass({
onGroupStoreUpdated: function() { onGroupStoreUpdated: function() {
this.setState({ this.setState({
isUserInvited: this._groupStore.getGroupInvitedMembers().some(
(m) => m.userId === this.props.groupMember.userId,
),
isUserPrivilegedInGroup: this._groupStore.isUserPrivileged(), isUserPrivilegedInGroup: this._groupStore.isUserPrivileged(),
}); });
}, },
@ -80,7 +84,7 @@ module.exports = React.createClass({
const ConfirmUserActionDialog = sdk.getComponent("dialogs.ConfirmUserActionDialog"); const ConfirmUserActionDialog = sdk.getComponent("dialogs.ConfirmUserActionDialog");
Modal.createDialog(ConfirmUserActionDialog, { Modal.createDialog(ConfirmUserActionDialog, {
groupMember: this.props.groupMember, groupMember: this.props.groupMember,
action: _t('Remove from community'), action: this.state.isUserInvited ? _t('Disinvite') : _t('Remove from community'),
danger: true, danger: true,
onFinished: (proceed) => { onFinished: (proceed) => {
if (!proceed) return; if (!proceed) return;
@ -98,7 +102,9 @@ module.exports = React.createClass({
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
Modal.createTrackedDialog('Failed to remove user from group', '', ErrorDialog, { Modal.createTrackedDialog('Failed to remove user from group', '', ErrorDialog, {
title: _t('Error'), title: _t('Error'),
description: _t('Failed to remove user from community'), description: this.state.isUserInvited ?
_t('Failed to withdraw invitation') :
_t('Failed to remove user from community'),
}); });
}).finally(() => { }).finally(() => {
this.setState({removingUser: false}); this.setState({removingUser: false});
@ -133,7 +139,7 @@ module.exports = React.createClass({
const kickButton = ( const kickButton = (
<AccessibleButton className="mx_MemberInfo_field" <AccessibleButton className="mx_MemberInfo_field"
onClick={this._onKick}> onClick={this._onKick}>
{ _t('Remove from community') } { this.state.isUserInvited ? _t('Disinvite') : _t('Remove from community') }
</AccessibleButton> </AccessibleButton>
); );