Fix room security radios
This commit is contained in:
parent
a61cbc1a11
commit
b871d7e849
2 changed files with 8 additions and 13 deletions
|
@ -34,7 +34,7 @@ interface IProps<T extends string> {
|
||||||
definitions: IDefinition<T>[];
|
definitions: IDefinition<T>[];
|
||||||
value?: T; // if not provided no options will be selected
|
value?: T; // if not provided no options will be selected
|
||||||
outlined?: boolean;
|
outlined?: boolean;
|
||||||
onChange(newValue: T);
|
onChange(newValue: T): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function StyledRadioGroup<T extends string>({name, definitions, value, className, outlined, onChange}: IProps<T>) {
|
function StyledRadioGroup<T extends string>({name, definitions, value, className, outlined, onChange}: IProps<T>) {
|
||||||
|
|
|
@ -145,7 +145,7 @@ export default class SecurityRoomSettingsTab extends React.Component {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_onRoomAccessRadioToggle = (ev) => {
|
_onRoomAccessRadioToggle = (roomAccess) => {
|
||||||
// join_rule
|
// join_rule
|
||||||
// INVITE | PUBLIC
|
// INVITE | PUBLIC
|
||||||
// ----------------------+----------------
|
// ----------------------+----------------
|
||||||
|
@ -162,7 +162,7 @@ export default class SecurityRoomSettingsTab extends React.Component {
|
||||||
let joinRule = "invite";
|
let joinRule = "invite";
|
||||||
let guestAccess = "can_join";
|
let guestAccess = "can_join";
|
||||||
|
|
||||||
switch (ev.target.value) {
|
switch (roomAccess) {
|
||||||
case "invite_only":
|
case "invite_only":
|
||||||
// no change - use defaults above
|
// no change - use defaults above
|
||||||
break;
|
break;
|
||||||
|
@ -191,11 +191,11 @@ export default class SecurityRoomSettingsTab extends React.Component {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_onHistoryRadioToggle = (ev) => {
|
_onHistoryRadioToggle = (history) => {
|
||||||
const beforeHistory = this.state.history;
|
const beforeHistory = this.state.history;
|
||||||
this.setState({history: ev.target.value});
|
this.setState({history: history});
|
||||||
MatrixClientPeg.get().sendStateEvent(this.props.roomId, "m.room.history_visibility", {
|
MatrixClientPeg.get().sendStateEvent(this.props.roomId, "m.room.history_visibility", {
|
||||||
history_visibility: ev.target.value,
|
history_visibility: history,
|
||||||
}, "").catch((e) => {
|
}, "").catch((e) => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
this.setState({history: beforeHistory});
|
this.setState({history: beforeHistory});
|
||||||
|
@ -261,25 +261,23 @@ export default class SecurityRoomSettingsTab extends React.Component {
|
||||||
<StyledRadioGroup
|
<StyledRadioGroup
|
||||||
name="roomVis"
|
name="roomVis"
|
||||||
value={joinRule}
|
value={joinRule}
|
||||||
|
onChange={this._onRoomAccessRadioToggle}
|
||||||
definitions={[
|
definitions={[
|
||||||
{
|
{
|
||||||
value: "invite_only",
|
value: "invite_only",
|
||||||
disabled: !canChangeAccess,
|
disabled: !canChangeAccess,
|
||||||
onChange: this._onRoomAccessRadioToggle,
|
|
||||||
label: _t('Only people who have been invited'),
|
label: _t('Only people who have been invited'),
|
||||||
checked: joinRule !== "public",
|
checked: joinRule !== "public",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "public_no_guests",
|
value: "public_no_guests",
|
||||||
disabled: !canChangeAccess,
|
disabled: !canChangeAccess,
|
||||||
onChange: this._onRoomAccessRadioToggle,
|
|
||||||
label: _t('Anyone who knows the room\'s link, apart from guests'),
|
label: _t('Anyone who knows the room\'s link, apart from guests'),
|
||||||
checked: joinRule === "public" && guestAccess !== "can_join",
|
checked: joinRule === "public" && guestAccess !== "can_join",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "public_with_guests",
|
value: "public_with_guests",
|
||||||
disabled: !canChangeAccess,
|
disabled: !canChangeAccess,
|
||||||
onChange: this._onRoomAccessRadioToggle,
|
|
||||||
label: _t("Anyone who knows the room's link, including guests"),
|
label: _t("Anyone who knows the room's link, including guests"),
|
||||||
checked: joinRule === "public" && guestAccess === "can_join",
|
checked: joinRule === "public" && guestAccess === "can_join",
|
||||||
},
|
},
|
||||||
|
@ -304,29 +302,26 @@ export default class SecurityRoomSettingsTab extends React.Component {
|
||||||
<StyledRadioGroup
|
<StyledRadioGroup
|
||||||
name="historyVis"
|
name="historyVis"
|
||||||
value={history}
|
value={history}
|
||||||
|
onChange={this._onHistoryRadioToggle}
|
||||||
definitions={[
|
definitions={[
|
||||||
{
|
{
|
||||||
value: "world_readable",
|
value: "world_readable",
|
||||||
disabled: !canChangeHistory,
|
disabled: !canChangeHistory,
|
||||||
onChange: this._onHistoryRadioToggle,
|
|
||||||
label: _t("Anyone"),
|
label: _t("Anyone"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "shared",
|
value: "shared",
|
||||||
disabled: !canChangeHistory,
|
disabled: !canChangeHistory,
|
||||||
onChange: this._onHistoryRadioToggle,
|
|
||||||
label: _t('Members only (since the point in time of selecting this option)'),
|
label: _t('Members only (since the point in time of selecting this option)'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "invited",
|
value: "invited",
|
||||||
disabled: !canChangeHistory,
|
disabled: !canChangeHistory,
|
||||||
onChange: this._onHistoryRadioToggle,
|
|
||||||
label: _t('Members only (since they were invited)'),
|
label: _t('Members only (since they were invited)'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: "joined",
|
value: "joined",
|
||||||
disabled: !canChangeHistory,
|
disabled: !canChangeHistory,
|
||||||
onChange: this._onHistoryRadioToggle,
|
|
||||||
label: _t('Members only (since they joined)'),
|
label: _t('Members only (since they joined)'),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
|
|
Loading…
Reference in a new issue