diff --git a/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx b/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx index 3b305178538e8..12d186a25f42a 100644 --- a/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx +++ b/superset-frontend/src/components/Chart/DrillBy/useDisplayModeToggle.tsx @@ -19,17 +19,14 @@ import { useMemo, useState } from 'react'; import { css, SupersetTheme, t } from '@superset-ui/core'; -import { Radio, CheckboxOptionType } from 'src/components/Radio'; +import { Radio } from 'src/components/Radio'; import { DrillByType } from '../types'; export const useDisplayModeToggle = () => { const [drillByDisplayMode, setDrillByDisplayMode] = useState( DrillByType.Chart, ); - const customButtons: CheckboxOptionType[] = [ - { label: t('Chart'), value: DrillByType.Chart }, - { label: t('Table'), value: DrillByType.Table }, - ]; + const displayModeToggle = useMemo( () => (
{ setDrillByDisplayMode(value); }} defaultValue={DrillByType.Chart} - options={customButtons} - value={drillByDisplayMode} + options={[ + { label: t('Chart'), value: DrillByType.Chart }, + { label: t('Table'), value: DrillByType.Table }, + ]} optionType="button" buttonStyle="outline" />
), - [drillByDisplayMode], + [], ); return { displayModeToggle, drillByDisplayMode }; }; diff --git a/superset-frontend/src/components/Radio/Radio.stories.tsx b/superset-frontend/src/components/Radio/Radio.stories.tsx index 8a697d6ca109f..4329322b40923 100644 --- a/superset-frontend/src/components/Radio/Radio.stories.tsx +++ b/superset-frontend/src/components/Radio/Radio.stories.tsx @@ -32,10 +32,18 @@ export default { }; const RadioArgsType = { - onChange: { action: 'changed' }, - checked: { control: 'boolean' }, - disabled: { control: 'boolean' }, - defaultChecked: { control: 'boolean' }, + value: { + control: 'text', + description: 'The value of the radio button.', + }, + disabled: { + control: 'boolean', + description: 'Whether the radio button is disabled or not.', + }, + checked: { + control: 'boolean', + description: 'The checked state of the radio button.', + }, }; const radioGroupWrapperArgsType = { @@ -64,14 +72,20 @@ const radioGroupWrapperArgsType = { description: 'Alignment of the Space layout', if: { arg: 'enableSpaceConfig', truthy: true }, }, + 'spaceConfig.wrap': { + control: 'boolean', + description: + 'Controls whether the items inside the Space component should wrap to the next line when space is insufficient', + if: { arg: 'enableSpaceConfig', truthy: true }, + }, }; export const RadioStory = { args: { - children: 'Radio', value: 'radio1', disabled: false, checked: false, + children: 'Radio', }, argTypes: RadioArgsType, }; @@ -86,27 +100,16 @@ RadioButtonStory.args = { }; RadioButtonStory.argTypes = RadioArgsType; -export const RadioGroupWithCustomRadioStory = ( - args: RadioGroupWrapperProps, -) => ( - - Custom Option 1 - Custom Option 2 - Custom Option 3 - -); -RadioGroupWithCustomRadioStory.args = { - spaceConfig: { direction: 'vertical', size: 'middle', align: 'center' }, - size: 'middle', - disabled: false, -}; -RadioGroupWithCustomRadioStory.argTypes = radioGroupWrapperArgsType; - export const RadioGroupWithOptionsStory = (args: RadioGroupWrapperProps) => ( ); RadioGroupWithOptionsStory.args = { - spaceConfig: { direction: 'vertical', size: 'middle', align: 'center' }, + spaceConfig: { + direction: 'vertical', + size: 'middle', + align: 'center', + wrap: false, + }, size: 'middle', options: [ { diff --git a/superset-frontend/src/components/Radio/index.tsx b/superset-frontend/src/components/Radio/index.tsx index 8740a5aeaffee..9311cdde5ad55 100644 --- a/superset-frontend/src/components/Radio/index.tsx +++ b/superset-frontend/src/components/Radio/index.tsx @@ -32,36 +32,25 @@ export type RadioGroupWrapperProps = RadioGroupProps & { align?: SpaceProps['align']; wrap?: SpaceProps['wrap']; }; - options?: CheckboxOptionType[]; - children?: React.ReactNode; + options: CheckboxOptionType[]; }; const RadioGroup = ({ - spaceConfig = { - direction: 'horizontal', - size: 'middle', - align: 'center', - wrap: false, - }, + spaceConfig, options, - children, ...props }: RadioGroupWrapperProps) => { - const content = options - ? options.map((option: CheckboxOptionType) => ( - - {option.label} - - )) - : children; - + const content = options.map((option: CheckboxOptionType) => ( + + {option.label} + + )); return ( {spaceConfig ? {content} : content} ); }; - export type { RadioChangeEvent, RadioGroupProps, diff --git a/superset-frontend/src/components/Table/header-renderers/HeaderWithRadioGroup.tsx b/superset-frontend/src/components/Table/header-renderers/HeaderWithRadioGroup.tsx index 73c0481baaaea..0626b2da90f3a 100644 --- a/superset-frontend/src/components/Table/header-renderers/HeaderWithRadioGroup.tsx +++ b/superset-frontend/src/components/Table/header-renderers/HeaderWithRadioGroup.tsx @@ -56,7 +56,12 @@ function HeaderWithRadioGroup(props: HeaderWithRadioGroupProps) { {groupTitle} { onChange(e.target.value); diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx index 3c68560c9ecd5..5b843a370b728 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FiltersConfigForm.tsx @@ -1107,14 +1107,15 @@ const FiltersConfigForm = ( label={{t('Sort type')}} > { onSortChanged(value.target.value); formChanged(); }} - > - {t('Sort ascending')} - {t('Sort descending')} - + /> {hasMetrics && ( - - {t('Minimum')} - - - {t('Exact')} - - - {t('Maximum')} - - + options={[ + { + label: t('Minimum'), + value: SingleValueType.Minimum, + }, + { label: t('Exact'), value: SingleValueType.Exact }, + { + label: t('Maximum'), + value: SingleValueType.Maximum, + }, + ]} + /> diff --git a/superset-frontend/src/explore/components/DataTableControl/index.tsx b/superset-frontend/src/explore/components/DataTableControl/index.tsx index bbbeab3c6f732..6c4e54e7cdfc8 100644 --- a/superset-frontend/src/explore/components/DataTableControl/index.tsx +++ b/superset-frontend/src/explore/components/DataTableControl/index.tsx @@ -141,14 +141,20 @@ const FormatPicker = ({ value: FormatPickerValue; }) => ( - {t('Formatted date')} - {t('Original value')} - + options={[ + { label: t('Formatted date'), value: FormatPickerValue.Formatted }, + { label: t('Original value'), value: FormatPickerValue.Original }, + ]} + /> ); const FormatPickerContainer = styled.div` diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CalendarFrame.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CalendarFrame.tsx index a47a6e59fb515..3815f06f5c2d2 100644 --- a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CalendarFrame.tsx +++ b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CalendarFrame.tsx @@ -46,7 +46,12 @@ export function CalendarFrame({ onChange, value }: FrameComponentProps) { {t('Configure Time Range: Previous...')} onChange(e.target.value)} diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CommonFrame.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CommonFrame.tsx index 0268c7583503d..9902f8d2c5403 100644 --- a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CommonFrame.tsx +++ b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CommonFrame.tsx @@ -42,7 +42,12 @@ export function CommonFrame(props: FrameComponentProps) { {t('Configure Time Range: Last...')} props.onChange(e.target.value)} diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CurrentCalendarFrame.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CurrentCalendarFrame.tsx index 73e49cc424e50..1058968b4ee3e 100644 --- a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CurrentCalendarFrame.tsx +++ b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CurrentCalendarFrame.tsx @@ -42,7 +42,12 @@ export function CurrentCalendarFrame({ onChange, value }: FrameComponentProps) { {t('Configure Time Range: Current...')} { let newValue = e.target.value; diff --git a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx index 1d37f0c85a172..969b46855e584 100644 --- a/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx +++ b/superset-frontend/src/explore/components/controls/DateFilterControl/components/CustomFrame.tsx @@ -239,17 +239,14 @@ export function CustomFrame(props: FrameComponentProps) { - - {t('NOW')} - - - {t('Date/Time')} - - + /> {anchorMode !== 'now' && ( diff --git a/superset-frontend/src/features/reports/ReportModal/index.tsx b/superset-frontend/src/features/reports/ReportModal/index.tsx index 14fc3eba005f7..ce49379afcd71 100644 --- a/superset-frontend/src/features/reports/ReportModal/index.tsx +++ b/superset-frontend/src/features/reports/ReportModal/index.tsx @@ -256,24 +256,31 @@ function ReportModal({
{ setCurrentReport({ report_format: event.target.value }); }} value={currentReport.report_format || defaultNotificationFormat} - > - {isTextBasedChart && ( - - {t('Text embedded in email')} - - )} - - {t('Image (PNG) embedded in email')} - - - {t('Formatted CSV attached in email')} - - + 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, + }, + ]} + />
);