diff --git a/.changeset/eleven-yaks-learn.md b/.changeset/eleven-yaks-learn.md new file mode 100644 index 0000000000000..c4b6cb607e7dd --- /dev/null +++ b/.changeset/eleven-yaks-learn.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': minor +--- + +Replaces the cancel button by reset in notification and export messages contextual bar. diff --git a/apps/meteor/client/views/room/contextualBar/ExportMessages/ExportMessages.tsx b/apps/meteor/client/views/room/contextualBar/ExportMessages/ExportMessages.tsx index 892d48b110a7a..9457c97a2bea2 100644 --- a/apps/meteor/client/views/room/contextualBar/ExportMessages/ExportMessages.tsx +++ b/apps/meteor/client/views/room/contextualBar/ExportMessages/ExportMessages.tsx @@ -59,12 +59,13 @@ const ExportMessages = () => { const { control, - formState: { errors, isSubmitting }, + formState: { errors, isSubmitting, isDirty }, watch, register, setValue, handleSubmit, clearErrors, + reset, } = useForm({ mode: 'onBlur', defaultValues: { @@ -126,7 +127,7 @@ const ExportMessages = () => { setValue('format', 'json'); } - setValue('messagesCount', messageCount); + setValue('messagesCount', messageCount, { shouldDirty: true }); }, [type, setValue, messageCount]); const handleExport = async ({ type, toUsers, dateFrom, dateTo, format, subject, additionalEmails }: ExportMessagesFormValues) => { @@ -345,8 +346,10 @@ const ExportMessages = () => { - - + diff --git a/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferences.tsx b/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferences.tsx index 7611f2aa2537d..0ab1921136bc6 100644 --- a/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferences.tsx +++ b/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferences.tsx @@ -33,6 +33,7 @@ const NotificationPreferences = ({ const { t } = useTranslation(); const { formState: { isDirty, isSubmitting }, + reset, } = useFormContext(); return ( @@ -47,7 +48,9 @@ const NotificationPreferences = ({ - {handleClose && } + diff --git a/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferencesForm.tsx b/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferencesForm.tsx index dabf8326bf7d4..ca06eb02f41da 100644 --- a/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferencesForm.tsx +++ b/apps/meteor/client/views/room/contextualBar/NotificationPreferences/NotificationPreferencesForm.tsx @@ -26,26 +26,21 @@ const NotificationPreferencesForm = ({ notificationOptions, handlePlaySound }: N control={control} name='turnOn' render={({ field: { value, onChange } }) => ( - + )} /> ( - + )} /> ( - + )} /> {!showCounter && ( @@ -57,7 +52,7 @@ const NotificationPreferencesForm = ({ notificationOptions, handlePlaySound }: N label={t('Show_mentions')} description={t('Display_mentions_counter')} onChange={onChange} - defaultChecked={value} + checked={value} /> )} /> diff --git a/apps/meteor/client/views/room/contextualBar/NotificationPreferences/components/NotificationToggle.tsx b/apps/meteor/client/views/room/contextualBar/NotificationPreferences/components/NotificationToggle.tsx index 006c1f252ba4b..c3a9c105fe304 100644 --- a/apps/meteor/client/views/room/contextualBar/NotificationPreferences/components/NotificationToggle.tsx +++ b/apps/meteor/client/views/room/contextualBar/NotificationPreferences/components/NotificationToggle.tsx @@ -1,15 +1,14 @@ import { Field, FieldLabel, FieldDescription, FieldGroup, ToggleSwitch, FieldRow } from '@rocket.chat/fuselage'; -import type { ReactElement } from 'react'; +import type { ComponentProps, ReactElement } from 'react'; import { memo, useId } from 'react'; type NotificationToggleProps = { label: string; description?: string; onChange: (e: unknown) => void; - defaultChecked: boolean; -}; +} & ComponentProps; -const NotificationToggle = ({ label, description, onChange, defaultChecked }: NotificationToggleProps): ReactElement => { +const NotificationToggle = ({ label, description, onChange, ...props }: NotificationToggleProps): ReactElement => { const fieldId = useId(); return ( @@ -17,7 +16,7 @@ const NotificationToggle = ({ label, description, onChange, defaultChecked }: No {label} - + {description && {description}} diff --git a/apps/meteor/tests/e2e/export-messages.spec.ts b/apps/meteor/tests/e2e/export-messages.spec.ts index dffb6b4d5edbd..797bc8acb5548 100644 --- a/apps/meteor/tests/e2e/export-messages.spec.ts +++ b/apps/meteor/tests/e2e/export-messages.spec.ts @@ -64,7 +64,7 @@ test.describe.serial('export-messages', () => { await poHomeChannel.tabs.btnExportMessages.click(); await poHomeChannel.content.getMessageByText('hello world').click(); - await poHomeChannel.tabs.exportMessages.btnCancel.click(); + await poHomeChannel.btnContextualbarClose.click(); await poHomeChannel.content.sendMessage('hello export'); await expect(poHomeChannel.content.getMessageByText('hello export')).toBeVisible();