fix: fix nvd3 and histogram regressions and migrate control panels to TS (#875)

* chore: add types to all control panels

* move nvd3 shared section to individual viz
This commit is contained in:
Ville Brofeldt 2020-12-21 21:29:24 +02:00 committed by Yongjie Zhao
parent ddfcb47dd1
commit 146f9a4dfd
19 changed files with 91 additions and 41 deletions

View File

@ -16,15 +16,16 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
import { t, legacyValidateInteger } from '@superset-ui/core';
import { import {
t, ControlPanelConfig,
legacyValidateInteger,
D3_TIME_FORMAT_OPTIONS,
D3_FORMAT_DOCS, D3_FORMAT_DOCS,
} from '@superset-ui/core'; D3_TIME_FORMAT_OPTIONS,
import { formatSelectOptions, sections } from '@superset-ui/chart-controls'; formatSelectOptions,
sections,
} from '@superset-ui/chart-controls';
export default { const config: ControlPanelConfig = {
controlPanelSections: [ controlPanelSections: [
sections.legacyRegularTime, sections.legacyRegularTime,
{ {
@ -177,3 +178,5 @@ export default {
}, },
}, },
}; };
export default config;

View File

@ -17,9 +17,9 @@
* under the License. * under the License.
*/ */
import { t, validateNonEmpty } from '@superset-ui/core'; 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: [ controlPanelSections: [
sections.legacyRegularTime, sections.legacyRegularTime,
{ {
@ -55,3 +55,5 @@ export default {
}, },
}, },
}; };
export default config;

View File

@ -18,8 +18,9 @@
*/ */
import { t, validateNonEmpty } from '@superset-ui/core'; import { t, validateNonEmpty } from '@superset-ui/core';
import { import {
formatSelectOptions,
columnChoices, columnChoices,
ControlPanelConfig,
formatSelectOptions,
formatSelectOptionsForRange, formatSelectOptionsForRange,
sections, sections,
} from '@superset-ui/chart-controls'; } from '@superset-ui/chart-controls';
@ -31,7 +32,7 @@ const sortAxisChoices = [
['value_desc', t('Metric descending')], ['value_desc', t('Metric descending')],
]; ];
export default { const config: ControlPanelConfig = {
controlPanelSections: [ controlPanelSections: [
sections.legacyRegularTime, sections.legacyRegularTime,
{ {
@ -261,3 +262,5 @@ export default {
}, },
}, },
}; };
export default config;

View File

@ -17,15 +17,20 @@
* under the License. * under the License.
*/ */
import { t, validateNonEmpty } from '@superset-ui/core'; 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: [ controlPanelSections: [
sections.legacyRegularTime,
{ {
label: t('Query'), label: t('Query'),
expanded: true, expanded: true,
controlSetRows: [ controlSetRows: [
sections.legacyRegularTime,
[ [
{ {
name: 'all_columns_x', name: 'all_columns_x',
@ -102,3 +107,4 @@ export default {
}, },
], ],
}; };
export default config;

View File

@ -17,9 +17,9 @@
* under the License. * under the License.
*/ */
import { t } from '@superset-ui/core'; 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: [ controlPanelSections: [
sections.legacyRegularTime, sections.legacyRegularTime,
{ {
@ -92,3 +92,5 @@ export default {
}, },
], ],
}; };
export default config;

View File

@ -17,9 +17,14 @@
* under the License. * under the License.
*/ */
import { t } from '@superset-ui/core'; 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: [ controlPanelSections: [
sections.legacyRegularTime, sections.legacyRegularTime,
{ {
@ -99,9 +104,13 @@ export default {
'Either a numerical column or `Auto`, which scales the point based ' + 'Either a numerical column or `Auto`, which scales the point based ' +
'on the largest cluster', 'on the largest cluster',
), ),
mapStateToProps: state => ({ mapStateToProps: state => {
choices: formatSelectOptions(['Auto']).concat(columnChoices(state.datasource)), const datasourceChoices = columnChoices(state.datasource);
}), const choices: [string, string][] = formatSelectOptions(['Auto']);
return {
choices: choices.concat(datasourceChoices),
};
},
}, },
}, },
], ],
@ -292,3 +301,5 @@ export default {
}, },
}, },
}; };
export default config;

View File

