Skip to content

Commit

Permalink
fix: fix nvd3 and histogram regressions and migrate control panels to…
Browse files Browse the repository at this point in the history
… TS (apache#875)

* chore: add types to all control panels

* move nvd3 shared section to individual viz
  • Loading branch information
villebro authored and zhaoyongjie committed Nov 25, 2021
1 parent 2b5ea35 commit 8ab63d7
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t, legacyValidateInteger } from '@superset-ui/core';
import {
t,
legacyValidateInteger,
D3_TIME_FORMAT_OPTIONS,
ControlPanelConfig,
D3_FORMAT_DOCS,
} from '@superset-ui/core';
import { formatSelectOptions, sections } from '@superset-ui/chart-controls';
D3_TIME_FORMAT_OPTIONS,
formatSelectOptions,
sections,
} from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
Expand Down Expand Up @@ -177,3 +178,5 @@ export default {
},
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/
import { t, validateNonEmpty } from '@superset-ui/core';
import { sections } from '@superset-ui/chart-controls';
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
Expand Down Expand Up @@ -55,3 +55,5 @@ export default {
},
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
*/
import { t, validateNonEmpty } from '@superset-ui/core';
import {
formatSelectOptions,
columnChoices,
ControlPanelConfig,
formatSelectOptions,
formatSelectOptionsForRange,
sections,
} from '@superset-ui/chart-controls';
Expand All @@ -31,7 +32,7 @@ const sortAxisChoices = [
['value_desc', t('Metric descending')],
];

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
Expand Down Expand Up @@ -261,3 +262,5 @@ export default {
},
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@
* under the License.
*/
import { t, validateNonEmpty } from '@superset-ui/core';
import { formatSelectOptions, columnChoices, sections } from '@superset-ui/chart-controls';
import {
ControlPanelConfig,
columnChoices,
formatSelectOptions,
sections,
} from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
controlSetRows: [
sections.legacyRegularTime,
[
{
name: 'all_columns_x',
Expand Down Expand Up @@ -102,3 +107,4 @@ export default {
},
],
};
export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { formatSelectOptions, sections } from '@superset-ui/chart-controls';
import { ControlPanelConfig, formatSelectOptions, sections } from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
Expand Down Expand Up @@ -92,3 +92,5 @@ export default {
},
],
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { formatSelectOptions, columnChoices, sections } from '@superset-ui/chart-controls';
import {
columnChoices,
ControlPanelConfig,
formatSelectOptions,
sections,
} from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
Expand Down Expand Up @@ -99,9 +104,13 @@ export default {
'Either a numerical column or `Auto`, which scales the point based ' +
'on the largest cluster',
),
mapStateToProps: state => ({
choices: formatSelectOptions(['Auto']).concat(columnChoices(state.datasource)),
}),
mapStateToProps: state => {
const datasourceChoices = columnChoices(state.datasource);
const choices: [string, string][] = formatSelectOptions(['Auto']);
return {
choices: choices.concat(datasourceChoices),
};
},
},
},
],
Expand Down Expand Up @@ -292,3 +301,5 @@ export default {
},
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
import React from 'react';
import PropTypes from 'prop-types';

import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls';
import { ColumnMeta, InfoTooltipWithTrigger } from '@superset-ui/chart-controls';

const propTypes = {
option: PropTypes.object.isRequired,
};

// This component provides a general tooltip for options
// in a SelectControl
export default function OptionDescription({ option }) {
export default function OptionDescription({ option }: { option: ColumnMeta }) {
return (
<span>
<span className="m-r-5 option-label">{option.label}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@
import React from 'react';
import { t, validateNonEmpty } from '@superset-ui/core';
import {
formatSelectOptions,
D3_TIME_FORMAT_OPTIONS,
ColumnMeta,
ControlPanelConfig,
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
formatSelectOptions,
sections,
} from '@superset-ui/chart-controls';
import OptionDescription from './OptionDescription';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
Expand Down Expand Up @@ -116,8 +118,8 @@ export default {
description: t('Use the Advanced Analytics options below'),
},
],
optionRenderer: op => <OptionDescription option={op} />,
valueRenderer: op => <OptionDescription option={op} />,
optionRenderer: (op: ColumnMeta) => <OptionDescription option={op} />,
valueRenderer: (op: ColumnMeta) => <OptionDescription option={op} />,
description: t('Settings for time series'),
},
},
Expand Down Expand Up @@ -355,3 +357,5 @@ export default {
},
],
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
*/
import { t } from '@superset-ui/core';
import {
D3_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
ControlPanelConfig,
formatSelectOptions,
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections,
} from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyTimeseriesTime,
{
Expand Down Expand Up @@ -135,3 +136,5 @@ export default {
columns: { includeTime: true },
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
import React from 'react';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
formatSelectOptions,
D3_TIME_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections,
} from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyTimeseriesTime,
{
Expand Down Expand Up @@ -251,3 +252,5 @@ export default {
},
],
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { sections } from '@superset-ui/chart-controls';
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
Expand All @@ -40,3 +40,5 @@ export default {
},
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,15 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t, D3_FORMAT_OPTIONS, D3_FORMAT_DOCS } from '@superset-ui/core';
import { sections } from '@superset-ui/chart-controls';
import { t } from '@superset-ui/core';
import {
ControlPanelConfig,
D3_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
sections,
} from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
Expand Down Expand Up @@ -69,3 +74,5 @@ export default {
},
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { formatSelectOptions, sections } from '@superset-ui/chart-controls';
import { ControlPanelConfig, formatSelectOptions, sections } from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
Expand Down Expand Up @@ -107,3 +107,5 @@ export default {
},
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {

const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyTimeseriesTime,
timeSeriesSection[0],
{
label: t('Chart Options'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {

const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyTimeseriesTime,
timeSeriesSection[0],
{
label: t('Chart Options'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {

const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyTimeseriesTime,
timeSeriesSection[0],
{
label: t('Chart Options'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {

const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyTimeseriesTime,
timeSeriesSection[0],
{
label: t('Chart Options'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
D3_TIME_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
sections,
} from '@superset-ui/chart-controls';

/*
Expand Down Expand Up @@ -305,7 +304,6 @@ export const yAxisLabel: CustomControlItem = {
};

export const timeSeriesSection: ControlPanelSectionConfig[] = [
sections.legacyTimeseriesTime,
{
label: t('Query'),
expanded: true,
Expand Down

0 comments on commit 8ab63d7

Please sign in to comment.