From e939b450fed70687000afb65fcaa8feecc013cb5 Mon Sep 17 00:00:00 2001 From: Yogesh Aggarwal Date: Sat, 6 Jan 2024 20:26:18 +0530 Subject: [PATCH] feat: Added checkbox in settings for the new setting (#2532) --- src/ui/components/SettingsView/GeneralTab.tsx | 2 + .../features/AlwaysStartAtHomePage.tsx | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/ui/components/SettingsView/features/AlwaysStartAtHomePage.tsx diff --git a/src/ui/components/SettingsView/GeneralTab.tsx b/src/ui/components/SettingsView/GeneralTab.tsx index 4fafff5fb..86c5683e1 100644 --- a/src/ui/components/SettingsView/GeneralTab.tsx +++ b/src/ui/components/SettingsView/GeneralTab.tsx @@ -2,6 +2,7 @@ import { Box, FieldGroup } from '@rocket.chat/fuselage'; import type { FC } from 'react'; import React from 'react'; +import { AlwaysStartAtHomePage } from './features/AlwaysStartAtHomePage'; import { ClearPermittedScreenCaptureServers } from './features/ClearPermittedScreenCaptureServers'; import { FlashFrame } from './features/FlashFrame'; import { HardwareAcceleration } from './features/HardwareAcceleration'; @@ -16,6 +17,7 @@ import { TrayIcon } from './features/TrayIcon'; export const GeneralTab: FC = () => ( + diff --git a/src/ui/components/SettingsView/features/AlwaysStartAtHomePage.tsx b/src/ui/components/SettingsView/features/AlwaysStartAtHomePage.tsx new file mode 100644 index 000000000..d5e1e931e --- /dev/null +++ b/src/ui/components/SettingsView/features/AlwaysStartAtHomePage.tsx @@ -0,0 +1,52 @@ +import { + Field, + FieldHint, + FieldLabel, + FieldRow, + ToggleSwitch, +} from '@rocket.chat/fuselage'; +import type { ChangeEvent, FC } from 'react'; +import React, { useCallback } from 'react'; +import { useTranslation } from 'react-i18next'; +import { useDispatch, useSelector } from 'react-redux'; +import type { Dispatch } from 'redux'; + +import type { RootAction } from '../../../../store/actions'; +import type { RootState } from '../../../../store/rootReducer'; +import { SETTINGS_SET_DO_ALWAYS_START_AT_HOME_PAGE_CHANGED } from '../../../actions'; + +type Props = { + className?: string; +}; + +export const AlwaysStartAtHomePage: FC = (props) => { + const isEnabled = useSelector( + ({ doAlwaysStartAtHomePage }: RootState) => doAlwaysStartAtHomePage + ); + const dispatch = useDispatch>(); + const { t } = useTranslation(); + const handleChange = useCallback( + (event: ChangeEvent) => { + const isChecked = event.currentTarget.checked; + dispatch({ + type: SETTINGS_SET_DO_ALWAYS_START_AT_HOME_PAGE_CHANGED, + payload: isChecked, + }); + }, + [dispatch] + ); + + return ( + + + + + {t('settings.options.startPage.title')} + + + + {t('settings.options.startPage.description')} + + + ); +};