From ea01bc7bafcd986b47663c5e75bf4c223a0a2e06 Mon Sep 17 00:00:00 2001
From: ankur12-1610
Date: Sat, 23 Jul 2022 09:58:42 +0530
Subject: [PATCH] Added conditional rendering for the JoinRule DropDown based
on labs feature
Signed-off-by: ankur12-1610
---
src/components/views/dialogs/CreateRoomDialog.tsx | 9 +++++++--
src/components/views/elements/JoinRuleDropdown.tsx | 7 ++++---
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/components/views/dialogs/CreateRoomDialog.tsx b/src/components/views/dialogs/CreateRoomDialog.tsx
index 4650a806bf92..003fb992970a 100644
--- a/src/components/views/dialogs/CreateRoomDialog.tsx
+++ b/src/components/views/dialogs/CreateRoomDialog.tsx
@@ -20,6 +20,7 @@ import { Room } from "matrix-js-sdk/src/models/room";
import { RoomType } from "matrix-js-sdk/src/@types/event";
import { JoinRule, Preset, Visibility } from "matrix-js-sdk/src/@types/partials";
+import SettingsStore from '../../../settings/SettingsStore';
import SdkConfig from '../../../SdkConfig';
import withValidation, { IFieldState } from '../elements/Validation';
import { _t } from '../../../languageHandler';
@@ -59,6 +60,7 @@ interface IState {
export default class CreateRoomDialog extends React.Component {
private readonly supportsRestricted: boolean;
+ private readonly knockingEnabled: boolean;
private nameField = createRef();
private aliasField = createRef();
@@ -66,12 +68,15 @@ export default class CreateRoomDialog extends React.Component {
super(props);
this.supportsRestricted = !!this.props.parentSpace;
+ this.knockingEnabled = SettingsStore.getValue("feature_knocking");
let joinRule = JoinRule.Invite;
if (this.props.defaultPublic) {
joinRule = JoinRule.Public;
} else if (this.supportsRestricted) {
joinRule = JoinRule.Restricted;
+ } else if (this.knockingEnabled) {
+ joinRule = JoinRule.Knock;
}
this.state = {
@@ -269,7 +274,7 @@ export default class CreateRoomDialog extends React.Component {
{ _t("You can change this at any time from room settings.") }
;
- } else if (this.state.joinRule === JoinRule.Knock) {
+ } else if (this.state.joinRule === JoinRule.Knock && this.knockingEnabled) {
publicPrivateLabel =
{ _t("Anyone can knock on this room to join.") }
@@ -353,7 +358,7 @@ export default class CreateRoomDialog extends React.Component {
{ labelInvite }
,
-
- { labelKnock }
-
,
{ labelPublic }
,
@@ -56,6 +53,10 @@ const JoinRuleDropdown = ({
options.unshift(
{ labelRestricted }
);
+ } else if (labelKnock) {
+ options.unshift(
+ { labelKnock }
+
);
}
return