Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Dynamic dashboard component #17208

Merged
merged 43 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
6eb04b1
fix:fix get permission function
simcha90 Apr 13, 2021
5e9a1d8
Merge branch 'master' of github.com:apache/superset
simcha90 Apr 18, 2021
2c5800a
Merge branch 'master' of github.com:apache/superset
simcha90 Apr 20, 2021
ea9aa8b
Merge branch 'master' of github.com:apache/superset
simcha90 Apr 25, 2021
402918a
Merge branch 'master' of github.com:apache/superset
simcha90 Apr 27, 2021
1a3cc39
Merge branch 'master' of github.com:apache/superset
simcha90 Apr 28, 2021
f6d4590
Merge branch 'master' of github.com:apache/superset
simcha90 May 10, 2021
97f2c15
Merge branch 'master' of github.com:apache/superset
simcha90 May 24, 2021
1f31df7
Merge branch 'master' of github.com:apache/superset
simcha90 May 24, 2021
dce7b7a
Merge branch 'master' of github.com:apache/superset
simcha90 May 26, 2021
0334f35
Merge branch 'master' of github.com:apache/superset
simcha90 May 30, 2021
f6dd314
Merge branch 'master' of github.com:apache/superset
simcha90 Jun 17, 2021
64267e1
Merge branch 'master' of github.com:apache/superset
simcha90 Jun 20, 2021
385eddc
Merge branch 'master' of github.com:apache/superset
simcha90 Jun 24, 2021
51a00a3
Merge branch 'master' of github.com:apache/superset
simcha90 Jul 1, 2021
4e94cb5
Merge branch 'master' of github.com:apache/superset
simcha90 Jul 4, 2021
e7fa0a6
Merge branch 'master' of github.com:apache/superset
simcha90 Jul 7, 2021
c3d24d7
Merge branch 'master' of github.com:apache/superset
simcha90 Aug 31, 2021
a3893a4
Merge branch 'master' of github.com:apache/superset
simcha90 Sep 29, 2021
30c516b
Merge branch 'master' of github.com:apache/superset
simcha90 Oct 5, 2021
03165d1
Merge branch 'master' of github.com:apache/superset
simcha90 Oct 7, 2021
9d86002
Merge branch 'master' of github.com:apache/superset
simcha90 Oct 17, 2021
57f4a13
feat: dynamic loading of dashboard components
simcha90 Oct 24, 2021
8556f1c
fix: revert image
simcha90 Oct 24, 2021
56a4e2a
fix: fix py
simcha90 Oct 24, 2021
208e275
fix: fix py
simcha90 Oct 24, 2021
e02ada3
Merge branch 'master' of github.com:apache/superset into dynamic_dash…
simcha90 Oct 27, 2021
369afd4
fix: pass state to dynamic component
simcha90 Oct 27, 2021
278303d
Merge branch 'master' of github.com:apache/superset into dynamic_dash…
simcha90 Nov 4, 2021
ccb5853
lint: add typing
simcha90 Dec 20, 2021
7ee2be4
Merge branch 'master' of github.com:apache/superset into dynamic_dash…
simcha90 Dec 20, 2021
4dd7bec
Merge branch 'master' of github.com:apache/superset into dynamic_dash…
simcha90 Dec 30, 2021
94e2d5b
lint: fix lint
simcha90 Dec 30, 2021
eba9e97
lint: fix lint
simcha90 Jan 2, 2022
503eea8
Merge branch 'master' of github.com:apache/superset into dynamic_dash…
simcha90 Jan 2, 2022
e374836
refactor: re-run pipeline
simcha90 Jan 2, 2022
aca538a
fix: fix CR notes
simcha90 Jan 17, 2022
d54bd9d
fix: fix CR notes
simcha90 Jan 17, 2022
26c0d65
Merge branch 'master' of github.com:apache/superset into dynamic_dash…
simcha90 Jan 25, 2022
3108ae0
move types and interfaces to core
villebro Feb 7, 2022
8d5993e
reorder exports
villebro Feb 9, 2022
b65e977
Merge branch 'master' into dynamic_dashboard_component
villebro Feb 9, 2022
e5b7040
rename Scope and Target
villebro Feb 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,5 @@
* specific language governing permissions and limitations
* under the License.
*/
import { DataMask } from '@superset-ui/core';

