From cfd6833356820d392a2dae3b7c3f96f6a8d30cb3 Mon Sep 17 00:00:00 2001 From: Timo Date: Mon, 2 Dec 2024 13:45:24 +0100 Subject: [PATCH] Use the JoinRuleSettings component for the guest link access prompt. Co-authored-by: fkwp --- res/css/views/settings/_JoinRuleSettings.pcss | 12 ++++++ .../rooms/RoomHeader/CallGuestLinkButton.tsx | 42 +++++++++---------- .../views/settings/JoinRuleSettings.tsx | 30 +++++++++---- src/i18n/strings/de_DE.json | 7 +++- src/i18n/strings/en_EN.json | 8 ++-- 5 files changed, 64 insertions(+), 35 deletions(-) diff --git a/res/css/views/settings/_JoinRuleSettings.pcss b/res/css/views/settings/_JoinRuleSettings.pcss index 965db9fb45f..82cb2e0d0f7 100644 --- a/res/css/views/settings/_JoinRuleSettings.pcss +++ b/res/css/views/settings/_JoinRuleSettings.pcss @@ -53,6 +53,14 @@ Please see LICENSE files in the repository root for full details. display: block; } + &.mx_StyledRadioButton_disabled { + opacity: 0.5; + } + + &.mx_StyledRadioButton_disabled + span { + opacity: 0.5; + } + & + span { display: inline-block; margin-left: 34px; @@ -71,3 +79,7 @@ Please see LICENSE files in the repository root for full details. font: var(--cpd-font-body-md-regular); margin-top: var(--cpd-space-2x); } + +.mx_JoinRuleSettings_recommended { + color: $accent-1000; +} diff --git a/src/components/views/rooms/RoomHeader/CallGuestLinkButton.tsx b/src/components/views/rooms/RoomHeader/CallGuestLinkButton.tsx index ae8e7be16bf..be3ed3176ea 100644 --- a/src/components/views/rooms/RoomHeader/CallGuestLinkButton.tsx +++ b/src/components/views/rooms/RoomHeader/CallGuestLinkButton.tsx @@ -14,10 +14,10 @@ import { EventType, JoinRule, Room } from "matrix-js-sdk/src/matrix"; import Modal from "../../../../Modal"; import ShareDialog from "../../dialogs/ShareDialog"; import { _t } from "../../../../languageHandler"; -import SettingsStore from "../../../../settings/SettingsStore"; import { calculateRoomVia } from "../../../../utils/permalinks/Permalinks"; import BaseDialog from "../../dialogs/BaseDialog"; import { useGuestAccessInformation } from "../../../../hooks/room/useGuestAccessInformation"; +import JoinRuleSettings from "../../settings/JoinRuleSettings"; /** * Display a button to open a dialog to share a link to the call using a element call guest spa url (`element_call:guest_spa_url` in the EW config). @@ -99,7 +99,6 @@ export const JoinRuleDialog: React.FC<{ room: Room; canInvite: boolean; }> = ({ onFinished, room, canInvite }) => { - const askToJoinEnabled = SettingsStore.getValue("feature_ask_to_join"); const [isUpdating, setIsUpdating] = React.useState(undefined); const changeJoinRule = useCallback( async (newRule: JoinRule) => { @@ -120,27 +119,24 @@ export const JoinRuleDialog: React.FC<{ ); return ( -

{_t("update_room_access_modal|description")}

-
- {askToJoinEnabled && canInvite && ( - - )} - -
+

{_t("update_room_access_modal|description", {}, { b: (sub) => {sub} })}

+

+ {_t("update_room_access_modal|revert_access_description", {}, { b: (sub) => {sub} })} +

+ { + await changeJoinRule(newRule).catch(() => { + return false; + }); + return true; + }} + closeSettingsFn={() => {}} + onError={(error: unknown) => logger.error("Could not generate change access level:", error)} + />

{_t("update_room_access_modal|dont_change_description")}