fix up and factor out mayChangeRoomAccess and fix review feedback
parent
df905cfcb7
commit
5a2a2c5bdc
|
@ -56,7 +56,7 @@ module.exports = React.createClass({
|
||||||
tags_changed: false,
|
tags_changed: false,
|
||||||
tags: tags,
|
tags: tags,
|
||||||
areNotifsMuted: areNotifsMuted,
|
areNotifsMuted: areNotifsMuted,
|
||||||
isRoomPublished: false, // updated in componentWillMount
|
// isRoomPublished: // set in componentWillMount
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -284,6 +284,11 @@ module.exports = React.createClass({
|
||||||
case "invite_only":
|
case "invite_only":
|
||||||
this.setState({
|
this.setState({
|
||||||
join_rule: "invite",
|
join_rule: "invite",
|
||||||
|
// we always set guests can_join here as it makes no sense to have
|
||||||
|
// an invite-only room that guests can't join. If you explicitly
|
||||||
|
// invite them, you clearly want them to join, whether they're a
|
||||||
|
// guest or not. In practice, guest_access should probably have
|
||||||
|
// been implemented as part of the join_rules enum.
|
||||||
guest_access: "can_join",
|
guest_access: "can_join",
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -330,6 +335,13 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
mayChangeRoomAccess: function() {
|
||||||
|
var cli = MatrixClientPeg.get();
|
||||||
|
var roomState = this.props.room.currentState;
|
||||||
|
return (roomState.mayClientSendStateEvent("m.room.join_rules", cli) &&
|
||||||
|
roomState.mayClientSendStateEvent("m.room.guest_access", cli))
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
// TODO: go through greying out things you don't have permission to change
|
// TODO: go through greying out things you don't have permission to change
|
||||||
// (or turning them into informative stuff)
|
// (or turning them into informative stuff)
|
||||||
|
@ -519,23 +531,21 @@ module.exports = React.createClass({
|
||||||
{ inviteGuestWarning }
|
{ inviteGuestWarning }
|
||||||
<label>
|
<label>
|
||||||
<input type="radio" name="roomVis" value="invite_only"
|
<input type="radio" name="roomVis" value="invite_only"
|
||||||
disabled={ !roomState.mayClientSendStateEvent("m.room.join_rules", cli) }
|
disabled={ !this.mayChangeRoomAccess() }
|
||||||
onChange={this._onRoomAccessRadioToggle}
|
onChange={this._onRoomAccessRadioToggle}
|
||||||
checked={this.state.join_rule !== "public"}/>
|
checked={this.state.join_rule !== "public"}/>
|
||||||
Only people who have been invited
|
Only people who have been invited
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<input type="radio" name="roomVis" value="public_no_guests"
|
<input type="radio" name="roomVis" value="public_no_guests"
|
||||||
disabled={ !(roomState.mayClientSendStateEvent("m.room.join_rules", cli) &&
|
disabled={ !this.mayChangeRoomAccess() }
|
||||||
roomState.mayClientSendStateEvent("m.room.guest_access", cli)) }
|
|
||||||
onChange={this._onRoomAccessRadioToggle}
|
onChange={this._onRoomAccessRadioToggle}
|
||||||
checked={this.state.join_rule === "public" && this.state.guest_access !== "can_join"}/>
|
checked={this.state.join_rule === "public" && this.state.guest_access !== "can_join"}/>
|
||||||
Anyone who knows the room's link, apart from guests
|
Anyone who knows the room's link, apart from guests
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<input type="radio" name="roomVis" value="public_with_guests"
|
<input type="radio" name="roomVis" value="public_with_guests"
|
||||||
disabled={ !(roomState.mayClientSendStateEvent("m.room.join_rules", cli) &&
|
disabled={ !this.mayChangeRoomAccess() }
|
||||||
roomState.mayClientSendStateEvent("m.room.guest_access", cli)) }
|
|
||||||
onChange={this._onRoomAccessRadioToggle}
|
onChange={this._onRoomAccessRadioToggle}
|
||||||
checked={this.state.join_rule === "public" && this.state.guest_access === "can_join"}/>
|
checked={this.state.join_rule === "public" && this.state.guest_access === "can_join"}/>
|
||||||
Anyone who knows the room's link, including guests
|
Anyone who knows the room's link, including guests
|
||||||
|
|
Loading…
Reference in New Issue