Skip to content

Commit

Permalink
Not applied
Browse files Browse the repository at this point in the history
  • Loading branch information
mistercrunch committed Dec 20, 2017
1 parent 5e92196 commit adbc075
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
8 changes: 1 addition & 7 deletions superset/assets/javascripts/explore/stores/visTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,6 @@ export const visTypes = {
['y_axis_format', 'y_axis_bounds'],
],
},
{
label: t('Code'),
controlSetRows: [
['js_data'],
['js_chart'],
],
},
sections.NVD3TimeSeries[1],
sections.annotations,
],
Expand Down Expand Up @@ -614,6 +607,7 @@ export const visTypes = {
controlPanelSections: [
{
label: t('Code'),
expanded: true,
controlSetRows: [
['markup_type'],
['code'],
Expand Down
7 changes: 3 additions & 4 deletions superset/assets/javascripts/modules/sandbox.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// A safe alternative to JS's eval
import vm from 'vm';
import moment from 'moment';
import d3 from 'd3';
import _ from 'underscore';

// Objects exposed here should be treated like a public API
// if `underscore` had backwards incompatible changes in a future release, we'd
// have to be careful about bumping the library as those changes could break user charts
const GLOBAL_CONTEXT = {
moment,
d3,
console,
_,
};
Expand Down
4 changes: 2 additions & 2 deletions superset/assets/spec/javascripts/modules/sandbox_spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { expect } from 'chai';

import sandboxedEval from '../../../javascripts/modules/sandbox';

describe('unitToRadius', () => {
describe('sandboxedEval', () => {
it('works like a basic eval', () => {
expect(sandboxedEval('100')).to.equal(100);
expect(sandboxedEval('v => v * 2')(5)).to.equal(10);
});
it('d3 is in context and works', () => {
expect(sandboxedEval("v => d3.format('.3s')(v)")(10000000)).to.equal('10.0M');
expect(sandboxedEval("l => _.find(l, s => s === 'bar')")(['foo', 'bar'])).to.equal('bar');
});
it('passes context as expected', () => {
expect(sandboxedEval('foo', { foo: 'bar' })).to.equal('bar');
Expand Down
6 changes: 1 addition & 5 deletions superset/assets/visualizations/nvd3_vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import mathjs from 'mathjs';
import d3tip from 'd3-tip';

import { getColorFromScheme } from '../javascripts/modules/colors';
import sandboxedEval from '../javascripts/modules/sandbox';
import AnnotationTypes, {
applyNativeColumns,
} from '../javascripts/modules/AnnotationTypes';
Expand Down Expand Up @@ -97,7 +96,6 @@ function formatLabel(column, verbose_map) {
/* eslint-enable camelcase */

function nvd3Vis(slice, payload) {
const fd = slice.formData;
let chart;
let colorKey = 'key';
const isExplore = $('#explore-container').length === 1;
Expand Down Expand Up @@ -131,6 +129,7 @@ function nvd3Vis(slice, payload) {
}

let width = slice.width();
const fd = slice.formData;

const barchartWidth = function () {
let bars;
Expand Down Expand Up @@ -726,9 +725,6 @@ function nvd3Vis(slice, payload) {
.attr('width', width)
.call(chart);
}
if (fd.js_chart) {
sandboxedEval(fd.js_chart, { foo: 'bar' })(chart);
}
return chart;
};

Expand Down

0 comments on commit adbc075

Please sign in to comment.