Skip to content

Commit

Permalink
Set VEGA_DEBUG only in the editor
Browse files Browse the repository at this point in the history
  • Loading branch information
nyurik committed Jan 13, 2018
1 parent c97e352 commit 28324c5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/core_plugins/vega/public/vega_view/vega_base_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ vega.scheme('elastic',
);

export class VegaBaseView {
constructor(vegaConfig, parentEl, vegaParser, serviceSettings) {
constructor(vegaConfig, editorMode, parentEl, vegaParser, serviceSettings) {
this._vegaConfig = vegaConfig;
this._editorMode = editorMode;
this._$parentEl = $(parentEl);
this._parser = vegaParser;
this._serviceSettings = serviceSettings;
Expand Down Expand Up @@ -123,7 +124,12 @@ export class VegaBaseView {
/**
* Set global debug variable to simplify vega debugging in console. Show info message first time
*/
static setDebugValues(view, spec, vlspec) {
setDebugValues(view, spec, vlspec) {
if (!this._editorMode) {
// VEGA_DEBUG should only be enabled in the editor mode
return;
}

if (window) {
if (window.VEGA_DEBUG === undefined && console) {
console.log('%cWelcome to Kibana Vega Plugin!', 'font-size: 16px; font-weight: bold;');
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/vega/public/vega_view/vega_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class VegaView extends VegaBaseView {
if (!this._$container) return;

const view = new vega.View(vega.parse(this._parser.spec), this._vegaViewConfig);
VegaView.setDebugValues(view, this._parser.spec, this._parser.vlspec);
this.setDebugValues(view, this._parser.spec, this._parser.vlspec);

view.warn = this.onWarn.bind(this);
view.error = this.onError.bind(this);
Expand Down
2 changes: 1 addition & 1 deletion src/core_plugins/vega/public/vega_visualization.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function VegaVisualizationProvider(vegaConfig, serviceSettings) {
if (vegaParser.useMap) {
throw new Error('Map mode is not yet supported in Kibana Core. You must use Kibana Vega plugin');
} else {
this._vegaView = new VegaView(vegaConfig, this._el, vegaParser, serviceSettings);
this._vegaView = new VegaView(vegaConfig, this._vis.editorMode, this._el, vegaParser, serviceSettings);
}
await this._vegaView.init();

Expand Down

0 comments on commit 28324c5

Please sign in to comment.