diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope.test.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope.test.tsx index cca776af15647..d836b8255bf77 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope.test.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope.test.tsx @@ -82,7 +82,6 @@ describe('FilterScope', () => { it('select tree values with 1 excluded', async () => { render(); fireEvent.click(screen.getByText('Scoping')); - fireEvent.click(screen.getByLabelText('Apply to specific panels')); expect(screen.getByRole('tree')).toBeInTheDocument(); fireEvent.click(getTreeSwitcher(2)); fireEvent.click(screen.getByText('CHART_ID2')); @@ -99,7 +98,6 @@ describe('FilterScope', () => { it('select 1 value only', async () => { render(); fireEvent.click(screen.getByText('Scoping')); - fireEvent.click(screen.getByLabelText('Apply to specific panels')); expect(screen.getByRole('tree')).toBeInTheDocument(); fireEvent.click(getTreeSwitcher(2)); fireEvent.click(screen.getByText('CHART_ID2')); @@ -124,7 +122,6 @@ describe('FilterScope', () => { />, ); fireEvent.click(screen.getByText('Scoping')); - fireEvent.click(screen.getByLabelText('Apply to specific panels')); await waitFor(() => { expect(screen.getByRole('tree')).toBeInTheDocument(); diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope.tsx index 682894acc294c..d175f50bccf88 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope.tsx @@ -17,13 +17,11 @@ * under the License. */ -import { FC, useCallback, useEffect, useMemo, useRef, useState } from 'react'; -import { NativeFilterScope, styled, t } from '@superset-ui/core'; -import { Radio } from 'src/components/Radio'; -import { AntdForm, Typography } from 'src/components'; -import { ScopingType } from './types'; +import { FC, useCallback, useEffect, useMemo, useState } from 'react'; +import { NativeFilterScope, styled } from '@superset-ui/core'; +import { AntdForm } from 'src/components'; import ScopingTree from './ScopingTree'; -import { getDefaultScopeValue, isScopingAll } from './utils'; +import { getDefaultScopeValue } from './utils'; type FilterScopeProps = { pathToFormValue?: string[]; @@ -31,7 +29,6 @@ type FilterScopeProps = { formFilterScope?: NativeFilterScope; forceUpdate: Function; filterScope?: NativeFilterScope; - formScopingType?: ScopingType; chartId?: number; initiallyExcludedCharts?: number[]; }; @@ -51,7 +48,6 @@ const CleanFormItem = styled(AntdForm.Item)` const FilterScope: FC = ({ pathToFormValue = [], - formScopingType, formFilterScope, forceUpdate, filterScope, @@ -63,25 +59,14 @@ const FilterScope: FC = ({ () => filterScope || getDefaultScopeValue(chartId, initiallyExcludedCharts), [chartId, filterScope, initiallyExcludedCharts], ); - const lastSpecificScope = useRef(initialFilterScope); - const initialScopingType = useMemo( - () => - isScopingAll(initialFilterScope, chartId) - ? ScopingType.All - : ScopingType.Specific, - [chartId, initialFilterScope], - ); const [hasScopeBeenModified, setHasScopeBeenModified] = useState(false); const onUpdateFormValues = useCallback( (formValues: any) => { - if (formScopingType === ScopingType.Specific) { - lastSpecificScope.current = formValues.scope; - } updateFormValues(formValues); setHasScopeBeenModified(true); }, - [formScopingType, updateFormValues], + [updateFormValues], ); const updateScopes = useCallback( @@ -98,49 +83,20 @@ const FilterScope: FC = ({ useEffect(() => { const updatedFormValues = { scope: initialFilterScope, - scoping: initialScopingType, }; updateScopes(updatedFormValues); - }, [initialFilterScope, initialScopingType, updateScopes]); + }, [initialFilterScope, updateScopes]); return ( - - { - const scope = - value === ScopingType.All - ? getDefaultScopeValue(chartId) - : lastSpecificScope.current; - updateFormValues({ scope }); - setHasScopeBeenModified(true); - forceUpdate(); - }} - > - {t('Apply to all panels')} - - {t('Apply to specific panels')} - - - - - {(formScopingType ?? initialScopingType) === ScopingType.Specific - ? t('Only selected panels will be affected by this filter') - : t('All panels with this column will be affected by this filter')} - - {(formScopingType ?? initialScopingType) === ScopingType.Specific && ( - - )} +