Skip to content

Commit

Permalink
Revert "use setupPluginsExtra instead of maintaining MainPreset"
Browse files Browse the repository at this point in the history
This reverts commit 282194f.
  • Loading branch information
Ubuntu committed May 22, 2021
1 parent 2cb6431 commit a335cd6
Show file tree
Hide file tree
Showing 29 changed files with 138 additions and 1,161 deletions.
16 changes: 2 additions & 14 deletions docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ x-superset-environment: &superset-environment
REDIS_CELERY_DB: 4
FLASK_ENV: production
SUPERSET_ENV: production
CYPRESS_CONFIG: "false"
MAPBOX_API_KEY: ${SUPERSET_MAPBOX_API_KEY}
PYTHONPATH: /app/pythonpath:/app/pythonpath_docker

Expand Down Expand Up @@ -57,7 +56,7 @@ services:
depends_on: *depends-on
volumes: *superset-volumes
ports:
- ${SUPERSET_PORT}:8088
- ${SUPERSET_PORT}:8080
networks:
- all

Expand All @@ -73,18 +72,7 @@ services:

superset-worker:
build: *superset-app-build
command: ["/usr/bin/docker-bootstrap.sh", "worker"]
restart: unless-stopped
environment: *superset-environment
user: "root"
depends_on: *depends-on
volumes: *superset-volumes
networks:
- all

superset-worker-beat:
build: *superset-app-build
command: ["/usr/bin/docker-bootstrap.sh", "beat"]
command: celery worker --app=superset.tasks.celery_app:app -Ofair -l INFO
restart: unless-stopped
environment: *superset-environment
user: "root"
Expand Down
5 changes: 1 addition & 4 deletions docker/superset/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ RUN /frontend-mem-nag.sh \
# Next, copy in the rest and let webpack do its thing
COPY ./repo/superset-frontend /app/superset-frontend

#COPY ./plugins/setupPluginsExtra.ts /app/superset-frontend/src/setup/setupPluginsExtra.ts
COPY ./plugins/MainPreset.js /app/superset-frontend/src/visualizations/presets/MainPreset.js

# This is BY FAR the most expensive step (thanks Terser!)
Expand All @@ -79,15 +78,14 @@ ENV LANG=C.UTF-8 \
FLASK_APP="superset.app:create_app()" \
PYTHONPATH="/app/pythonpath" \
SUPERSET_HOME="/app/superset_home" \
SUPERSET_PORT=8088
SUPERSET_PORT=8080

RUN useradd --user-group --no-create-home --no-log-init --shell /bin/bash superset \
&& mkdir -p ${SUPERSET_HOME} ${PYTHONPATH} \
&& apt-get update -y \
&& apt-get install -y --no-install-recommends \
build-essential \
default-libmysqlclient-dev \
libsasl2-modules-gssapi-mit \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*

Expand All @@ -108,7 +106,6 @@ RUN cd /app \
&& pip install -e .

COPY ./repo/docker/docker-entrypoint.sh /usr/bin/
COPY ./repo/docker/docker-bootstrap.sh /usr/bin/

WORKDIR /app

