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

feat(core): expand native filter hook and add chart metadata fields #943

Merged
merged 5 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 13 additions & 5 deletions packages/superset-ui-core/src/chart/models/ChartMetadata.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Behavior } from '../types/Base';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer this to be called ChartFilterBehavior (after first-time seeing it in apache/superset#13052 and being confused of what it is), but looks like I'm late to the party...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't necessarily be restricted to filtering behavior, for example drill-downs which are essentially groupbys, but ChartBehavior could also be ok. Let me know if you want to update this now, otherwise we'll stick to this naming.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's save the update to when we need to expand this functionality.


interface LookupTable {
[key: string]: boolean;
}
Expand All @@ -7,11 +9,12 @@ export interface ChartMetadataConfig {
canBeAnnotationTypes?: string[];
credits?: string[];
description?: string;
datasourceCount?: number;
show?: boolean;
supportedAnnotationTypes?: string[];
thumbnail: string;
useLegacyApi?: boolean;
isNativeFilter?: boolean;
behaviors?: Behavior[];
}

export default class ChartMetadata {
Expand All @@ -33,7 +36,9 @@ export default class ChartMetadata {

useLegacyApi: boolean;

isNativeFilter: boolean;
behaviors: Behavior[];

datasourceCount: number;

constructor(config: ChartMetadataConfig) {
const {
Expand All @@ -45,7 +50,8 @@ export default class ChartMetadata {
supportedAnnotationTypes = [],
thumbnail,
useLegacyApi = false,
isNativeFilter = false,
behaviors = [],
datasourceCount = 1,
} = config;

this.name = name;
Expand All @@ -65,7 +71,8 @@ export default class ChartMetadata {
this.supportedAnnotationTypes = supportedAnnotationTypes;
this.thumbnail = thumbnail;
this.useLegacyApi = useLegacyApi;
this.isNativeFilter = isNativeFilter;
this.behaviors = behaviors;
this.datasourceCount = datasourceCount;
}

canBeAnnotationType(type: string): boolean {
Expand All @@ -82,7 +89,8 @@ export default class ChartMetadata {
supportedAnnotationTypes: this.supportedAnnotationTypes,
thumbnail: this.thumbnail,
useLegacyApi: this.useLegacyApi,
isNativeFilter: this.isNativeFilter,
behaviors: this.behaviors,
datasourceCount: this.datasourceCount,
});
}
}
13 changes: 12 additions & 1 deletion packages/superset-ui-core/src/chart/types/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,19 @@ import { ExtraFormData } from '../../query';

export type HandlerFunction = (...args: unknown[]) => void;

export enum Behavior {
CROSS_FILTER = 'CROSS_FILTER',
NATIVE_FILTER = 'NATIVE_FILTER',
}

export type SetExtraFormDataHook = {
(extraFormData: ExtraFormData): void;
({
extraFormData,
currentState: { value },
}: {
extraFormData: ExtraFormData;
currentState: { value: any; [key: string]: any };
}): void;
};

export interface PlainObject {
Expand Down

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions plugins/plugin-filter-antd/README.md

This file was deleted.

Loading