@ -20,7 +20,7 @@
import React from 'react'; import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { InfoTooltipWithTrigger } from '@superset-ui/chart-controls'; import { ColumnMeta, InfoTooltipWithTrigger } from '@superset-ui/chart-controls';
const propTypes = { const propTypes = {
option: PropTypes.object.isRequired, option: PropTypes.object.isRequired,
@ -28,7 +28,7 @@ const propTypes = {
// This component provides a general tooltip for options // This component provides a general tooltip for options
// in a SelectControl // in a SelectControl
export default function OptionDescription({ option }) { export default function OptionDescription({ option }: { option: ColumnMeta }) {
return ( return (
<span> <span>
<span className="m-r-5 option-label">{option.label}</span> <span className="m-r-5 option-label">{option.label}</span>

View File

@ -19,15 +19,17 @@
import React from 'react'; import React from 'react';
import { t, validateNonEmpty } from '@superset-ui/core'; import { t, validateNonEmpty } from '@superset-ui/core';
import { import {
formatSelectOptions, ColumnMeta,
D3_TIME_FORMAT_OPTIONS, ControlPanelConfig,
D3_FORMAT_DOCS, D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS, D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
formatSelectOptions,
sections, sections,
} from '@superset-ui/chart-controls'; } from '@superset-ui/chart-controls';
import OptionDescription from './OptionDescription'; import OptionDescription from './OptionDescription';
export default { const config: ControlPanelConfig = {
controlPanelSections: [ controlPanelSections: [
sections.legacyRegularTime, sections.legacyRegularTime,
{ {
@ -116,8 +118,8 @@ export default {
description: t('Use the Advanced Analytics options below'), description: t('Use the Advanced Analytics options below'),
}, },
], ],
optionRenderer: op => <OptionDescription option={op} />, optionRenderer: (op: ColumnMeta) => <OptionDescription option={op} />,
valueRenderer: op => <OptionDescription option={op} />, valueRenderer: (op: ColumnMeta) => <OptionDescription option={op} />,
description: t('Settings for time series'), description: t('Settings for time series'),
}, },
}, },
@ -355,3 +357,5 @@ export default {
}, },
], ],
}; };
export default config;

View File

@ -18,14 +18,15 @@
*/ */
import { t } from '@superset-ui/core'; import { t } from '@superset-ui/core';
import { import {
D3_FORMAT_OPTIONS, ControlPanelConfig,
D3_FORMAT_DOCS,
formatSelectOptions, formatSelectOptions,
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS, D3_TIME_FORMAT_OPTIONS,
sections, sections,
} from '@superset-ui/chart-controls'; } from '@superset-ui/chart-controls';
export default { const config: ControlPanelConfig = {
controlPanelSections: [ controlPanelSections: [
sections.legacyTimeseriesTime, sections.legacyTimeseriesTime,
{ {
@ -135,3 +136,5 @@ export default {
columns: { includeTime: true }, columns: { includeTime: true },
}, },
}; };
export default config;

View File

@ -19,14 +19,15 @@
import React from 'react'; import React from 'react';
import { t } from '@superset-ui/core'; import { t } from '@superset-ui/core';
import { import {
ControlPanelConfig,
formatSelectOptions, formatSelectOptions,
D3_TIME_FORMAT_OPTIONS,
D3_FORMAT_DOCS, D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS, D3_FORMAT_OPTIONS,
D3_TIME_FORMAT_OPTIONS,
sections, sections,
} from '@superset-ui/chart-controls'; } from '@superset-ui/chart-controls';
export default { const config: ControlPanelConfig = {
controlPanelSections: [ controlPanelSections: [
sections.legacyTimeseriesTime, sections.legacyTimeseriesTime,
{ {
@ -251,3 +252,5 @@ export default {
}, },
], ],
}; };
export default config;

View File

@ -17,9 +17,9 @@
* under the License. * under the License.
*/ */
import { t } from '@superset-ui/core'; 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: [ controlPanelSections: [
sections.legacyRegularTime, sections.legacyRegularTime,
{ {
@ -40,3 +40,5 @@ export default {
}, },
}, },
}; };
export default config;

View File

@ -16,10 +16,15 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
import { t, D3_FORMAT_OPTIONS, D3_FORMAT_DOCS } from '@superset-ui/core'; import { t } from '@superset-ui/core';
import { sections } from '@superset-ui/chart-controls'; import {
ControlPanelConfig,
D3_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
sections,
} from '@superset-ui/chart-controls';
export default { const config: ControlPanelConfig = {
controlPanelSections: [ controlPanelSections: [
sections.legacyRegularTime, sections.legacyRegularTime,
{ {
@ -69,3 +74,5 @@ export default {
}, },
}, },
}; };
export default config;

View File

@ -17,9 +17,9 @@
* under the License. * under the License.
*/ */
import { t } from '@superset-ui/core'; 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: [ controlPanelSections: [
sections.legacyRegularTime, sections.legacyRegularTime,
{ {
@ -107,3 +107,5 @@ export default {
}, },
}, },
}; };
export default config;

View File

@ -36,6 +36,7 @@ import {
const config: ControlPanelConfig = { const config: ControlPanelConfig = {
controlPanelSections: [ controlPanelSections: [
sections.legacyTimeseriesTime,
timeSeriesSection[0], timeSeriesSection[0],
{ {
label: t('Chart Options'), label: t('Chart Options'),

View File

@ -42,6 +42,7 @@ import {
const config: ControlPanelConfig = { const config: ControlPanelConfig = {
controlPanelSections: [ controlPanelSections: [
sections.legacyTimeseriesTime,
timeSeriesSection[0], timeSeriesSection[0],
{ {
label: t('Chart Options'), label: t('Chart Options'),

View File

@ -34,6 +34,7 @@ import {
const config: ControlPanelConfig = { const config: ControlPanelConfig = {
controlPanelSections: [ controlPanelSections: [
sections.legacyTimeseriesTime,
timeSeriesSection[0], timeSeriesSection[0],
{ {
label: t('Chart Options'), label: t('Chart Options'),

View File

@ -39,6 +39,7 @@ import {
const config: ControlPanelConfig = { const config: ControlPanelConfig = {
controlPanelSections: [ controlPanelSections: [
sections.legacyTimeseriesTime,
timeSeriesSection[0], timeSeriesSection[0],
{ {
label: t('Chart Options'), label: t('Chart Options'),

View File

@ -27,7 +27,6 @@ import {
D3_TIME_FORMAT_OPTIONS, D3_TIME_FORMAT_OPTIONS,
D3_FORMAT_DOCS, D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS, D3_FORMAT_OPTIONS,
sections,
} from '@superset-ui/chart-controls'; } from '@superset-ui/chart-controls';
/* /*
@ -305,7 +304,6 @@ export const yAxisLabel: CustomControlItem = {
}; };
export const timeSeriesSection: ControlPanelSectionConfig[] = [ export const timeSeriesSection: ControlPanelSectionConfig[] = [
sections.legacyTimeseriesTime,
{ {
label: t('Query'), label: t('Query'),
expanded: true, expanded: true,