[MM-61683]: Ensure radio button groups are properly formed (#30013)

* MM-61683: Ensure radio button groups are properly formed

* MM-61683: Fix the failing i18 CI

* MM-61683: Fix desktop notification translation IDs

* MM-61683: Fix lint-style

* MM-61683: Update name attribute inside channel notification modal
Add aria-label inside RadioSettingItem
Update snapshot

* MM-61683: Revert creating a constant for default messages and id

* MM-61683: Add legend tag inside radio setting item component

* MM-61683: Update snapshot

---------

Co-authored-by: Saurabh Sharma <saurabh.sharma@brightscout.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
ayush-chauhan233 2025-02-11 21:16:06 +05:30 committed by GitHub
parent d3dcc74e5a
commit 9aaa52136c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 195 additions and 162 deletions

View File

@ -201,6 +201,11 @@ Object {
<fieldset
class="mm-modal-generic-section-item__fieldset-radio"
>
<legend
class="hidden-label"
>
Notify me about…
</legend>
<label
class="mm-modal-generic-section-item__label-radio"
>
@ -208,7 +213,7 @@ Object {
checked=""
data-testid="desktopNotification-all"
id="desktopNotification-all"
name="desktopNotification-all"
name="desktop"
type="radio"
value="all"
/>
@ -221,7 +226,7 @@ Object {
<input
data-testid="desktopNotification-mention"
id="desktopNotification-mention"
name="desktopNotification-mention"
name="desktop"
type="radio"
value="mention"
/>
@ -233,7 +238,7 @@ Object {
<input
data-testid="desktopNotification-none"
id="desktopNotification-none"
name="desktopNotification-none"
name="desktop"
type="radio"
value="none"
/>
@ -637,6 +642,11 @@ Object {
<fieldset
class="mm-modal-generic-section-item__fieldset-radio"
>
<legend
class="hidden-label"
>
Notify me about…
</legend>
<label
class="mm-modal-generic-section-item__label-radio"
>
@ -644,7 +654,7 @@ Object {
checked=""
data-testid="desktopNotification-all"
id="desktopNotification-all"
name="desktopNotification-all"
name="desktop"
type="radio"
value="all"
/>
@ -657,7 +667,7 @@ Object {
<input
data-testid="desktopNotification-mention"
id="desktopNotification-mention"
name="desktopNotification-mention"
name="desktop"
type="radio"
value="mention"
/>
@ -669,7 +679,7 @@ Object {
<input
data-testid="desktopNotification-none"
id="desktopNotification-none"
name="desktopNotification-none"
name="desktop"
type="radio"
value="none"
/>
@ -836,13 +846,18 @@ Object {
<fieldset
class="mm-modal-generic-section-item__fieldset-radio"
>
<legend
class="hidden-label"
>
Notify me about…
</legend>
<label
class="mm-modal-generic-section-item__label-radio"
>
<input
data-testid="MobileNotification-all"
id="MobileNotification-all"
name="MobileNotification-all"
name="push"
type="radio"
value="all"
/>
@ -855,7 +870,7 @@ Object {
checked=""
data-testid="MobileNotification-mention"
id="MobileNotification-mention"
name="MobileNotification-mention"
name="push"
type="radio"
value="mention"
/>
@ -868,7 +883,7 @@ Object {
<input
data-testid="MobileNotification-none"
id="MobileNotification-none"
name="MobileNotification-none"
name="push"
type="radio"
value="none"
/>
@ -1530,6 +1545,11 @@ Object {
<fieldset
class="mm-modal-generic-section-item__fieldset-radio"
>
<legend
class="hidden-label"
>
Notify me about…
</legend>
<label
class="mm-modal-generic-section-item__label-radio"
>
@ -1537,7 +1557,7 @@ Object {
checked=""
data-testid="desktopNotification-all"
id="desktopNotification-all"
name="desktopNotification-all"
name="desktop"
type="radio"
value="all"
/>
@ -1550,7 +1570,7 @@ Object {
<input
data-testid="desktopNotification-mention"
id="desktopNotification-mention"
name="desktopNotification-mention"
name="desktop"
type="radio"
value="mention"
/>
@ -1562,7 +1582,7 @@ Object {
<input
data-testid="desktopNotification-none"
id="desktopNotification-none"
name="desktopNotification-none"
name="desktop"
type="radio"
value="none"
/>
@ -2047,6 +2067,11 @@ Object {
<fieldset
class="mm-modal-generic-section-item__fieldset-radio"
>
<legend
class="hidden-label"
>
Notify me about…
</legend>
<label
class="mm-modal-generic-section-item__label-radio"
>
@ -2054,7 +2079,7 @@ Object {
checked=""
data-testid="desktopNotification-all"
id="desktopNotification-all"
name="desktopNotification-all"
name="desktop"
type="radio"
value="all"
/>
@ -2067,7 +2092,7 @@ Object {
<input
data-testid="desktopNotification-mention"
id="desktopNotification-mention"
name="desktopNotification-mention"
name="desktop"
type="radio"
value="mention"
/>
@ -2079,7 +2104,7 @@ Object {
<input
data-testid="desktopNotification-none"
id="desktopNotification-none"
name="desktopNotification-none"
name="desktop"
type="radio"
value="none"
/>
@ -2564,6 +2589,11 @@ Object {
<fieldset
class="mm-modal-generic-section-item__fieldset-radio"
>
<legend
class="hidden-label"
>
Notify me about…
</legend>
<label
class="mm-modal-generic-section-item__label-radio"
>
@ -2571,7 +2601,7 @@ Object {
checked=""
data-testid="desktopNotification-all"
id="desktopNotification-all"
name="desktopNotification-all"
name="desktop"
type="radio"
value="all"
/>
@ -2584,7 +2614,7 @@ Object {
<input
data-testid="desktopNotification-mention"
id="desktopNotification-mention"
name="desktopNotification-mention"
name="desktop"
type="radio"
value="mention"
/>
@ -2596,7 +2626,7 @@ Object {
<input
data-testid="desktopNotification-none"
id="desktopNotification-none"
name="desktopNotification-none"
name="desktop"
type="radio"
value="none"
/>

View File

@ -2,7 +2,7 @@
// See LICENSE.txt for license information.
import React from 'react';
import {FormattedMessage} from 'react-intl';
import {defineMessage, FormattedMessage} from 'react-intl';
import type {FieldsetCheckbox} from 'components/widgets/modals/components/checkbox_setting_item';
import type {FieldsetRadio} from 'components/widgets/modals/components/radio_setting_item';
@ -41,8 +41,12 @@ export const AutoFollowThreadsInputFieldData: FieldsetCheckbox = {
dataTestId: 'autoFollowThreads',
};
export const desktopNotificationInputFieldData = (defaultOption: string): FieldsetRadio => {
return {
const defaultMessage = defineMessage({
id: 'channel_notifications.default',
defaultMessage: '(default)',
});
export const desktopNotificationInputFieldData = (defaultOption: string): FieldsetRadio => ({
options: [
{
dataTestId: `desktopNotification-${NotificationLevels.ALL}`,
@ -53,13 +57,12 @@ export const desktopNotificationInputFieldData = (defaultOption: string): Fields
values={{
optionalDefault: defaultOption === NotificationLevels.ALL ? (
<FormattedMessage
id='channel_notifications.default'
defaultMessage='(default)'
{...defaultMessage}
/>) : undefined,
}}
/>
),
name: `desktopNotification-${NotificationLevels.ALL}`,
name: 'desktop',
key: `desktopNotification-${NotificationLevels.ALL}`,
value: NotificationLevels.ALL,
},
@ -72,13 +75,12 @@ export const desktopNotificationInputFieldData = (defaultOption: string): Fields
values={{
optionalDefault: defaultOption === NotificationLevels.MENTION ? (
<FormattedMessage
id='channel_notifications.default'
defaultMessage='(default)'
{...defaultMessage}
/>) : undefined,
}}
/>
),
name: `desktopNotification-${NotificationLevels.MENTION}`,
name: 'desktop',
key: `desktopNotification-${NotificationLevels.MENTION}`,
value: NotificationLevels.MENTION,
},
@ -91,19 +93,18 @@ export const desktopNotificationInputFieldData = (defaultOption: string): Fields
values={{
optionalDefault: defaultOption === NotificationLevels.NONE ? (
<FormattedMessage
id='channel_notifications.default'
defaultMessage='(default)'
{...defaultMessage}
/>) : undefined,
}}
/>
),
name: `desktopNotification-${NotificationLevels.NONE}`,
name: 'desktop',
key: `desktopNotification-${NotificationLevels.NONE}`,
value: NotificationLevels.NONE,
},
],
};
};
}
);
export const desktopNotificationSoundsCheckboxFieldData: FieldsetCheckbox = {
name: 'desktopNotificationSoundsCheckbox',
@ -116,8 +117,7 @@ export const desktopNotificationSoundsSelectFieldData: FieldsetReactSelect = {
options: optionsOfMessageNotificationSoundsSelect,
};
export const mobileNotificationInputFieldData = (defaultOption: string): FieldsetRadio => {
return {
export const mobileNotificationInputFieldData = (defaultOption: string): FieldsetRadio => ({
options: [
{
dataTestId: `MobileNotification-${NotificationLevels.ALL}`,
@ -128,13 +128,12 @@ export const mobileNotificationInputFieldData = (defaultOption: string): Fieldse
values={{
optionalDefault: defaultOption === NotificationLevels.ALL ? (
<FormattedMessage
id='channel_notifications.default'
defaultMessage='(default)'
{...defaultMessage}
/>) : undefined,
}}
/>
),
name: `MobileNotification-${NotificationLevels.ALL}`,
name: 'push',
key: `MobileNotification-${NotificationLevels.ALL}`,
value: NotificationLevels.ALL,
},
@ -142,18 +141,18 @@ export const mobileNotificationInputFieldData = (defaultOption: string): Fieldse
dataTestId: `MobileNotification-${NotificationLevels.MENTION}`,
title: (
<FormattedMessage
id='channelNotifications.mobileNotification.mention'
defaultMessage='Mentions, direct messages, and keywords only {optionalDefault}'
values={{
optionalDefault: defaultOption === NotificationLevels.MENTION ? (
<FormattedMessage
id='channel_notifications.default'
defaultMessage='(default)'
{...defaultMessage}
/>) : undefined,
}}
/>
),
name: `MobileNotification-${NotificationLevels.MENTION}`,
name: 'push',
key: `MobileNotification-${NotificationLevels.MENTION}`,
value: NotificationLevels.MENTION,
},
@ -166,19 +165,18 @@ export const mobileNotificationInputFieldData = (defaultOption: string): Fieldse
values={{
optionalDefault: defaultOption === NotificationLevels.NONE ? (
<FormattedMessage
id='channel_notifications.default'
defaultMessage='(default)'
{...defaultMessage}
/>) : undefined,
}}
/>
),
name: `MobileNotification-${NotificationLevels.NONE}`,
name: 'push',
key: `MobileNotification-${NotificationLevels.NONE}`,
value: NotificationLevels.NONE,
},
],
};
};
}
);
export default {
desktopNotificationInputFieldData,

View File

@ -54,7 +54,12 @@ function RadioSettingItem({
});
const content = (
<fieldset className='mm-modal-generic-section-item__fieldset-radio'>
<fieldset
className='mm-modal-generic-section-item__fieldset-radio'
>
<legend className='hidden-label'>
{title}
</legend>
{[...fields]}
</fieldset>
);