Skip to content

Commit

Permalink
feat(native-filters): add AppSection type (#1038)
Browse files Browse the repository at this point in the history
* feat: add place type

* refactor: fix CR notes

* docs: update comments

* fix: fix CR notes
  • Loading branch information
simcha90 authored and zhaoyongjie committed Nov 26, 2021
1 parent 803fd44 commit 05bd319
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
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 { AppSection, Behavior, convertKeysToCamelCase, Datasource, JsonObject } 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,
}),
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ export enum Behavior {
NATIVE_FILTER = 'NATIVE_FILTER',
}

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

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

export type DataMask = {
Expand Down

0 comments on commit 05bd319

Please sign in to comment.