Merge pull request #217 from matrix-org/matthew/disable-room-settings
grey out roomsettings that you can't edit
This commit is contained in:
commit
81674684bb
1 changed files with 18 additions and 19 deletions
|
@ -272,7 +272,9 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
var power_levels = this.props.room.currentState.getStateEvents('m.room.power_levels', '');
|
var power_levels = this.props.room.currentState.getStateEvents('m.room.power_levels', '');
|
||||||
var events_levels = (power_levels ? power_levels.events : {}) || {};
|
var events_levels = (power_levels ? power_levels.events : {}) || {};
|
||||||
var user_id = MatrixClientPeg.get().credentials.userId;
|
var cli = MatrixClientPeg.get();
|
||||||
|
var roomState = this.props.room.currentState;
|
||||||
|
var user_id = cli.credentials.userId;
|
||||||
|
|
||||||
if (power_levels) {
|
if (power_levels) {
|
||||||
power_levels = power_levels.getContent();
|
power_levels = power_levels.getContent();
|
||||||
|
@ -321,18 +323,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
var state_default = (parseInt(power_levels ? power_levels.state_default : 0) || 0);
|
var state_default = (parseInt(power_levels ? power_levels.state_default : 0) || 0);
|
||||||
|
|
||||||
var room_aliases_level = state_default;
|
var canSetTag = !cli.isGuest();
|
||||||
if (events_levels['m.room.aliases'] !== undefined) {
|
|
||||||
room_aliases_level = events_levels['m.room.aliases'];
|
|
||||||
}
|
|
||||||
var can_set_room_aliases = current_user_level >= room_aliases_level;
|
|
||||||
|
|
||||||
var canonical_alias_level = state_default;
|
|
||||||
if (events_levels['m.room.canonical_alias'] !== undefined) {
|
|
||||||
canonical_alias_level = events_levels['m.room.canonical_alias'];
|
|
||||||
}
|
|
||||||
var canSetCanonicalAlias = current_user_level >= canonical_alias_level;
|
|
||||||
var canSetTag = true;
|
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
@ -409,7 +400,7 @@ module.exports = React.createClass({
|
||||||
onChange={ self._onTagChange.bind(self, tag.name) }/>
|
onChange={ self._onTagChange.bind(self, tag.name) }/>
|
||||||
{ tag.label }
|
{ tag.label }
|
||||||
</label>);
|
</label>);
|
||||||
}) : tags.map(function(tag) { return tag.label; }).join(", ")
|
}) : (self.state.tags && self.state.tags.join) ? self.state.tags.join(", ") : "None"
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -425,16 +416,20 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
<div className="mx_RoomSettings_toggles">
|
<div className="mx_RoomSettings_toggles">
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" onChange={this._onToggle.bind(this, "areNotifsMuted", true, false)} defaultChecked={this.state.areNotifsMuted}/>
|
<input type="checkbox" disabled={ cli.isGuest() }
|
||||||
|
onChange={this._onToggle.bind(this, "areNotifsMuted", true, false)}
|
||||||
|
defaultChecked={this.state.areNotifsMuted}/>
|
||||||
Mute notifications for this room
|
Mute notifications for this room
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" onChange={this._onToggle.bind(this, "join_rule", "invite", "public")}
|
<input type="checkbox" disabled={ !roomState.mayClientSendStateEvent("m.room.join_rule", cli) }
|
||||||
|
onChange={this._onToggle.bind(this, "join_rule", "invite", "public")}
|
||||||
defaultChecked={this.state.join_rule !== "public"}/>
|
defaultChecked={this.state.join_rule !== "public"}/>
|
||||||
Make this room private
|
Make this room private
|
||||||
</label>
|
</label>
|
||||||
<label>
|
<label>
|
||||||
<input type="checkbox" onChange={this._onToggle.bind(this, "guest_access", "can_join", "forbidden")}
|
<input type="checkbox" disabled={ !roomState.mayClientSendStateEvent("m.room.guest_access", cli) }
|
||||||
|
onChange={this._onToggle.bind(this, "guest_access", "can_join", "forbidden")}
|
||||||
defaultChecked={this.state.guest_access === "can_join"}/>
|
defaultChecked={this.state.guest_access === "can_join"}/>
|
||||||
Let guests join this room
|
Let guests join this room
|
||||||
</label>
|
</label>
|
||||||
|
@ -442,24 +437,28 @@ module.exports = React.createClass({
|
||||||
<h3>Who can read history?</h3>
|
<h3>Who can read history?</h3>
|
||||||
<label htmlFor="hvis_wr">
|
<label htmlFor="hvis_wr">
|
||||||
<input type="radio" id="hvis_wr" name="historyVis" value="world_readable"
|
<input type="radio" id="hvis_wr" name="historyVis" value="world_readable"
|
||||||
|
disabled={ !roomState.mayClientSendStateEvent("m.room.history_visibility", cli) }
|
||||||
defaultChecked={historyVisibility === "world_readable"}
|
defaultChecked={historyVisibility === "world_readable"}
|
||||||
onChange={this._onHistoryRadioToggle} />
|
onChange={this._onHistoryRadioToggle} />
|
||||||
Anyone
|
Anyone
|
||||||
</label>
|
</label>
|
||||||
<label htmlFor="hvis_sh">
|
<label htmlFor="hvis_sh">
|
||||||
<input type="radio" id="hvis_sh" name="historyVis" value="shared"
|
<input type="radio" id="hvis_sh" name="historyVis" value="shared"
|
||||||
|
disabled={ !roomState.mayClientSendStateEvent("m.room.history_visibility", cli) }
|
||||||
defaultChecked={historyVisibility === "shared"}
|
defaultChecked={historyVisibility === "shared"}
|
||||||
onChange={this._onHistoryRadioToggle} />
|
onChange={this._onHistoryRadioToggle} />
|
||||||
Members only (since the point in time of selecting this option)
|
Members only (since the point in time of selecting this option)
|
||||||
</label>
|
</label>
|
||||||
<label htmlFor="hvis_inv">
|
<label htmlFor="hvis_inv">
|
||||||
<input type="radio" id="hvis_inv" name="historyVis" value="invited"
|
<input type="radio" id="hvis_inv" name="historyVis" value="invited"
|
||||||
|
disabled={ !roomState.mayClientSendStateEvent("m.room.history_visibility", cli) }
|
||||||
defaultChecked={historyVisibility === "invited"}
|
defaultChecked={historyVisibility === "invited"}
|
||||||
onChange={this._onHistoryRadioToggle} />
|
onChange={this._onHistoryRadioToggle} />
|
||||||
Members only (since they were invited)
|
Members only (since they were invited)
|
||||||
</label>
|
</label>
|
||||||
<label htmlFor="hvis_joi">
|
<label htmlFor="hvis_joi">
|
||||||
<input type="radio" id="hvis_joi" name="historyVis" value="joined"
|
<input type="radio" id="hvis_joi" name="historyVis" value="joined"
|
||||||
|
disabled={ !roomState.mayClientSendStateEvent("m.room.history_visibility", cli) }
|
||||||
defaultChecked={historyVisibility === "joined"}
|
defaultChecked={historyVisibility === "joined"}
|
||||||
onChange={this._onHistoryRadioToggle} />
|
onChange={this._onHistoryRadioToggle} />
|
||||||
Members only (since they joined)
|
Members only (since they joined)
|
||||||
|
@ -479,8 +478,8 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
<AliasSettings ref="alias_settings"
|
<AliasSettings ref="alias_settings"
|
||||||
roomId={this.props.room.roomId}
|
roomId={this.props.room.roomId}
|
||||||
canSetCanonicalAlias={canSetCanonicalAlias}
|
canSetCanonicalAlias={ roomState.mayClientSendStateEvent("m.room.canonical_alias", cli) }
|
||||||
canSetAliases={can_set_room_aliases}
|
canSetAliases={ roomState.mayClientSendStateEvent("m.room.aliases", cli) }
|
||||||
canonicalAliasEvent={this.props.room.currentState.getStateEvents('m.room.canonical_alias', '')}
|
canonicalAliasEvent={this.props.room.currentState.getStateEvents('m.room.canonical_alias', '')}
|
||||||
aliasEvents={this.props.room.currentState.getStateEvents('m.room.aliases')} />
|
aliasEvents={this.props.room.currentState.getStateEvents('m.room.aliases')} />
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue