Skip to content

Commit

Permalink
feat(chart-controls): implement dnd controls for all charts (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
kgabryje authored and zhaoyongjie committed Nov 30, 2021
1 parent 4df23a4 commit 5e6af31
Show file tree
Hide file tree
Showing 12 changed files with 287 additions and 98 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v14.5.5
v14.15.5
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js

node_js:
- '11'
- '14'

cache:
- npm: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"@airbnb/config-typescript": "^2.1.2",
"@airbnb/nimbus": "^2.1.3",
"@superset-ui/commit-config": "^0.0.9",
"@superset-ui/chart-controls": "^0.16.3",
"@superset-ui/core": "^0.16.3",
"@superset-ui/chart-controls": "^0.17.49",
"@superset-ui/core": "^0.17.49",
"@types/enzyme": "^3.10.5",
"@types/jest": "^25.1.1",
"@types/jsdom": "^12.2.4",
Expand All @@ -73,7 +73,7 @@
"react": "^16.9.0"
},
"engines": {
"node": ">=10.10.0",
"node": ">=14.15.5",
"npm": ">=6.8.0",
"yarn": ">=1.13.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
* under the License.
*/
import { sections } from '@superset-ui/chart-controls';
import { t, validateNonEmpty, legacyValidateInteger } from '@superset-ui/core';
import { t, legacyValidateInteger, isFeatureEnabled, FeatureFlag } from '@superset-ui/core';
import { formatSelectOptions } from '../../utilities/utils';
import { columnChoices } from '../../utilities/controls';
import {
filterNulls,
jsColumns,
Expand All @@ -33,33 +32,21 @@ import {
extruded,
viewport,
mapboxStyle,
geojsonColumn,
} from '../../utilities/Shared_DeckGL';
import { dndGeojsonColumn } from '../../utilities/sharedDndControls';

const geojson = isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dndGeojsonColumn
: geojsonColumn;

export default {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
controlSetRows: [
[
{
name: 'geojson',
config: {
type: 'SelectControl',
label: t('GeoJson Column'),
validators: [validateNonEmpty],
description: t('Select the geojson column'),
mapStateToProps: state => ({
choices: columnChoices(state.datasource),
}),
},
},
null,
],
['row_limit', filterNulls],
['adhoc_filters'],
],
controlSetRows: [[geojson], ['row_limit'], [filterNulls], ['adhoc_filters']],
},
{
label: t('Map'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default {
{
label: t('Query'),
expanded: true,
controlSetRows: [[spatial, 'size'], ['row_limit', filterNulls], ['adhoc_filters']],
controlSetRows: [[spatial], ['size'], ['row_limit'], [filterNulls], ['adhoc_filters']],
},
{
label: t('Map'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
* under the License.
*/
import { sections } from '@superset-ui/chart-controls';
import { t, validateNonEmpty, legacyValidateInteger } from '@superset-ui/core';
import { t, legacyValidateInteger, isFeatureEnabled, FeatureFlag } from '@superset-ui/core';
import { formatSelectOptions } from '../../utilities/utils';
import { columnChoices } from '../../utilities/controls';
import {
filterNulls,
jsColumns,
Expand All @@ -33,33 +32,21 @@ import {
extruded,
viewport,
mapboxStyle,
geojsonColumn,
} from '../../utilities/Shared_DeckGL';
import { dndGeojsonColumn } from '../../utilities/sharedDndControls';

const geojson = isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dndGeojsonColumn
: geojsonColumn;

export default {
controlPanelSections: [
sections.legacyRegularTime,
{
label: t('Query'),
expanded: true,
controlSetRows: [
[
{
name: 'geojson',
config: {
type: 'SelectControl',
label: t('GeoJson Column'),
validators: [validateNonEmpty],
description: t('Select the geojson column'),
mapStateToProps: state => ({
choices: columnChoices(state.datasource),
}),
},
},
null,
],
['row_limit', filterNulls],
['adhoc_filters'],
],
controlSetRows: [[geojson], ['row_limit'], [filterNulls], ['adhoc_filters']],
},
{
label: t('Map'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import { sections } from '@superset-ui/chart-controls';
import { t } from '@superset-ui/core';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import {
filterNulls,
autozoom,
Expand All @@ -32,6 +32,7 @@ import {
reverseLongLat,
mapboxStyle,
} from '../../utilities/Shared_DeckGL';
import { dndLineColumn } from '../../utilities/sharedDndControls';

export default {
controlPanelSections: [
Expand All @@ -40,17 +41,21 @@ export default {
label: t('Query'),
expanded: true,
controlSetRows: [
[isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP) ? dndLineColumn : lineColumn],
[
lineColumn,
{
...lineType,
choices: [
['polyline', 'Polyline'],
['json', 'JSON'],
],
config: {
...lineType.config,
choices: [
['polyline', 'Polyline'],
['json', 'JSON'],
],
},
},
],
['row_limit', filterNulls],
['row_limit'],
[filterNulls],
['adhoc_filters'],
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import { sections } from '@superset-ui/chart-controls';
import { t } from '@superset-ui/core';
import { FeatureFlag, isFeatureEnabled, t } from '@superset-ui/core';
import timeGrainSqlaAnimationOverrides from '../../utilities/controls';
import { formatSelectOptions } from '../../utilities/utils';
import {
Expand All @@ -43,6 +43,11 @@ import {
reverseLongLat,
mapboxStyle,
} from '../../utilities/Shared_DeckGL';
import { dndLineColumn } from '../../utilities/sharedDndControls';

const lines = isFeatureEnabled(FeatureFlag.ENABLE_EXPLORE_DRAG_AND_DROP)
? dndLineColumn
: lineColumn;

export default {
controlPanelSections: [
Expand All @@ -52,13 +57,37 @@ export default {
expanded: true,
controlSetRows: [
[
{ ...lineColumn, label: t('Polygon Column') },
{ ...lineType, label: t('Polygon Encoding') },
{
...lines,
config: {
...lines.config,
label: t('Polygon Column'),
},
},
],
[
{
...lineType,
config: {
...lineType.config,
label: t('Polygon Encoding'),
},
},
],
['adhoc_filters'],
['metric', { ...pointRadiusFixed, label: t('Elevation') }],
['row_limit', null],
[reverseLongLat, filterNulls],
['metric'],
[
{
...pointRadiusFixed,
config: {
...pointRadiusFixed.config,
label: t('Elevation'),
},
},
],
['row_limit'],
[reverseLongLat],
[filterNulls],
],
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default {
{
label: t('Query'),
expanded: true,
controlSetRows: [[spatial, 'size'], ['row_limit', filterNulls], ['adhoc_filters']],
controlSetRows: [[spatial], ['size'], ['row_limit'], [filterNulls], ['adhoc_filters']],
},
{
label: t('Map'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -364,3 +364,16 @@ export const mapboxStyle = {
description: t('Base layer map style'),
},
};

export const geojsonColumn = {
name: 'geojson',
config: {
type: 'SelectControl',
label: t('GeoJson Column'),
validators: [validateNonEmpty],
description: t('Select the geojson column'),
mapStateToProps: state => ({
choices: columnChoices(state.datasource),
}),
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { t } from '@superset-ui/core';
import { dndEntity } from '@superset-ui/chart-controls/lib/shared-controls/dndControls';

export const dndLineColumn = {
name: 'line_column',
config: {
...dndEntity,
label: t('Lines column'),
description: t('The database columns that contains lines information'),
},
};

export const dndGeojsonColumn = {
name: 'geojson',
config: {
...dndEntity,
label: t('GeoJson Column'),
description: t('Select the geojson column'),
},
};
Loading

0 comments on commit 5e6af31

Please sign in to comment.