Expand Down
16 changes: 0 additions & 16 deletions superset/plugins/MainPreset.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ import {
//EchartsBoxPlotChartPlugin,
EchartsTimeseriesChartPlugin,
EchartsGraphChartPlugin,
EchartsGaugeChartPlugin,
EchartsRadarChartPlugin,
EchartsMixedTimeseriesChartPlugin,
} from '@superset-ui/plugin-chart-echarts';
import {
EchartsBoxPlotChartPlugin,
Expand All @@ -69,11 +66,7 @@ import {
SelectFilterPlugin,
RangeFilterPlugin,
TimeFilterPlugin,
TimeColumnFilterPlugin,
TimeGrainFilterPlugin,
GroupByFilterPlugin,
} from 'src/filters/components/';
import { PivotTableChartPlugin as PivotTableChartPluginV2 } from '@superset-ui/plugin-chart-pivot-table';
import FilterBoxChartPlugin from '../FilterBox/FilterBoxChartPlugin';
import TimeTableChartPlugin from '../TimeTable/TimeTableChartPlugin';

Expand All @@ -98,12 +91,7 @@ export default class MainPreset extends Preset {
new DualLineChartPlugin().configure({ key: 'dual_line' }),
new EventFlowChartPlugin().configure({ key: 'event_flow' }),
new FilterBoxChartPlugin().configure({ key: 'filter_box' }),
new EchartsGaugeChartPlugin().configure({ key: 'gauge_chart' }),
new EchartsGraphChartPlugin().configure({ key: 'graph_chart' }),
new EchartsRadarChartPlugin().configure({ key: 'radar' }),
new EchartsMixedTimeseriesChartPlugin().configure({
key: 'mixed_timeseries',
}),
new HeatmapChartPlugin().configure({ key: 'heatmap' }),
new HistogramChartPlugin().configure({ key: 'histogram' }),
new HorizonChartPlugin().configure({ key: 'horizon' }),
Expand All @@ -115,7 +103,6 @@ export default class MainPreset extends Preset {
new PartitionChartPlugin().configure({ key: 'partition' }),
new EchartsPieChartPlugin().configure({ key: 'pie' }),
new PivotTableChartPlugin().configure({ key: 'pivot_table' }),
new PivotTableChartPluginV2().configure({ key: 'pivot_table_v2' }),
new RoseChartPlugin().configure({ key: 'rose' }),
new SankeyChartPlugin().configure({ key: 'sankey' }),
new SunburstChartPlugin().configure({ key: 'sunburst' }),
Expand All @@ -131,9 +118,6 @@ export default class MainPreset extends Preset {
new SelectFilterPlugin().configure({ key: 'filter_select' }),
new RangeFilterPlugin().configure({ key: 'filter_range' }),
new TimeFilterPlugin().configure({ key: 'filter_time' }),
new TimeColumnFilterPlugin().configure({ key: 'filter_timecolumn' }),
new TimeGrainFilterPlugin().configure({ key: 'filter_timegrain' }),
new GroupByFilterPlugin().configure({ key: 'filter_groupby' }),
],
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
commits = response.json()
if not commits:
print("Commits list is empty", file=sys.stderr)
elif commits[0]["sha"] == "bc1e208c1db1b6c57a7cd46c69beb9fc0e3184ea":
elif commits[0]["sha"] == "fecfc34cd3e3dd2efb8daee03d6416384914cc8a":
print("No changes were made to the MainPresets file")
else:
print("Changes were made to the MainPresets file", file=sys.stderr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,67 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
import React, { useCallback } from 'react';
import React from 'react';
import Echart from '../components/Echart';
import { jsx as ___EmotionJSX } from "@emotion/react";
export default function EchartsBoxPlot({
height,
width,
echartOptions,
setDataMask,
labelMap,
groupby,
selectedValues,
formData
echartOptions
}) {
const handleChange = useCallback(values => {
if (!formData.emitFilter) {
return;
}

const groupbyValues = values.map(value => labelMap[value]);
setDataMask({
extraFormData: {
filters: values.length === 0 ? [] : groupby.map((col, idx) => {
const val = groupbyValues.map(v => v[idx]);
if (val === null || val === undefined) return {
col,
op: 'IS NULL'
};
return {
col,
op: 'IN',
val: val
};
})
},
filterState: {
value: groupbyValues.length ? groupbyValues : null
},
ownState: {
selectedValues: values.length ? values : null
}
});
}, [groupby, labelMap, setDataMask, selectedValues]);
const eventHandlers = {
click: props => {
const {
name
} = props;
const values = Object.values(selectedValues);

if (values.includes(name)) {
handleChange(values.filter(v => v !== name));
} else {
handleChange([...values, name]);
}
}
};
return ___EmotionJSX(Echart, {
return /*#__PURE__*/React.createElement(Echart, {
height: height,
width: width,
echartOptions: echartOptions,
eventHandlers: eventHandlers,
selectedValues: selectedValues
echartOptions: echartOptions
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const PERCENTILE_REGEX = /(\d+)\/(\d+) percentiles/;
export default function buildQuery(formData) {
const {
query_mode,
groupby = [],
groupby,
minimum,
p10,
p25,
Expand Down Expand Up @@ -66,8 +66,8 @@ export default function buildQuery(formData) {
let whiskerType;
let percentiles;
const {
columns = [],
metrics = []
columns,
metrics
} = baseQueryObject;
const percentileMatch = PERCENTILE_REGEX.exec(whiskerOptions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@
* under the License.
*/
import React from 'react';
import { FeatureFlag, isFeatureEnabled, QueryMode, t } from '@superset-ui/core';
import { ColumnOption, D3_FORMAT_DOCS, D3_FORMAT_OPTIONS, D3_TIME_FORMAT_OPTIONS, formatSelectOptions, sections, QueryModeLabel } from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA } from '../Pie/types';
import { jsx as ___EmotionJSX } from "@emotion/react";
const {
emitFilter
} = DEFAULT_FORM_DATA;
import { t } from '@superset-ui/core';
import { formatSelectOptions, D3_FORMAT_OPTIONS, ColumnOption, sections } from '@superset-ui/chart-controls';
export let QueryMode;

(function (QueryMode) {
QueryMode["aggregate"] = "aggregate";
QueryMode["raw"] = "raw";
})(QueryMode || (QueryMode = {}));

const QueryModeLabel = {
[QueryMode.aggregate]: t('Aggregate'),
[QueryMode.raw]: t('Raw Records')
};

function getQueryMode(controls) {
var _controls$query_mode, _controls$all_columns;
Expand All @@ -35,7 +41,7 @@ function getQueryMode(controls) {
}

const rawColumns = controls == null ? void 0 : (_controls$all_columns = controls.all_columns) == null ? void 0 : _controls$all_columns.value;
const hasRawColumns = rawColumns && rawColumns.length > 0;
const hasRawColumns = rawColumns && (rawColumns == null ? void 0 : rawColumns.length) > 0;
return hasRawColumns ? QueryMode.raw : QueryMode.aggregate;
}
/**
Expand All @@ -46,21 +52,31 @@ function getQueryMode(controls) {
function isQueryMode(mode) {
return ({
controls
}) => getQueryMode(controls) === mode;
}) => {
return getQueryMode(controls) === mode;
};
}

const isAggMode = isQueryMode(QueryMode.aggregate);
const isRawMode = isQueryMode(QueryMode.raw);
const queryMode = {
type: 'RadioButtonControl',
label: t('Query mode'),
label: t('Query Mode'),
default: null,
options: [[QueryMode.aggregate, QueryModeLabel[QueryMode.aggregate]], [QueryMode.raw, QueryModeLabel[QueryMode.raw]]],
options: [{
label: QueryModeLabel[QueryMode.aggregate],
value: QueryMode.aggregate
}, {
label: QueryModeLabel[QueryMode.raw],
value: QueryMode.raw
}],
mapStateToProps: ({
controls
}) => ({
value: getQueryMode(controls)
})
}) => {
return {
value: getQueryMode(controls)
};
}
};
const all_columns = {
type: 'SelectControl',
Expand All @@ -71,11 +87,11 @@ const all_columns = {
allowAll: true,
commaChoosesOption: false,
default: [],
optionRenderer: c => ___EmotionJSX(ColumnOption, {
optionRenderer: c => /*#__PURE__*/React.createElement(ColumnOption, {
showType: true,
column: c
}),
valueRenderer: c => ___EmotionJSX(ColumnOption, {
valueRenderer: c => /*#__PURE__*/React.createElement(ColumnOption, {
column: c
}),
valueKey: 'column_name',
Expand Down Expand Up @@ -155,16 +171,7 @@ export default {
}, {
label: t('Chart Options'),
expanded: true,
controlSetRows: [['color_scheme'], isFeatureEnabled(FeatureFlag.DASHBOARD_CROSS_FILTERS) ? [{
name: 'emit_filter',
config: {
type: 'CheckboxControl',
label: t('Enable emitting filters'),
default: emitFilter,
renderTrigger: true,
description: t('Enable emmiting filters.')
}
}] : [], [{
controlSetRows: [['color_scheme'], [{
name: 'x_ticks_layout',
config: {
type: 'SelectControl',
Expand All @@ -186,17 +193,6 @@ export default {
choices: D3_FORMAT_OPTIONS,
description: `${t('D3 format syntax: https://github.com/d3/d3-format')} ${t('Only applies when "Label Type" is set to show values.')}`
}
}], [{
name: 'date_format',
config: {
type: 'SelectControl',
freeForm: true,
label: t('Date format'),
renderTrigger: true,
choices: D3_TIME_FORMAT_OPTIONS,
default: 'smart_date',
description: D3_FORMAT_DOCS
}
}]]
}],
controlOverrides: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { t, ChartMetadata, ChartPlugin, Behavior } from '@superset-ui/core';
import { t, ChartMetadata, ChartPlugin } from '@superset-ui/core';
import buildQuery from './buildQuery';
import controlPanel from './controlPanel';
import transformProps from './transformProps';
Expand All @@ -38,7 +38,6 @@ export default class EchartsBoxPlotChartPlugin extends ChartPlugin {
controlPanel,
loadChart: () => import('./EchartsBoxPlot'),
metadata: new ChartMetadata({
behaviors: [Behavior.INTERACTIVE_CHART],
credits: ['https://echarts.apache.org'],
description: 'Box Plot (Apache ECharts)',
name: t('Box Plot'),
Expand Down
Loading

0 comments on commit a335cd6

Please sign in to comment.