export enum DataMaskType {
NativeFilters = 'nativeFilters',
CrossFilters = 'crossFilters',
}

export type DataMaskState = { [id: string]: DataMask };

export type DataMaskWithId = { id: string } & DataMask;
export type DataMaskStateWithId = { [filterId: string]: DataMaskWithId };
export * from './types/Base';
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@

import { AdhocFilter, DataMask } from '@superset-ui/core';

export interface Column {
export interface NativeFilterColumn {
name: string;
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: Column;
column: NativeFilterColumn;

// maybe someday support this?
// show values from these columns in the filter options selector
Expand All @@ -44,16 +44,37 @@ export enum NativeFilterType {
DIVIDER = 'DIVIDER',
}

export enum DataMaskType {
NativeFilters = 'nativeFilters',
CrossFilters = 'crossFilters',
}

export type DataMaskState = { [id: string]: DataMask };

export type DataMaskWithId = { id: string } & DataMask;
export type DataMaskStateWithId = { [filterId: string]: DataMaskWithId };

export type FilterSet = {
id: number;
name: string;
nativeFilters: Filters;
dataMask: DataMaskStateWithId;
};

export type FilterSets = {
[filtersSetId: string]: FilterSet;
};

export interface Filter {
cascadeParentIds: string[];
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<Target>];
targets: [Partial<NativeFilterTarget>];
controlValues: {
[key: string]: any;
};
Expand All @@ -70,6 +91,7 @@ export interface Filter {
type: typeof NativeFilterType.NATIVE_FILTER;
description: string;
}

export interface Divider {
id: string;
title: string;
Expand All @@ -78,3 +100,18 @@ export interface Divider {
}

export type FilterConfiguration = Array<Filter | Divider>;

export type Filters = {
[filterId: string]: Filter;
};

export type NativeFiltersState = {
filters: Filters;
filterSets: FilterSets;
focusedFilterId?: string;
};

export type DashboardComponentMetadata = {
nativeFilters: NativeFiltersState;
dataMask: DataMaskStateWithId;
};
2 changes: 2 additions & 0 deletions superset-frontend/packages/superset-ui-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/

export * from './models';
export * from './utils';
export * from './types';
export * from './translation';
export * from './connection';
export * from './dashboard';
export * from './dynamic-plugins';
export * from './query';
export * from './number-format';
Expand Down
10 changes: 6 additions & 4 deletions superset-frontend/spec/fixtures/mockNativeFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
import { ExtraFormData } from '@superset-ui/core';
import { NativeFilterType } from 'src/dashboard/components/nativeFilters/types';
import { NativeFiltersState } from 'src/dashboard/reducers/types';
import { DataMaskStateWithId } from '../../src/dataMask/types';
import {
DataMaskStateWithId,
ExtraFormData,
NativeFiltersState,
NativeFilterType,
} from '@superset-ui/core';

export const nativeFilters: NativeFiltersState = {
filterSets: {},
Expand Down
16 changes: 8 additions & 8 deletions superset-frontend/src/dashboard/actions/nativeFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,21 @@
* under the License.
*/

import { makeApi } from '@superset-ui/core';
import {
FilterConfiguration,
Filters,
FilterSet,
FilterSets,
makeApi,
} from '@superset-ui/core';
import { Dispatch } from 'redux';
import { FilterConfiguration } from 'src/dashboard/components/nativeFilters/types';
import {
SET_DATA_MASK_FOR_FILTER_CONFIG_FAIL,
setDataMaskForFilterConfigComplete,
} from 'src/dataMask/actions';
import { HYDRATE_DASHBOARD } from './hydrate';
import { dashboardInfoChanged } from './dashboardInfo';
import {
Filters,
FilterSet,
FilterSetFullData,
FilterSets,
} from '../reducers/types';
import { FilterSetFullData } from '../reducers/types';
import { DashboardInfo, RootState } from '../types';

export const SET_FILTER_CONFIG_BEGIN = 'SET_FILTER_CONFIG_BEGIN';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import NewRow from './gridComponents/new/NewRow';
import NewTabs from './gridComponents/new/NewTabs';
import NewMarkdown from './gridComponents/new/NewMarkdown';
import SliceAdder from '../containers/SliceAdder';
import dashboardComponents from '../../visualizations/presets/dashboardComponents';
import NewDynamicComponent from './gridComponents/new/NewDynamicComponent';

export interface BCPProps {
isStandalone: boolean;
Expand Down Expand Up @@ -106,6 +108,14 @@ const BuilderComponentPane: React.FC<BCPProps> = ({
<NewHeader />
<NewMarkdown />
<NewDivider />
{dashboardComponents
.getAll()
.map(({ key: componentKey, metadata }) => (
<NewDynamicComponent
metadata={metadata}
componentKey={componentKey}
/>
))}
</Tabs.TabPane>
<Tabs.TabPane
key={2}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
*/
import React, { FC } from 'react';
import { FormInstance } from 'antd/lib/form';
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 { Scope } from 'src/dashboard/components/nativeFilters/types';
import { useForceUpdate } from 'src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils';
import { CrossFilterScopingFormType } from 'src/dashboard/components/CrossFilterScopingModal/types';

type CrossFilterScopingFormProps = {
chartId: number;
scope: Scope;
scope: NativeFilterScope;
form: FormInstance<CrossFilterScopingFormType>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

import { Scope } from '../nativeFilters/types';
import { NativeFilterScope } from '@superset-ui/core';

export type CrossFilterScopingFormType = {
scope: Scope;
scope: NativeFilterScope;
};
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
// when its container size changes, due to e.g., builder side panel opening
import React, { FC, useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { FeatureFlag, isFeatureEnabled } from '@superset-ui/core';
import { FeatureFlag, Filters, isFeatureEnabled } from '@superset-ui/core';
import { ParentSize } from '@vx/responsive';
import Tabs from 'src/components/Tabs';
import DashboardGrid from 'src/dashboard/containers/DashboardGrid';
Expand All @@ -31,7 +31,6 @@ import {
DASHBOARD_ROOT_DEPTH,
} from 'src/dashboard/util/constants';
import { getRootLevelTabIndex, getRootLevelTabsComponent } from './utils';
import { Filters } from '../../reducers/types';
import { getChartIdsInFilterScope } from '../../util/activeDashboardFilters';
import findTabIndexByComponentId from '../../util/findTabIndexByComponentId';
import { findTabsWithChartsInScope } from '../nativeFilters/utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/
import { useSelector } from 'react-redux';
import { Filter } from '@superset-ui/core';
import { FeatureFlag, isFeatureEnabled } from 'src/featureFlags';
import { useCallback, useEffect, useState, useContext } from 'react';
import { URL_PARAMS } from 'src/constants';
Expand All @@ -27,7 +28,6 @@ import {
useFilters,
useNativeFiltersDataMask,
} from '../nativeFilters/FilterBar/state';
import { Filter } from '../nativeFilters/types';

// eslint-disable-next-line import/prefer-default-export
export const useNativeFilters = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { uniqWith } from 'lodash';
import cx from 'classnames';
import { DataMaskStateWithId, Filters } from '@superset-ui/core';
import Icons from 'src/components/Icons';
import { usePrevious } from 'src/hooks/usePrevious';
import { DataMaskStateWithId } from 'src/dataMask/types';
import DetailsPanelPopover from './DetailsPanel';
import { Pill } from './Styles';
import {
Expand All @@ -38,7 +38,6 @@ import {
DashboardLayout,
RootState,
} from '../../types';
import { Filters } from '../../reducers/types';

export interface FiltersBadgeProps {
chartId: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,21 @@
* under the License.
*/
import {
DataMaskStateWithId,
DataMaskType,
ensureIsArray,
FeatureFlag,
Filters,
FilterState,
isFeatureEnabled,
NativeFilterType,
} from '@superset-ui/core';
import { NO_TIME_RANGE, TIME_FILTER_MAP } from 'src/explore/constants';
import { getChartIdsInFilterScope } from 'src/dashboard/util/activeDashboardFilters';
import { ChartConfiguration, Filters } from 'src/dashboard/reducers/types';
import { DataMaskStateWithId, DataMaskType } from 'src/dataMask/types';
import { ChartConfiguration } from 'src/dashboard/reducers/types';
import { areObjectsEqual } from 'src/reduxUtils';
import { Layout } from '../../types';
import { getTreeCheckedItems } from '../nativeFilters/FiltersConfigModal/FiltersConfigForm/FilterScope/utils';
import { NativeFilterType } from '../nativeFilters/types';

export enum IndicatorStatus {
Unset = 'UNSET',
Expand Down
Loading