Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

feat(native-filters): add AppSection type #1038

Merged
merged 4 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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
11 changes: 10 additions & 1 deletion packages/superset-ui-core/src/chart/models/ChartProps.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createSelector } from 'reselect';
import { Behavior, convertKeysToCamelCase, Datasource, JsonObject } from '../..';
import { Behavior, convertKeysToCamelCase, Datasource, JsonObject, AppSection } from '../..';
import { HandlerFunction, PlainObject, SetDataMaskHook } from '../types/Base';
import { QueryData, DataRecordFilters } from '..';

Expand Down Expand Up @@ -55,6 +55,8 @@ export interface ChartPropsConfig {
ownCurrentState?: JsonObject;
/** Set of actual behaviors that this instance of chart should use */
behaviors?: Behavior[];
/** Application section of the chart on the screen (in what components/screen it placed) */
appSection?: AppSection;
}

const DEFAULT_WIDTH = 800;
Expand Down Expand Up @@ -87,6 +89,8 @@ export default class ChartProps<FormData extends RawFormData = RawFormData> {

behaviors: Behavior[];

appSection?: AppSection;

constructor(config: ChartPropsConfig & { formData?: FormData } = {}) {
const {
annotationData = {},
Expand All @@ -99,6 +103,7 @@ export default class ChartProps<FormData extends RawFormData = RawFormData> {
behaviors = [],
width = DEFAULT_WIDTH,
height = DEFAULT_HEIGHT,
appSection,
} = config;
this.width = width;
this.height = height;
Expand All @@ -112,6 +117,7 @@ export default class ChartProps<FormData extends RawFormData = RawFormData> {
this.queriesData = queriesData;
this.ownCurrentState = ownCurrentState;
this.behaviors = behaviors;
this.appSection = appSection;
}
}

Expand All @@ -128,6 +134,7 @@ ChartProps.createSelector = function create(): ChartPropsSelector {
input => input.width,
input => input.ownCurrentState,
input => input.behaviors,
input => input.appSection,
(
annotationData,
datasource,
Expand All @@ -139,6 +146,7 @@ ChartProps.createSelector = function create(): ChartPropsSelector {
width,
ownCurrentState,
behaviors,
appSection,
) =>
new ChartProps({
annotationData,
Expand All @@ -151,6 +159,7 @@ ChartProps.createSelector = function create(): ChartPropsSelector {
ownCurrentState,
width,
behaviors,
appSection,
}),
);
};
7 changes: 7 additions & 0 deletions packages/superset-ui-core/src/chart/types/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export enum Behavior {
NATIVE_FILTER = 'NATIVE_FILTER',
}

export enum AppSection {
EXPLORE = 'EXPLORE',
DASHBOARD = 'DASHBOARD',
FILTER_BAR = 'FILTER_BAR',
FILTER_CONFIG_MODAL = 'FILTER_CONFIG_MODAL',
}

export type DataMaskCurrentState = { value?: any; [key: string]: any };

export type DataMask = {
Expand Down