refactor(Radio): Upgrade Radio Component to Ant Design 5 (#32004)

This commit is contained in:
Enzo Martellucci
2025-01-31 17:45:06 +01:00
committed by GitHub
parent 1c1494d3e0
commit 468bb5f47a
17 changed files with 293 additions and 199 deletions

View File

@@ -41,7 +41,7 @@ import TimezoneSelector from 'src/components/TimezoneSelector';
import LabeledErrorBoundInput from 'src/components/Form/LabeledErrorBoundInput';
import Icons from 'src/components/Icons';
import { CronError } from 'src/components/CronPicker';
import { RadioChangeEvent } from 'src/components';
import { Radio, RadioChangeEvent } from 'src/components/Radio';
import { Input } from 'src/components/Input';
import withToasts from 'src/components/MessageToasts/withToasts';
import { ChartState } from 'src/explore/types';
@@ -68,8 +68,6 @@ import {
TimezoneHeaderStyle,
SectionHeaderStyle,
StyledMessageContentTitle,
StyledRadio,
StyledRadioGroup,
} from './styles';
interface ReportProps {
@@ -257,24 +255,32 @@ function ReportModal({
<h4>{t('Message content')}</h4>
</StyledMessageContentTitle>
<div className="inline-container">
<StyledRadioGroup
<Radio.GroupWrapper
spaceConfig={{
direction: 'vertical',
size: 'middle',
align: 'start',
wrap: false,
}}
onChange={(event: RadioChangeEvent) => {
setCurrentReport({ report_format: event.target.value });
}}
value={currentReport.report_format || defaultNotificationFormat}
>
{isTextBasedChart && (
<StyledRadio value={NotificationFormats.Text}>
{t('Text embedded in email')}
</StyledRadio>
)}
<StyledRadio value={NotificationFormats.PNG}>
{t('Image (PNG) embedded in email')}
</StyledRadio>
<StyledRadio value={NotificationFormats.CSV}>
{t('Formatted CSV attached in email')}
</StyledRadio>
</StyledRadioGroup>
options={[
{
label: t('Text embedded in email'),
value: NotificationFormats.Text,
},
{
label: t('Image (PNG) embedded in email'),
value: NotificationFormats.PNG,
},
{
label: t('Formatted CSV attached in email'),
value: NotificationFormats.CSV,
},
]}
/>
</div>
</>
);

View File

@@ -108,10 +108,6 @@ export const StyledRadio = styled(Radio)`
line-height: ${({ theme }) => theme.gridUnit * 8}px;
`;
export const StyledRadioGroup = styled(Radio.Group)`
margin-left: ${({ theme }) => theme.gridUnit * 0.5}px;
`;
export const antDErrorAlertStyles = (theme: SupersetTheme) => css`
margin: ${theme.gridUnit * 4}px;
margin-top: 0;