You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2023/02/27 14:07:25 UTC

[superset] 01/05: Remove scoping modal

This is an automated email from the ASF dual-hosted git repository.

diegopucci pushed a commit to branch chore/rm-cross-filter-scoping
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 98bb1e9a1d04d9ba18b152f32fe26ad6e8cdea6b
Author: geido <di...@gmail.com>
AuthorDate: Mon Feb 27 10:07:29 2023 +0100

    Remove scoping modal
---
 .../CrossFilterScopingForm.test.tsx                |  60 -----------
 .../CrossFilterScopingForm/index.tsx               |  57 -----------
 .../CrossFilterScopingModal.tsx                    | 112 ---------------------
 .../components/CrossFilterScopingModal/types.ts    |  24 -----
 .../CrossFilterScopingModal/utils/index.ts         |  29 ------
 .../CrossFilterScopingModal/utils/utils.test.ts    |  34 -------
 .../components/SliceHeaderControls/index.tsx       |  23 -----
 7 files changed, 339 deletions(-)

diff --git a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/CrossFilterScopingForm.test.tsx b/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/CrossFilterScopingForm.test.tsx
deleted file mode 100644
index f1093e2a9e..0000000000
--- a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/CrossFilterScopingForm.test.tsx
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import React from 'react';
-import { render } from 'spec/helpers/testing-library';
-import FilterScope from 'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope';
-import CrossFilterScopingForm from '.';
-
-jest.mock(
-  'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope',
-  () => jest.fn(() => null),
-);
-
-const createProps = () => {
-  const getFieldValue = jest.fn();
-  getFieldValue.mockImplementation(name => name);
-  return {
-    chartId: 123,
-    scope: 'Scope',
-    form: { getFieldValue },
-  };
-};
-
-test('Should send correct props', () => {
-  const props = createProps();
-  render(<CrossFilterScopingForm {...(props as any)} />);
-
-  expect(FilterScope).toHaveBeenCalledWith(
-    expect.objectContaining({
-      chartId: 123,
-      filterScope: 'Scope',
-      formFilterScope: 'scope',
-      formScopingType: 'scoping',
-    }),
-    {},
-  );
-});
-
-test('Should get correct fields', () => {
-  const props = createProps();
-  render(<CrossFilterScopingForm {...(props as any)} />);
-  expect(props.form.getFieldValue).toBeCalledTimes(2);
-  expect(props.form.getFieldValue).toHaveBeenNthCalledWith(1, 'scope');
-  expect(props.form.getFieldValue).toHaveBeenNthCalledWith(2, 'scoping');
-});
diff --git a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/index.tsx b/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/index.tsx
deleted file mode 100644
index b0d138cc96..0000000000
--- a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/index.tsx
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import React, { FC } from 'react';
-import { FormInstance } from 'src/components';
-import { NativeFilterScope } from '@superset-ui/core';
-import FilterScope from 'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/FilterScope';
-import { setCrossFilterFieldValues } from 'src/dashboard/components/CrossFilterScopingModal/utils';
-import { useForceUpdate } from 'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils';
-import { CrossFilterScopingFormType } from 'src/dashboard/components/CrossFilterScopingModal/types';
-
-type CrossFilterScopingFormProps = {
-  chartId: number;
-  scope: NativeFilterScope;
-  form: FormInstance<CrossFilterScopingFormType>;
-};
-
-const CrossFilterScopingForm: FC<CrossFilterScopingFormProps> = ({
-  form,
-  scope,
-  chartId,
-}) => {
-  const forceUpdate = useForceUpdate();
-  const formScope = form.getFieldValue('scope');
-  const formScoping = form.getFieldValue('scoping');
-  return (
-    <FilterScope
-      updateFormValues={(values: any) => {
-        setCrossFilterFieldValues(form, {
-          ...values,
-        });
-      }}
-      filterScope={scope}
-      chartId={chartId}
-      formFilterScope={formScope}
-      forceUpdate={forceUpdate}
-      formScopingType={formScoping}
-    />
-  );
-};
-
-export default CrossFilterScopingForm;
diff --git a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingModal.tsx b/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingModal.tsx
deleted file mode 100644
index cdd9364b4b..0000000000
--- a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingModal.tsx
+++ /dev/null
@@ -1,112 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import { t } from '@superset-ui/core';
-import React, { FC } from 'react';
-import { useDispatch, useSelector } from 'react-redux';
-import { StyledModal } from 'src/components/Modal';
-import Button from 'src/components/Button';
-import { AntdForm } from 'src/components';
-import { setChartConfiguration } from 'src/dashboard/actions/dashboardInfo';
-import { ChartConfiguration } from 'src/dashboard/reducers/types';
-import { ChartsState, Layout, RootState } from 'src/dashboard/types';
-import { getChartIdsInFilterScope } from 'src/dashboard/util/getChartIdsInFilterScope';
-import CrossFilterScopingForm from './CrossFilterScopingForm';
-import { CrossFilterScopingFormType } from './types';
-import { StyledForm } from '../nativeFilters/FiltersConfigModal/FiltersConfigModal';
-
-type CrossFilterScopingModalProps = {
-  chartId: number;
-  isOpen: boolean;
-  onClose: () => void;
-};
-
-const CrossFilterScopingModal: FC<CrossFilterScopingModalProps> = ({
-  isOpen,
-  chartId,
-  onClose,
-}) => {
-  const dispatch = useDispatch();
-  const [form] = AntdForm.useForm<CrossFilterScopingFormType>();
-  const chartConfig = useSelector<any, ChartConfiguration>(
-    ({ dashboardInfo }) => dashboardInfo?.metadata?.chart_configuration,
-  );
-  const charts = useSelector<RootState, ChartsState>(state => state.charts);
-  const layout = useSelector<RootState, Layout>(
-    state => state.dashboardLayout.present,
-  );
-  const scope = chartConfig?.[chartId]?.crossFilters?.scope;
-  const handleSave = () => {
-    const chartsInScope = getChartIdsInFilterScope(
-      form.getFieldValue('scope'),
-      charts,
-      layout,
-    );
-
-    dispatch(
-      setChartConfiguration({
-        ...chartConfig,
-        [chartId]: {
-          id: chartId,
-          crossFilters: { scope: form.getFieldValue('scope'), chartsInScope },
-        },
-      }),
-    );
-    onClose();
-  };
-
-  return (
-    <StyledModal
-      visible={isOpen}
-      maskClosable={false}
-      title={t('Cross Filter Scoping')}
-      width="55%"
-      destroyOnClose
-      onCancel={onClose}
-      onOk={handleSave}
-      centered
-      data-test="cross-filter-scoping-modal"
-      footer={
-        <>
-          <Button
-            key="cancel"
-            buttonStyle="secondary"
-            data-test="cross-filter-scoping-modal-cancel-button"
-            onClick={onClose}
-          >
-            {t('Cancel')}
-          </Button>
-          <Button
-            key="submit"
-            buttonStyle="primary"
-            onClick={handleSave}
-            data-test="cross-filter-scoping-modal-save-button"
-          >
-            {t('Save')}
-          </Button>
-        </>
-      }
-    >
-      <StyledForm preserve={false} form={form} layout="vertical">
-        <CrossFilterScopingForm form={form} scope={scope} chartId={chartId} />
-      </StyledForm>
-    </StyledModal>
-  );
-};
-
-export default CrossFilterScopingModal;
diff --git a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/types.ts b/superset-frontend/src/dashboard/components/CrossFilterScopingModal/types.ts
deleted file mode 100644
index 6dfd11f95b..0000000000
--- a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/types.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { NativeFilterScope } from '@superset-ui/core';
-
-export type CrossFilterScopingFormType = {
-  scope: NativeFilterScope;
-};
diff --git a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/utils/index.ts b/superset-frontend/src/dashboard/components/CrossFilterScopingModal/utils/index.ts
deleted file mode 100644
index e3eaf3e0c8..0000000000
--- a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/utils/index.ts
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-import { FormInstance } from 'src/components';
-
-// eslint-disable-next-line import/prefer-default-export
-export const setCrossFilterFieldValues = (
-  form: FormInstance,
-  values: object,
-) => {
-  form.setFieldsValue({
-    ...values,
-  });
-};
diff --git a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/utils/utils.test.ts b/superset-frontend/src/dashboard/components/CrossFilterScopingModal/utils/utils.test.ts
deleted file mode 100644
index edc4fde937..0000000000
--- a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/utils/utils.test.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { setCrossFilterFieldValues } from '.';
-
-test('setValues', () => {
-  const from = { setFieldsValue: jest.fn() };
-  const values = {
-    val01: 'val01',
-    val02: 'val02',
-    val03: 'val03',
-    val04: 'val04',
-  };
-  setCrossFilterFieldValues(from as any, values);
-
-  expect(from.setFieldsValue).toBeCalledTimes(1);
-  expect(from.setFieldsValue).toBeCalledWith(values);
-});
diff --git a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx
index 4037234f74..6604093935 100644
--- a/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx
+++ b/superset-frontend/src/dashboard/components/SliceHeaderControls/index.tsx
@@ -44,7 +44,6 @@ import { NoAnimationDropdown } from 'src/components/Dropdown';
 import ShareMenuItems from 'src/dashboard/components/menu/ShareMenuItems';
 import downloadAsImage from 'src/utils/downloadAsImage';
 import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags';
