Skip to content

Commit af877c6

Browse files
authored
feat: deprecate old SuperChart API that accepts chartProps (apache-superset#202)
BREAKING CHANGE: No longer accept chartProps as a single prop in <SuperChart>. Developers must specify each field in chartProps individually.
1 parent 630d3e5 commit af877c6

File tree

3 files changed

+10
-134
lines changed

3 files changed

+10
-134
lines changed

packages/superset-ui-chart/src/components/SuperChartShell.tsx

Lines changed: 0 additions & 65 deletions
This file was deleted.

packages/superset-ui-chart/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export { default as ChartProps } from './models/ChartProps';
55

66
export { default as createLoadableRenderer } from './components/createLoadableRenderer';
77
export { default as reactify } from './components/reactify';
8-
export { default as SuperChart } from './components/SuperChartShell';
8+
export { default as SuperChart } from './components/SuperChart';
99

1010
export {
1111
default as getChartBuildQueryRegistry,

packages/superset-ui-chart/test/components/SuperChartShell.test.tsx renamed to packages/superset-ui-chart/test/components/SuperChart.test.tsx

Lines changed: 9 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jest.mock('resize-observer-polyfill');
66
// @ts-ignore
77
import { triggerResizeObserver } from 'resize-observer-polyfill';
88
import ErrorBoundary from 'react-error-boundary';
9-
import { ChartProps, SuperChart } from '../../src';
9+
import { SuperChart } from '../../src';
1010
import RealSuperChart from '../../src/components/SuperChart';
1111
import { ChartKeys, DiligentChartPlugin, BuggyChartPlugin } from './MockChartPlugins';
1212
import promiseTimeout from './promiseTimeout';
@@ -97,47 +97,15 @@ describe('SuperChart', () => {
9797
});
9898
});
9999

100-
describe('supports multiple way of specifying chartProps', () => {
101-
it('chartProps is instanceof ChartProps', () => {
102-
const wrapper = mount(
103-
<SuperChart
104-
chartType={ChartKeys.DILIGENT}
105-
chartProps={new ChartProps({ width: 20, height: 20 })}
106-
/>,
107-
);
108-
109-
return promiseTimeout(() => {
110-
const renderedWrapper = wrapper.render();
111-
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
112-
expectDimension(renderedWrapper, 20, 20);
113-
});
114-
});
115-
it('chartProps is ChartPropsConfig', () => {
116-
const wrapper = mount(
117-
<SuperChart chartType={ChartKeys.DILIGENT} chartProps={{ width: 201, height: 202 }} />,
118-
);
100+
it('passes the props to renderer correctly', () => {
101+
const wrapper = mount(
102+
<SuperChart chartType={ChartKeys.DILIGENT} width={101} height={118} formData={{ abc: 1 }} />,
103+
);
119104

120-
return promiseTimeout(() => {
121-
const renderedWrapper = wrapper.render();
122-
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
123-
expectDimension(renderedWrapper, 201, 202);
124-
});
125-
});
126-
it('fields of chartProps are listed as props of SuperChart', () => {
127-
const wrapper = mount(
128-
<SuperChart
129-
chartType={ChartKeys.DILIGENT}
130-
width={101}
131-
height={118}
132-
formData={{ abc: 1 }}
133-
/>,
134-
);
135-
136-
return promiseTimeout(() => {
137-
const renderedWrapper = wrapper.render();
138-
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
139-
expectDimension(renderedWrapper, 101, 118);
140-
});
105+
return promiseTimeout(() => {
106+
const renderedWrapper = wrapper.render();
107+
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
108+
expectDimension(renderedWrapper, 101, 118);
141109
});
142110
});
143111

@@ -191,33 +159,6 @@ describe('SuperChart', () => {
191159
const wrapper = mount(<SuperChart chartType={ChartKeys.DILIGENT} debounceTime={1} />);
192160
triggerResizeObserver();
193161

194-
return promiseTimeout(() => {
195-
const renderedWrapper = wrapper.render();
196-
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
197-
expectDimension(renderedWrapper, 300, 400);
198-
}, 100);
199-
});
200-
it('works when width and height are inside chartProps', () => {
201-
const wrapper = mount(
202-
<SuperChart
203-
chartType={ChartKeys.DILIGENT}
204-
debounceTime={1}
205-
chartProps={{ width: 123, height: 456 }}
206-
/>,
207-
);
208-
209-
return promiseTimeout(() => {
210-
const renderedWrapper = wrapper.render();
211-
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);
212-
expectDimension(renderedWrapper, 123, 456);
213-
}, 100);
214-
});
215-
it('works when there is chartProps but still no width and height', () => {
216-
const wrapper = mount(
217-
<SuperChart chartType={ChartKeys.DILIGENT} debounceTime={1} chartProps={{}} />,
218-
);
219-
triggerResizeObserver();
220-
221162
return promiseTimeout(() => {
222163
const renderedWrapper = wrapper.render();
223164
expect(renderedWrapper.find('div.test-component')).toHaveLength(1);

0 commit comments

Comments
 (0)