From e5b7040cced7079c4306a82459b4a279b0cff422 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt Date: Wed, 9 Feb 2022 12:08:29 +0200 Subject: [PATCH] rename Scope and Target --- .../superset-ui-core/src/dashboard/types/Base.ts | 8 ++++---- .../CrossFilterScopingForm/index.tsx | 4 ++-- .../components/CrossFilterScopingModal/types.ts | 4 ++-- .../FiltersConfigForm/FilterScope/FilterScope.tsx | 6 +++--- .../FiltersConfigForm/FilterScope/ScopingTree.tsx | 6 +++--- .../FiltersConfigForm/FilterScope/utils.ts | 13 ++++++++----- .../nativeFilters/FiltersConfigModal/types.ts | 4 ++-- .../nativeFilters/FiltersConfigModal/utils.ts | 4 ++-- superset-frontend/src/dashboard/reducers/types.ts | 4 ++-- .../src/dashboard/util/activeAllDashboardFilters.ts | 4 ++-- 10 files changed, 30 insertions(+), 27 deletions(-) diff --git a/superset-frontend/packages/superset-ui-core/src/dashboard/types/Base.ts b/superset-frontend/packages/superset-ui-core/src/dashboard/types/Base.ts index a3927af78e9ed..fbd631d259145 100644 --- a/superset-frontend/packages/superset-ui-core/src/dashboard/types/Base.ts +++ b/superset-frontend/packages/superset-ui-core/src/dashboard/types/Base.ts @@ -24,13 +24,13 @@ export interface NativeFilterColumn { displayName?: string; } -export interface Scope { +export interface NativeFilterScope { rootPath: string[]; excluded: number[]; } /** The target of a filter is the datasource/column being filtered */ -export interface Target { +export interface NativeFilterTarget { datasetId: number; column: NativeFilterColumn; @@ -70,11 +70,11 @@ export interface Filter { defaultDataMask: DataMask; id: string; // randomly generated at filter creation name: string; - scope: Scope; + scope: NativeFilterScope; filterType: string; // for now there will only ever be one target // when multiple targets are supported, change this to Target[] - targets: [Partial]; + targets: [Partial]; controlValues: { [key: string]: any; }; diff --git a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/index.tsx b/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/index.tsx index 7d7d510d83beb..7ef5a5e9c2d7c 100644 --- a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/index.tsx +++ b/superset-frontend/src/dashboard/components/CrossFilterScopingModal/CrossFilterScopingForm/index.tsx @@ -18,7 +18,7 @@ */ import React, { FC } from 'react'; import { FormInstance } from 'antd/lib/form'; -import { Scope } from '@superset-ui/core'; +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'; @@ -26,7 +26,7 @@ import { CrossFilterScopingFormType } from 'src/dashboard/components/CrossFilter type CrossFilterScopingFormProps = { chartId: number; - scope: Scope; + scope: NativeFilterScope; form: FormInstance; }; diff --git a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/types.ts b/superset-frontend/src/dashboard/components/CrossFilterScopingModal/types.ts index 6dadba9f8cd33..6dfd11f95bb54 100644 --- a/superset-frontend/src/dashboard/components/CrossFilterScopingModal/types.ts +++ b/superset-frontend/src/dashboard/components/CrossFilterScopingModal/types.ts @@ -17,8 +17,8 @@ * under the License. */ -import { Scope } from '@superset-ui/core'; +import { NativeFilterScope } from '@superset-ui/core'; export type CrossFilterScopingFormType = { - scope: Scope; + scope: NativeFilterScope; }; 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 bf69a920639d1..877e43fdf7502 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 @@ -18,7 +18,7 @@ */ import React, { FC, useCallback, useState } from 'react'; -import { Scope, styled, t } from '@superset-ui/core'; +import { NativeFilterScope, styled, t } from '@superset-ui/core'; import { Radio } from 'src/components/Radio'; import { Form, Typography } from 'src/common/components'; import { useComponentDidUpdate } from 'src/hooks/useComponentDidUpdate/useComponentDidUpdate'; @@ -29,9 +29,9 @@ import { getDefaultScopeValue, isScopingAll } from './utils'; type FilterScopeProps = { pathToFormValue?: string[]; updateFormValues: (values: any) => void; - formFilterScope?: Scope; + formFilterScope?: NativeFilterScope; forceUpdate: Function; - filterScope?: Scope; + filterScope?: NativeFilterScope; formScopingType?: ScopingType; chartId?: number; initiallyExcludedCharts?: number[]; diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/ScopingTree.tsx b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/ScopingTree.tsx index e4ff0e53ddcf9..713eb95e7a796 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/ScopingTree.tsx +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/ScopingTree.tsx @@ -18,7 +18,7 @@ */ import React, { FC, useMemo, useState } from 'react'; -import { Scope } from '@superset-ui/core'; +import { NativeFilterScope } from '@superset-ui/core'; import { Tree } from 'src/common/components'; import { DASHBOARD_ROOT_ID } from 'src/dashboard/util/constants'; import { Tooltip } from 'src/components/Tooltip'; @@ -29,8 +29,8 @@ import { findFilterScope, getTreeCheckedItems } from './utils'; type ScopingTreeProps = { forceUpdate: Function; updateFormValues: (values: any) => void; - formScope?: Scope; - initialScope: Scope; + formScope?: NativeFilterScope; + initialScope: NativeFilterScope; chartId?: number; initiallyExcludedCharts?: number[]; }; diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/utils.ts b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/utils.ts index 193f31efec67d..4bf04c7e957bf 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/utils.ts +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/utils.ts @@ -23,7 +23,7 @@ import { TAB_TYPE, } from 'src/dashboard/util/componentTypes'; import { DASHBOARD_ROOT_ID } from 'src/dashboard/util/constants'; -import { Scope, t } from '@superset-ui/core'; +import { NativeFilterScope, t } from '@superset-ui/core'; import { BuildTreeLeafTitle, TreeItem } from './types'; export const isShowTypeInTree = ({ type, meta }: LayoutItem, charts?: Charts) => @@ -113,7 +113,10 @@ const checkTreeItem = ( }); }; -export const getTreeCheckedItems = (scope: Scope, layout: Layout) => { +export const getTreeCheckedItems = ( + scope: NativeFilterScope, + layout: Layout, +) => { const checkedItems: string[] = []; checkTreeItem(checkedItems, layout, [...scope.rootPath], [...scope.excluded]); return [...new Set(checkedItems)]; @@ -123,7 +126,7 @@ export const getTreeCheckedItems = (scope: Scope, layout: Layout) => { export const findFilterScope = ( checkedKeys: string[], layout: Layout, -): Scope => { +): NativeFilterScope => { if (!checkedKeys.length) { return { rootPath: [], @@ -169,14 +172,14 @@ export const findFilterScope = ( export const getDefaultScopeValue = ( chartId?: number, initiallyExcludedCharts: number[] = [], -): Scope => ({ +): NativeFilterScope => ({ rootPath: [DASHBOARD_ROOT_ID], excluded: chartId ? [chartId, ...initiallyExcludedCharts] : initiallyExcludedCharts, }); -export const isScopingAll = (scope: Scope, chartId?: number) => +export const isScopingAll = (scope: NativeFilterScope, chartId?: number) => !scope || (scope.rootPath[0] === DASHBOARD_ROOT_ID && !scope.excluded.filter(item => item !== chartId).length); diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/types.ts b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/types.ts index 13351ce4af77a..42daba882214c 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/types.ts +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/types.ts @@ -20,11 +20,11 @@ import { AdhocFilter, DataMask, NativeFilterType, - Scope, + NativeFilterScope, } from '@superset-ui/core'; export interface NativeFiltersFormItem { - scope: Scope; + scope: NativeFilterScope; name: string; filterType: string; dataset: { diff --git a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts index 007dfe1bc2cc9..b6edd9fd024aa 100644 --- a/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts +++ b/superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/utils.ts @@ -26,7 +26,7 @@ import { NativeFilterType, Divider, t, - Target, + NativeFilterTarget, } from '@superset-ui/core'; import { DASHBOARD_ROOT_ID } from 'src/dashboard/util/constants'; import { @@ -156,7 +156,7 @@ export const createHandleSave = description: formInputs.description, }; } - const target: Partial = {}; + const target: Partial = {}; if (formInputs.dataset) { target.datasetId = formInputs.dataset.value; } diff --git a/superset-frontend/src/dashboard/reducers/types.ts b/superset-frontend/src/dashboard/reducers/types.ts index 8044600b9658d..c1c723cf01793 100644 --- a/superset-frontend/src/dashboard/reducers/types.ts +++ b/superset-frontend/src/dashboard/reducers/types.ts @@ -18,7 +18,7 @@ */ import componentTypes from 'src/dashboard/util/componentTypes'; -import { Scope, JsonObject } from '@superset-ui/core'; +import { NativeFilterScope, JsonObject } from '@superset-ui/core'; export enum Scoping { All = 'All', @@ -29,7 +29,7 @@ export type ChartConfiguration = { [chartId: number]: { id: number; crossFilters: { - scope: Scope; + scope: NativeFilterScope; }; }; }; diff --git a/superset-frontend/src/dashboard/util/activeAllDashboardFilters.ts b/superset-frontend/src/dashboard/util/activeAllDashboardFilters.ts index 7d037f154fbf9..f0a9b709ee5db 100644 --- a/superset-frontend/src/dashboard/util/activeAllDashboardFilters.ts +++ b/superset-frontend/src/dashboard/util/activeAllDashboardFilters.ts @@ -20,7 +20,7 @@ import { DataMaskStateWithId, Filters, JsonObject, - Scope, + NativeFilterScope, } from '@superset-ui/core'; import { CHART_TYPE } from './componentTypes'; import { ActiveFilters, Layout, LayoutItem } from '../types'; @@ -38,7 +38,7 @@ export const findAffectedCharts = ({ }: { child: string; layout: { [key: string]: LayoutItem }; - scope: Scope; + scope: NativeFilterScope; activeFilters: ActiveFilters; filterId: string; extraFormData: any;