Skip to content

Commit

Permalink
fix(generator-superset): update plugin template to 0.17 standards (ap…
Browse files Browse the repository at this point in the history
  • Loading branch information
villebro authored and zhaoyongjie committed Nov 25, 2021
1 parent 7f2b167 commit 699dce9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
"access": "public"
},
"dependencies": {
"@superset-ui/core": "^0.15.2",
"@superset-ui/chart-controls": "^0.15.2"
"@superset-ui/core": "^0.17.0",
"@superset-ui/chart-controls": "^0.17.0"
},
"peerDependencies": {
"react": "^16.13.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ import { buildQueryContext, QueryFormData } from '@superset-ui/core';
* if a viz needs multiple different result sets.
*/
export default function buildQuery(formData: QueryFormData) {
const { cols: groupby } = formData;
return buildQueryContext(formData, baseQueryObject => [
{
...baseQueryObject,
groupby,<%if (chartType === 'timeseries') { %>
is_timeseries: true,<% } %>
},
]);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/
import { t, validateNonEmpty } from '@superset-ui/core';
import { ControlPanelConfig } from '@superset-ui/chart-controls';
import { ControlPanelConfig, sections, sharedControls } from '@superset-ui/chart-controls';

const config: ControlPanelConfig = {
/**
Expand Down Expand Up @@ -96,10 +96,40 @@ const config: ControlPanelConfig = {

// For control input types, see: superset-frontend/src/explore/components/controls/index.js
controlPanelSections: [
<%if (chartType === 'timeseries') { %>sections.legacyTimeseriesTime,<% } else { %>sections.legacyRegularTime,<% } %>
{
label: t('Query'),
expanded: true,
controlSetRows: [['groupby'], ['metrics'], ['adhoc_filters'], ['row_limit', null]],
controlSetRows: [
[
{
name: 'cols',
config: {
...sharedControls.groupby,
label: t('Columns'),
description: t('Columns to group by'),
},
},
],
[
{
name: 'metrics',
config: {
...sharedControls.metrics,
// it's possible to add validators to controls if
// certain selections/types need to be enforced
validators: [validateNonEmpty],
},
},
],
['adhoc_filters'],
[
{
name: 'row_limit',
config: sharedControls.row_limit,
},
],
],
},
{
label: t('Hello Controls!'),
Expand Down Expand Up @@ -155,25 +185,6 @@ const config: ControlPanelConfig = {
],
},
],
<%if (chartType === 'timeseries') { %> // Time series charts need to override the `druidTimeSeries` and `sqlaTimeSeries`
// sections to add the time grain dropdown.
sectionOverrides: {
druidTimeSeries: {
controlSetRows: [['granularity', 'druid_time_origin'], ['time_range']],
},
sqlaTimeSeries: {
controlSetRows: [['granularity_sqla', 'time_grain_sqla'], ['time_range']],
},
},<% } %>
controlOverrides: {
series: {
validators: [validateNonEmpty],
clearable: false,
},
row_limit: {
default: 100,
},
},
};

export default config;

0 comments on commit 699dce9

Please sign in to comment.