Skip to content

Commit

Permalink
chore(chart-controls): remove dedicated time section (apache#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro authored and zhaoyongjie committed Nov 24, 2021
1 parent e0562b8 commit 8cd39a8
Show file tree
Hide file tree
Showing 46 changed files with 201 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,34 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { ControlPanelSectionConfig } from './types';

// A few standard controls sections that are used internally.
// Not recommended for use in third-party plugins.

export const druidTimeSeries = {
const baseTimeSection = {
label: t('Time'),
expanded: true,
description: t('Time related form attributes'),
controlSetRows: [['time_range']],
};

export const datasourceAndVizType = {
export const legacyTimeseriesTime: ControlPanelSectionConfig = {
...baseTimeSection,
controlSetRows: [
['granularity'],
['druid_time_origin'],
['granularity_sqla'],
['time_grain_sqla'],
['time_range'],
],
};

export const legacyRegularTime: ControlPanelSectionConfig = {
...baseTimeSection,
controlSetRows: [['granularity_sqla'], ['time_range']],
};

export const datasourceAndVizType: ControlPanelSectionConfig = {
label: t('Datasource & Chart Type'),
expanded: true,
controlSetRows: [
Expand Down Expand Up @@ -75,19 +91,12 @@ export const datasourceAndVizType = {
],
};

export const colorScheme = {
export const colorScheme: ControlPanelSectionConfig = {
label: t('Color Scheme'),
controlSetRows: [['color_scheme', 'label_colors']],
};

export const sqlaTimeSeries = {
label: t('Time'),
description: t('Time related form attributes'),
expanded: true,
controlSetRows: [['granularity_sqla'], ['time_range']],
};

export const annotations = {
export const annotations: ControlPanelSectionConfig = {
label: t('Annotations and Layers'),
tabOverride: 'data',
expanded: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export interface DatasourceMeta {
main_dttm_col: string;
// eg. ['["ds", true]', 'ds [asc]']
order_by_choices?: [string, string][] | null;
time_grain_sqla: [string, string][];
granularity_sqla: [string, string][];
time_grain_sqla?: string;
granularity_sqla?: string;
datasource_name: string | null;
description: string | null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import { DatasourceMeta } from '../types';
/**
* Convert Dataource columns to column choices
*/
export default function columnChoices(datasource?: DatasourceMeta | null) {
export default function columnChoices(datasource?: DatasourceMeta | null): [string, string][] {
return (
datasource?.columns
.map(col => [col.column_name, col.verbose_name || col.column_name])
.map((col): [string, string] => [col.column_name, col.verbose_name || col.column_name])
.sort((opt1, opt2) => (opt1[1].toLowerCase() > opt2[1].toLowerCase() ? 1 : -1)) || []
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('columnChoices()', () => {
it('should convert columns to choices', () => {
expect(
columnChoices({
id: 1,
metrics: [],
type: DatasourceType.Table,
main_dttm_col: 'test',
Expand All @@ -40,6 +41,10 @@ describe('columnChoices()', () => {
verbose_name: 'bar',
},
],
verbose_map: {},
column_format: { fiz: 'NUMERIC', about: 'STRING', foo: 'DATE' },
datasource_name: 'my_datasource',
description: 'this is my datasource',
}),
).toEqual([
['foo', 'bar'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import {
D3_TIME_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
} from '@superset-ui/core';
import { formatSelectOptions } from '@superset-ui/chart-controls';
import { formatSelectOptions, sections } from '@superset-ui/chart-controls';

export default {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
* under the License.
*/
import { t, validateNonEmpty } from '@superset-ui/core';
import { sections } from '@superset-ui/chart-controls';

export default {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,16 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { D3_FORMAT_OPTIONS, D3_FORMAT_DOCS } 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: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down Expand Up @@ -103,3 +109,5 @@ export default {
},
},
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ import {
ColumnOption,
columnChoices,
ControlPanelConfig,
sections,
SelectControlConfig,
ColumnMeta,
} from '@superset-ui/chart-controls';

const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Event definition'),
controlSetRows: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { formatSelectOptions } from '@superset-ui/chart-controls';
import { formatSelectOptions, sections } from '@superset-ui/chart-controls';

export default {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
formatSelectOptions,
columnChoices,
formatSelectOptionsForRange,
sections,
} from '@superset-ui/chart-controls';

const sortAxisChoices = [
Expand All @@ -32,6 +33,7 @@ const sortAxisChoices = [

export default {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
* under the License.
*/
import { t, validateNonEmpty } from '@superset-ui/core';
import { formatSelectOptions, columnChoices } from '@superset-ui/chart-controls';
import { formatSelectOptions, columnChoices, sections } from '@superset-ui/chart-controls';

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

export default {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { formatSelectOptions, columnChoices } from '@superset-ui/chart-controls';
import { formatSelectOptions, columnChoices, sections } from '@superset-ui/chart-controls';

export default {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down Expand Up @@ -92,3 +94,5 @@ export default {
},
],
};

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

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down Expand Up @@ -62,3 +64,5 @@ export default {
},
],
};

export default config;
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@ import {
D3_TIME_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
sections,
} from '@superset-ui/chart-controls';
import OptionDescription from './OptionDescription';

export default {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ import {
D3_FORMAT_DOCS,
formatSelectOptions,
D3_TIME_FORMAT_OPTIONS,
sections,
} from '@superset-ui/chart-controls';

export default {
controlPanelSections: [
sections.legacyTimeseriesTime,
{
label: t('Query'),
expanded: true,
Expand Down Expand Up @@ -132,12 +134,4 @@ export default {
groupby: { includeTime: true },
columns: { includeTime: true },
},
sectionOverrides: {
druidTimeSeries: {
controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']],
},
sqlaTimeSeries: {
controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']],
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ import {
D3_TIME_FORMAT_OPTIONS,
D3_FORMAT_DOCS,
D3_FORMAT_OPTIONS,
sections,
} from '@superset-ui/chart-controls';

export default {
controlPanelSections: [
sections.legacyTimeseriesTime,
{
label: t('Query'),
expanded: true,
Expand Down Expand Up @@ -248,12 +250,4 @@ export default {
],
},
],
sectionOverrides: {
druidTimeSeries: {
controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']],
},
sqlaTimeSeries: {
controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']],
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { sections } from '@superset-ui/chart-controls';

export default {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@
* under the License.
*/
import { t } from '@superset-ui/core';
import { ControlPanelConfig } from '@superset-ui/chart-controls';
import { ControlPanelConfig, sections } from '@superset-ui/chart-controls';

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

export default {
const config: ControlPanelConfig = {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
Expand Down Expand Up @@ -63,3 +65,5 @@ export default {
},
},
};

export default config;
Loading

0 comments on commit 8cd39a8

Please sign in to comment.