Skip to content

Commit

Permalink
Revert "Créer les salons dans un espace"
Browse files Browse the repository at this point in the history
This reverts commit b33c60c.
  • Loading branch information
jdauphant committed Sep 5, 2023
1 parent b33c60c commit ec4db29
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 40 deletions.
9 changes: 2 additions & 7 deletions src/tchap/components/views/dialogs/TchapCreateRoomDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import TchapCreateRoom from "../../../lib/createTchapRoom";
interface IProps {
defaultPublic?: boolean; // unused for Tchap version
defaultName?: string;
parentSpace?: Room;
parentSpace?: Room; // unused for Tchap version
defaultEncrypted?: boolean; // unused for Tchap version
onFinished(proceed: boolean, opts?: IOpts): void;
}
Expand All @@ -43,16 +43,13 @@ interface IState {
tchapRoomType: TchapRoomType;
forumFederationSwitchValue: boolean;
showFederateSwitch: boolean;
createRoomInSpace: boolean;
}

export default class TchapCreateRoomDialog extends React.Component<IProps, IState> {
private nameField = createRef<Field>();
private readonly createRoomInSpace: boolean;

public constructor(props) {
super(props);
this.createRoomInSpace = !!this.props.parentSpace;

const federationOptions = TchapUtils.getRoomFederationOptions();

Expand All @@ -62,7 +59,6 @@ export default class TchapCreateRoomDialog extends React.Component<IProps, IStat
tchapRoomType: TchapRoomType.Private,
forumFederationSwitchValue: federationOptions.forumFederationSwitchDefaultValue,
showFederateSwitch: federationOptions.showForumFederationSwitch,
createRoomInSpace: createRoomInSpace,
};
}

Expand Down Expand Up @@ -153,7 +149,7 @@ export default class TchapCreateRoomDialog extends React.Component<IProps, IStat
public render() {
const shortDomain: string = TchapUtils.getShortDomain();

const title = this.createRoomInSpace ? _t("Create a room in this space") : _t("Create a room");
const title = _t("Create a room");

return (
<BaseDialog
Expand All @@ -180,7 +176,6 @@ export default class TchapCreateRoomDialog extends React.Component<IProps, IStat
forumFederationSwitchValue={this.state.forumFederationSwitchValue}
setForumFederationSwitchValue={this.onForumFederatedChange}
setRoomType={this.onTchapRoomTypeChange}
createRoomInSpace={this.createRoomInSpace}
/>
</div>
</form>
Expand Down
7 changes: 3 additions & 4 deletions src/tchap/components/views/elements/TchapRoomTypeSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ interface IProps {
forumFederationSwitchValue?: boolean;
setRoomType(value: TchapRoomType): void;
setForumFederationSwitchValue(forumFederationSwitchValue: boolean): void;
createRoomInSpace: boolean;
}

interface IState {
Expand Down Expand Up @@ -84,7 +83,7 @@ export default class TchapRoomTypeSelector extends React.Component<IProps, IStat
onChange={this.onRoomTypeChange}
>
<div className="tc_TchapRoomTypeSelector_RadioButton_title">{_t("Private room")}</div>
<div>{this.createRoomInSpace ? _t("Private discussions accessible to all users of this space.") : _t("Accessible to all users by invitation from an administrator.")}</div>
<div>{_t("Accessible to all users by invitation from an administrator.")}</div>
</StyledRadioButton>
</label>
<label className={externalClasses}>
Expand All @@ -98,7 +97,7 @@ export default class TchapRoomTypeSelector extends React.Component<IProps, IStat
{_t("Private room open to external users")}
</div>
<div>
{this.createRoomInSpace ? _t("Accessible to all users of this space and to external guests by invitation of an administrator.") : _t("Accessible to all users and to external guests by invitation of an administrator.")}
{_t("Accessible to all users and to external guests by invitation of an administrator.")}
</div>
</StyledRadioButton>
</label>
Expand All @@ -110,7 +109,7 @@ export default class TchapRoomTypeSelector extends React.Component<IProps, IStat
onChange={this.onRoomTypeChange}
>
<div className="tc_TchapRoomTypeSelector_RadioButton_title">{_t("Forum room")}</div>
<div>{this.createRoomInSpace ? _t("Public discussion accessible to all users of this space or from a shared link.") : _t("Accessible to all users from the forum directory or from a shared link.")}</div>
<div>{_t("Accessible to all users from the forum directory or from a shared link.")}</div>
{roomFederateOpt}
</StyledRadioButton>
</label>
Expand Down
34 changes: 5 additions & 29 deletions src/tchap/lib/createTchapRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,10 @@ export default class TchapCreateRoom {
createRoomOpts.creation_content = { "m.federate": federate };
createRoomOpts.initial_state = createRoomOpts.initial_state || [];

opts.parentSpace = this.props.parentSpace;

switch (tchapRoomType) {
case TchapRoomType.Forum: {
// Space "Forum" only for members and not encrypted
if (this.props.parentSpace) {
createRoomOpts.visibility = Visibility.PrivateChat;
} else { //"Forum" only for tchap members and not encrypted
createRoomOpts.visibility = Visibility.Public;
}
//"Forum" only for tchap members and not encrypted
createRoomOpts.visibility = Visibility.Public;
createRoomOpts.preset = Preset.PublicChat;
// Here we could have used createRoomOpts.accessRule directly,
// but since accessRules are a custom Tchap event, it is ignored by later code.
Expand All @@ -52,12 +46,7 @@ export default class TchapCreateRoom {
state_key: "",
});

//Open to space by default
if (this.props.parentSpace) {
opts.joinRule = JoinRule.Restricted;
} else {
opts.joinRule = JoinRule.Public;
}
opts.joinRule = JoinRule.Public;
opts.encryption = false;
opts.historyVisibility = HistoryVisibility.Shared;
break;
Expand All @@ -73,12 +62,7 @@ export default class TchapCreateRoom {
type: TchapRoomAccessRulesEventId,
state_key: "",
});
//Open to space by default
if (this.props.parentSpace) {
opts.joinRule = JoinRule.Restricted;
} else {
opts.joinRule = JoinRule.Invite;
}
opts.joinRule = JoinRule.Invite;
opts.encryption = true;
opts.historyVisibility = HistoryVisibility.Invited;
break;
Expand All @@ -94,20 +78,12 @@ export default class TchapCreateRoom {
type: TchapRoomAccessRulesEventId,
state_key: "",
});
//Open to space by default
if (this.props.parentSpace) {
opts.joinRule = JoinRule.Restricted;
} else {
opts.joinRule = JoinRule.Invite;
}
opts.joinRule = JoinRule.Invite;
opts.encryption = true;
opts.historyVisibility = HistoryVisibility.Invited;
break;
}
}



return opts;
}
}

0 comments on commit ec4db29

Please sign in to comment.