diff --git a/src/tchap/components/views/dialogs/TchapCreateRoomDialog.tsx b/src/tchap/components/views/dialogs/TchapCreateRoomDialog.tsx index ac5184f0dd..b3507899a5 100644 --- a/src/tchap/components/views/dialogs/TchapCreateRoomDialog.tsx +++ b/src/tchap/components/views/dialogs/TchapCreateRoomDialog.tsx @@ -32,7 +32,7 @@ import TchapCreateRoom from "../../../lib/createTchapRoom"; interface IProps { defaultPublic?: boolean; // unused for Tchap version defaultName?: string; - parentSpace?: Room; // unused for Tchap version + parentSpace?: Room; defaultEncrypted?: boolean; // unused for Tchap version onFinished(proceed: boolean, opts?: IOpts): void; } @@ -47,9 +47,11 @@ interface IState { export default class TchapCreateRoomDialog extends React.Component { private nameField = createRef(); + private readonly createRoomInSpace: boolean; public constructor(props) { super(props); + this.createRoomInSpace = !!this.props.parentSpace; const federationOptions = TchapUtils.getRoomFederationOptions(); @@ -132,6 +134,7 @@ export default class TchapCreateRoomDialog extends React.Component diff --git a/src/tchap/components/views/elements/TchapRoomTypeSelector.tsx b/src/tchap/components/views/elements/TchapRoomTypeSelector.tsx index 5f23cc05e7..b91dd5ba5d 100644 --- a/src/tchap/components/views/elements/TchapRoomTypeSelector.tsx +++ b/src/tchap/components/views/elements/TchapRoomTypeSelector.tsx @@ -21,6 +21,7 @@ interface IProps { forumFederationSwitchValue?: boolean; setRoomType(value: TchapRoomType): void; setForumFederationSwitchValue(forumFederationSwitchValue: boolean): void; + createRoomInSpace: boolean; } interface IState { @@ -83,7 +84,7 @@ export default class TchapRoomTypeSelector extends React.Component
{_t("Private room")}
-
{_t("Accessible to all users by invitation from an administrator.")}
+
{this.props.createRoomInSpace ? _t("Private discussions accessible to all users of this space.") : _t("Accessible to all users by invitation from an administrator.")}
@@ -109,7 +110,7 @@ export default class TchapRoomTypeSelector extends React.Component
{_t("Forum room")}
-
{_t("Accessible to all users from the forum directory or from a shared link.")}
+
{this.props.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.")}
{roomFederateOpt} diff --git a/src/tchap/i18n/strings/tchap_translations.json b/src/tchap/i18n/strings/tchap_translations.json index 9627a04cfc..ed1904dea6 100644 --- a/src/tchap/i18n/strings/tchap_translations.json +++ b/src/tchap/i18n/strings/tchap_translations.json @@ -57,6 +57,22 @@ "en":"Allow access to this room to all users, even outside \"%(domain)s\" domain", "fr":"Autoriser l'accès à tous les utilisateurs, même ceux qui ne sont pas membres du domaine \"%(domain)s\"" }, + "Create a room in this space": { + "en": "Create a room in this space", + "fr": "Créer un salon dans cet espace" + }, + "Private discussions accessible to all users of this space.": { + "en": "Private discussions accessible to all users of this space.", + "fr": "Discussions privées accessibles à tous les membres de cet espace" + }, + "Private discussions accessible to all users of this space and to external guests by invitation of an administrator.": { + "en": "Private discussions accessible to all users of this space and to external guests by invitation of an administrator.", + "fr": "Discussions privées accessibles à tous les membres de cet espace et aux utilisateurs externes sur invitation d'un administrateur." + }, + "Public discussion accessible to all users of this space or from a shared link.": { + "en": "Public discussion accessible to all users of this space or from a shared link.", + "fr": "Discussions publiques accessibles à tous les membres de cet espace ou depuis un lien de partage." + }, "Scanning": { "en": "Scanning", "fr": "Scanning" diff --git a/src/tchap/lib/createTchapRoom.ts b/src/tchap/lib/createTchapRoom.ts index e5680fcd1c..03f7c496a2 100644 --- a/src/tchap/lib/createTchapRoom.ts +++ b/src/tchap/lib/createTchapRoom.ts @@ -18,6 +18,7 @@ export default class TchapCreateRoom { name: string, tchapRoomType: TchapRoomType, federate: boolean = DEFAULT_FEDERATE_VALUE, + parentSpace?: Room ): IOpts { const opts: IOpts = {}; const createRoomOpts: ICreateRoomOpts = {}; @@ -30,10 +31,18 @@ export default class TchapCreateRoom { createRoomOpts.creation_content = { "m.federate": federate }; createRoomOpts.initial_state = createRoomOpts.initial_state || []; + if(parentSpace) { + opts.parentSpace = parentSpace; + } + switch (tchapRoomType) { case TchapRoomType.Forum: { - //"Forum" only for tchap members and not encrypted - createRoomOpts.visibility = Visibility.Public; + // Space "Forum" only for space members and not encrypted + if (parentSpace) { + createRoomOpts.visibility = Visibility.PrivateChat; + } else { //"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. @@ -46,7 +55,12 @@ export default class TchapCreateRoom { state_key: "", }); - opts.joinRule = JoinRule.Public; + //Open to space by default + if (parentSpace) { + opts.joinRule = JoinRule.Restricted; + } else { + opts.joinRule = JoinRule.Public; + } opts.encryption = false; opts.historyVisibility = HistoryVisibility.Shared; break; @@ -62,7 +76,12 @@ export default class TchapCreateRoom { type: TchapRoomAccessRulesEventId, state_key: "", }); - opts.joinRule = JoinRule.Invite; + //Open to space by default + if (parentSpace) { + opts.joinRule = JoinRule.Restricted; + } else { + opts.joinRule = JoinRule.Invite; + } opts.encryption = true; opts.historyVisibility = HistoryVisibility.Invited; break; @@ -78,7 +97,12 @@ export default class TchapCreateRoom { type: TchapRoomAccessRulesEventId, state_key: "", }); - opts.joinRule = JoinRule.Invite; + //Open to space by default + if (parentSpace) { + opts.joinRule = JoinRule.Restricted; + } else { + opts.joinRule = JoinRule.Invite; + } opts.encryption = true; opts.historyVisibility = HistoryVisibility.Invited; break;