-import CrossFilterScopingModal from 'src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingModal';
 import { getSliceHeaderTooltip } from 'src/dashboard/util/getSliceHeaderTooltip';
 import { Tooltip } from 'src/components/Tooltip';
 import Icons from 'src/components/Icons';
@@ -57,7 +56,6 @@ import { DrillDetailMenuItems } from 'src/components/Chart/DrillDetail';
 import { LOG_ACTIONS_CHART_DOWNLOAD_AS_IMAGE } from 'src/logger/LogUtils';
 
 const MENU_KEYS = {
-  CROSS_FILTER_SCOPING: 'cross_filter_scoping',
   DOWNLOAD_AS_IMAGE: 'download_as_image',
   EXPLORE_CHART: 'explore_chart',
   EXPORT_CSV: 'export_csv',
@@ -157,7 +155,6 @@ type SliceHeaderControlsPropsWithRouter = SliceHeaderControlsProps &
   RouteComponentProps;
 interface State {
   showControls: boolean;
-  showCrossFilterScopingModal: boolean;
 }
 
 const dropdownIconsStyles = css`
@@ -256,7 +253,6 @@ class SliceHeaderControls extends React.PureComponent<
 
     this.state = {
       showControls: false,
-      showCrossFilterScopingModal: false,
     };
   }
 
@@ -287,9 +283,6 @@ class SliceHeaderControls extends React.PureComponent<
         this.refreshChart();
         this.props.addSuccessToast(t('Data refreshed'));
         break;
-      case MENU_KEYS.CROSS_FILTER_SCOPING:
-        this.setState({ showCrossFilterScopingModal: true });
-        break;
       case MENU_KEYS.TOGGLE_CHART_DESCRIPTION:
         // eslint-disable-next-line no-unused-expressions
         this.props.toggleExpandSlice?.(this.props.slice.slice_id);
@@ -477,17 +470,6 @@ class SliceHeaderControls extends React.PureComponent<
           <Menu.Divider />
         )}
 
-        {isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS) &&
-          isCrossFilter &&
-          crossFiltersEnabled && (
-            <>
-              <Menu.Item key={MENU_KEYS.CROSS_FILTER_SCOPING}>
-                {t('Cross-filter scoping')}
-              </Menu.Item>
-              <Menu.Divider />
-            </>
-          )}
-
         {supersetCanShare && (
           <Menu.SubMenu title={t('Share')}>
             <ShareMenuItems
@@ -538,11 +520,6 @@ class SliceHeaderControls extends React.PureComponent<
 
     return (
       <>
-        <CrossFilterScopingModal
-          chartId={slice.slice_id}
-          isOpen={this.state.showCrossFilterScopingModal}
-          onClose={() => this.setState({ showCrossFilterScopingModal: false })}
-        />
         {isFullSize && (
           <Icons.FullscreenExitOutlined
             style={{ fontSize: 22 }}