mirror of
https://github.com/apache/superset.git
synced 2026-04-17 23:25:05 +00:00
Introduce Javascript controls (#4076)
* Introduce Javascript controls This allows power-users to perform intricate transformations on data and objects using javascript code. The operations allowed are "sanboxed" or limited using node's vm `runInNewContext` https://nodejs.org/api/vm.html#vm_vm_runinnewcontext_code_sandbox_options For now I'm only enabling in the line chart visualization, but the plan would be to go towards offering more power to people who can write some JS moving forward. * Not applied
This commit is contained in:
committed by
GitHub
parent
b4909f2d03
commit
69195f8d2d
17
superset/assets/spec/javascripts/modules/sandbox_spec.jsx
Normal file
17
superset/assets/spec/javascripts/modules/sandbox_spec.jsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { it, describe } from 'mocha';
|
||||
import { expect } from 'chai';
|
||||
|
||||
import sandboxedEval from '../../../javascripts/modules/sandbox';
|
||||
|
||||
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("l => _.find(l, s => s === 'bar')")(['foo', 'bar'])).to.equal('bar');
|
||||
});
|
||||
it('passes context as expected', () => {
|
||||
expect(sandboxedEval('foo', { foo: 'bar' })).to.equal('bar');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user