Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Input fields in userPreferences/idleTimeLimit option. #34899

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
34d5fb9
addHoursMinSecFields
thepiyush-303 Oct 22, 2024
57161f7
Merge branch 'develop' into addingFeatureInUserPresence
thepiyush-303 Oct 22, 2024
49c34f7
chore:changeset
thepiyush-303 Oct 26, 2024
d4dc02c
Merge branch 'develop' into addingFeatureInUserPresence
thepiyush-303 Oct 26, 2024
ffbee29
Merge branch 'addingFeatureInUserPresence' of https://github.com/thep…
thepiyush-303 Oct 26, 2024
50ab19e
fix Some files
thepiyush-303 Oct 28, 2024
357db55
draft
thepiyush-303 Dec 15, 2024
1081ce2
Merge branch 'addingFeatureInUserPresence' of https://github.com/thep…
thepiyush-303 Dec 15, 2024
c1d385e
newApproach
thepiyush-303 Dec 15, 2024
1366917
newdraft
thepiyush-303 Dec 15, 2024
2d7506e
better approach
thepiyush-303 Dec 15, 2024
dbbe733
lint
thepiyush-303 Dec 15, 2024
7de98a7
lint
thepiyush-303 Dec 15, 2024
aeeb204
lint
thepiyush-303 Dec 15, 2024
0677a65
lint
thepiyush-303 Dec 15, 2024
4545ae7
lint
thepiyush-303 Dec 15, 2024
2003296
merge conflicts
thepiyush-303 Dec 25, 2024
526cdc0
conflicts
thepiyush-303 Dec 25, 2024
4137e43
Merge branch 'develop' into addingFeatureInUserPresence
thepiyush-303 Dec 25, 2024
88b0a1c
fix
thepiyush-303 Dec 31, 2024
c99ce7f
Merge branch 'addingFeatureInUserPresence' of https://github.com/thep…
thepiyush-303 Dec 31, 2024
30a7434
Merge branch 'develop' into addingFeatureInUserPresence
thepiyush-303 Dec 31, 2024
a55f028
fix1
thepiyush-303 Dec 31, 2024
f5159f1
Merge branch 'addingFeatureInUserPresence' of https://github.com/thep…
thepiyush-303 Dec 31, 2024
110689c
lint
thepiyush-303 Dec 31, 2024
b653d23
Merge branch 'develop' into addingFeatureInUserPresence
thepiyush-303 Jan 3, 2025
cf67e71
fix
thepiyush-303 Jan 7, 2025
9696852
add Minutes, Seconds in en.i18n file
thepiyush-303 Jan 7, 2025
612ecd9
lint
thepiyush-303 Jan 7, 2025
b79d32b
Merge branch 'develop' into feat/EnhanceUserPreference
thepiyush-303 Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/wild-sheep-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Added input fields so the user can specify exactly the time of the enableAutoAway preference in hours, minutes and seconds.
54 changes: 54 additions & 0 deletions apps/meteor/client/views/account/preferences/IdleTimeEditor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { NumberInput, FieldRow, FieldLabel } from '@rocket.chat/fuselage';
import { useUniqueId } from '@rocket.chat/fuselage-hooks';
import { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';

type IdleTimeEditorProps = {
onChangeTime: (time: number | undefined) => void;
};

const IdleTimeEditor = ({ onChangeTime }: IdleTimeEditorProps) => {
const { t } = useTranslation();
const [hours, setHours] = useState<number>(0);
const [minutes, setMinutes] = useState<number>(5);
const [seconds, setSeconds] = useState<number>(0);
const [finalSecondCount, setFinalSecondCount] = useState<number | undefined>(hours * 3600 + minutes * 60 + seconds);

const idleTimeLimitHrs = useUniqueId();
const idleTimeLimitMin = useUniqueId();
const idleTimeLimitSec = useUniqueId();

function handleHours(e: any) {
setHours(Number(e.target.value));
}

function handleMinutes(e: any) {
setMinutes(Number(e.target.value));
}

function handleSeconds(e: any) {
setSeconds(Number(e.target.value));
}

useEffect(() => {
handleFinalSecondCount();
}, [hours, minutes, seconds]);

function handleFinalSecondCount() {
setFinalSecondCount(hours * 3600 + minutes * 60 + seconds);
onChangeTime(finalSecondCount);
}

return (
<FieldRow>
<FieldLabel htmlFor={idleTimeLimitHrs}>{t('Hours')}</FieldLabel>
<NumberInput value={hours} onChange={handleHours} id={idleTimeLimitHrs} min={0} />
<FieldLabel htmlFor={idleTimeLimitMin}>{t('Minutes')}</FieldLabel>
<NumberInput value={minutes} onChange={handleMinutes} id={idleTimeLimitMin} max={59} min={0} />
<FieldLabel htmlFor={idleTimeLimitSec}>{t('Seconds')}</FieldLabel>
<NumberInput value={seconds} onChange={handleSeconds} id={idleTimeLimitSec} max={59} min={0} />
</FieldRow>
);
};

export default IdleTimeEditor;
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { AccordionItem, Field, FieldLabel, FieldRow, NumberInput, FieldGroup, ToggleSwitch } from '@rocket.chat/fuselage';
import { AccordionItem, Field, FieldLabel, FieldRow, FieldGroup, ToggleSwitch } from '@rocket.chat/fuselage';
import { useUniqueId } from '@rocket.chat/fuselage-hooks';
import { Controller, useFormContext } from 'react-hook-form';
import { useTranslation } from 'react-i18next';

import IdleTimeEditor from './IdleTimeEditor';

const PreferencesUserPresenceSection = () => {
const { t } = useTranslation();
const { register, control } = useFormContext();
const { control } = useFormContext();

const enableAutoAwayId = useUniqueId();
const idleTimeLimit = useUniqueId();

return (
<AccordionItem title={t('User_Presence')}>
Expand All @@ -26,10 +27,12 @@ const PreferencesUserPresenceSection = () => {
</FieldRow>
</Field>
<Field>
<FieldLabel htmlFor={idleTimeLimit}>{t('Idle_Time_Limit')}</FieldLabel>
<FieldRow>
<NumberInput id={idleTimeLimit} {...register('idleTimeLimit')} />
</FieldRow>
<FieldLabel>{t('Idle_Time_Limit')}</FieldLabel>
<Controller
name='idleTimeLimit'
control={control}
render={({ field: { onChange } }) => <IdleTimeEditor onChangeTime={onChange} />}
/>
</Field>
</FieldGroup>
</AccordionItem>
Expand Down
2 changes: 2 additions & 0 deletions packages/i18n/src/locales/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3815,6 +3815,7 @@
"Minimum_balance": "Minimum balance",
"minute": "minute",
"minutes": "minutes",
"Minutes": "Minutes",
"Missing_configuration": "Missing configuration",
"Mobex_sms_gateway_address": "Mobex SMS Gateway Address",
"Mobex_sms_gateway_address_desc": "IP or Host of your Mobex service with specified port. E.g. `http://192.168.1.1:1401` or `https://www.example.com:1401`",
Expand Down Expand Up @@ -4941,6 +4942,7 @@
"used_limit_infinite": "{{used, number}} / ∞",
"Seats_usage": "Seats Usage",
"seconds": "seconds",
"Seconds": "Seconds",
"Secret_token": "Secret Token",
"Secure_SaaS_solution": "Secure SaaS solution.",
"Security": "Security",
Expand Down
Loading