From d731f7063067f825df3c2781b1497e27124e4849 Mon Sep 17 00:00:00 2001 From: Ville Brofeldt <33317356+villebro@users.noreply.github.com> Date: Fri, 4 Dec 2020 19:46:36 +0200 Subject: [PATCH] fix(demo): add antd css and implement action hook (#851) --- .../packages/superset-ui-demo/package.json | 1 + .../plugins/plugin-filter-antd/Select/Stories.tsx | 11 +++++++++-- .../src/Select/AntdSelectFilter.tsx | 1 - .../plugin-filter-antd/src/Select/transformProps.ts | 1 - 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-demo/package.json b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-demo/package.json index 81078a2f459d8..8733f8fe7f4a6 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-demo/package.json +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-demo/package.json @@ -67,6 +67,7 @@ "@types/react-loadable": "^5.5.3", "@types/react-resizable": "^1.7.2", "@types/storybook__react": "5.2.1", + "antd": "^4.9.1", "bootstrap": "^3.4.1", "core-js": "3.6.5", "gh-pages": "^3.0.0", diff --git a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-demo/storybook/stories/plugins/plugin-filter-antd/Select/Stories.tsx b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-demo/storybook/stories/plugins/plugin-filter-antd/Select/Stories.tsx index 9181b0454d340..61b8b8a6481f4 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-demo/storybook/stories/plugins/plugin-filter-antd/Select/Stories.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/packages/superset-ui-demo/storybook/stories/plugins/plugin-filter-antd/Select/Stories.tsx @@ -1,9 +1,12 @@ import React from 'react'; +import { action } from '@storybook/addon-actions'; +import { boolean, withKnobs } from '@storybook/addon-knobs'; import { SuperChart, getChartTransformPropsRegistry } from '@superset-ui/core'; import { AntdSelectFilterPlugin } from '@superset-ui/plugin-filter-antd'; import transformProps from '@superset-ui/plugin-filter-antd/lib/Select/transformProps'; import data from './data'; import { withResizableChartDemo } from '../../../../shared/components/ResizableChartDemo'; +import 'antd/dist/antd.css'; new AntdSelectFilterPlugin().configure({ key: 'filter_select' }).register(); @@ -11,7 +14,7 @@ getChartTransformPropsRegistry().registerValue('filter_select', transformProps); export default { title: 'Filter Plugins|plugin-filter-antd/Select', - decorators: [withResizableChartDemo], + decorators: [withKnobs, withResizableChartDemo], }; export const Select = ({ width, height }) => { @@ -24,12 +27,16 @@ export const Select = ({ width, height }) => { formData={{ adhoc_filters: [], extra_filters: [], - multiSelect: true, + multiSelect: boolean('Multi select', true), + inverseSelection: boolean('Inverse selection', false), row_limit: 1000, viz_type: 'filter_select', groupby: ['country_name'], metrics: ['SUM(SP_POP_TOTL)'], }} + hooks={{ + setExtraFormData: action('setExtraFormData'), + }} /> ); }; diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-filter-antd/src/Select/AntdSelectFilter.tsx b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-filter-antd/src/Select/AntdSelectFilter.tsx index a65dfd1d2f0c0..4df3a1ff97cbb 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-filter-antd/src/Select/AntdSelectFilter.tsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-filter-antd/src/Select/AntdSelectFilter.tsx @@ -52,7 +52,6 @@ export default function AntdPluginFilterSelect(props: AntdPluginFilterSelectProp enableEmptyFilter && !inverseSelection && (value === undefined || value === null || value.length === 0); - console.log(enableEmptyFilter, emptyFilter); setExtraFormData({ append_form_data: emptyFilter ? { diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-filter-antd/src/Select/transformProps.ts b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-filter-antd/src/Select/transformProps.ts index f10994d24b04b..f472339163dd1 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-filter-antd/src/Select/transformProps.ts +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/plugin-filter-antd/src/Select/transformProps.ts @@ -25,7 +25,6 @@ export default function transformProps(chartProps: ChartProps) { const { setExtraFormData = () => {} } = hooks; const data = queryData.data as DataRecord[]; - // console.log('formData via TransformProps.ts', formData); return { width, height,