')
.attr('id', 'vislib-vis-fixtures')
@@ -52,11 +68,25 @@ afterEach(function() {
count = 0;
});
-export default function VislibFixtures(Private) {
- return function(visLibParams) {
- const Vis = Private(VislibVisProvider);
+const getDeps = () => {
+ const uiSettings = new Map();
+ return {
+ uiSettings,
+ vislibColor,
+ getHierarchicalTooltipFormatter,
+ getPointSeriesTooltipFormatter,
+ vislibSeriesResponseHandlerProvider,
+ vislibSlicesResponseHandlerProvider,
+ };
+};
+
+export default function getVislibFixtures(Private) {
+ setHierarchicalTooltipFormatter(Private);
+ setPointSeriesTooltipFormatter(Private);
+
+ return function(visLibParams, element) {
return new Vis(
- $visCanvas.new(),
+ element || $visCanvas.new(),
_.defaults({}, visLibParams || {}, {
addTooltip: true,
addLegend: true,
@@ -64,7 +94,8 @@ export default function VislibFixtures(Private) {
setYExtents: false,
yAxis: {},
type: 'histogram',
- })
+ }),
+ getDeps()
);
};
}
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_config_normal.json b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_config_normal.json
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_config_normal.json
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_config_normal.json
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_config_percentage.json b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_config_percentage.json
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_config_percentage.json
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_config_percentage.json
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_d3.json b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_d3.json
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_d3.json
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_d3.json
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_data_point.json b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_data_point.json
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_data_point.json
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_bar_chart_data_point.json
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_config.json b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_config.json
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_config.json
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_config.json
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_d3.json b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_d3.json
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_d3.json
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_d3.json
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_data_point.json b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_data_point.json
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_data_point.json
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/dispatch_heatmap_data_point.json
diff --git a/src/fixtures/vislib/mock_data/date_histogram/_columns.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_columns.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/date_histogram/_columns.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_columns.js
diff --git a/src/fixtures/vislib/mock_data/date_histogram/_rows.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_rows.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/date_histogram/_rows.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_rows.js
diff --git a/src/fixtures/vislib/mock_data/date_histogram/_rows_series_with_holes.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_rows_series_with_holes.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/date_histogram/_rows_series_with_holes.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_rows_series_with_holes.js
diff --git a/src/fixtures/vislib/mock_data/date_histogram/_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_series.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/date_histogram/_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_series.js
diff --git a/src/fixtures/vislib/mock_data/date_histogram/_series_monthly_interval.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_series_monthly_interval.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/date_histogram/_series_monthly_interval.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_series_monthly_interval.js
diff --git a/src/fixtures/vislib/mock_data/date_histogram/_series_neg.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_series_neg.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/date_histogram/_series_neg.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_series_neg.js
diff --git a/src/fixtures/vislib/mock_data/date_histogram/_series_pos_neg.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_series_pos_neg.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/date_histogram/_series_pos_neg.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_series_pos_neg.js
diff --git a/src/fixtures/vislib/mock_data/date_histogram/_stacked_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_stacked_series.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/date_histogram/_stacked_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/date_histogram/_stacked_series.js
diff --git a/src/fixtures/vislib/mock_data/filters/_columns.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/filters/_columns.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/filters/_columns.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/filters/_columns.js
diff --git a/src/fixtures/vislib/mock_data/filters/_rows.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/filters/_rows.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/filters/_rows.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/filters/_rows.js
diff --git a/src/fixtures/vislib/mock_data/filters/_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/filters/_series.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/filters/_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/filters/_series.js
diff --git a/src/fixtures/vislib/mock_data/geohash/_columns.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/geohash/_columns.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/geohash/_columns.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/geohash/_columns.js
diff --git a/src/fixtures/vislib/mock_data/geohash/_geo_json.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/geohash/_geo_json.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/geohash/_geo_json.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/geohash/_geo_json.js
diff --git a/src/fixtures/vislib/mock_data/geohash/_rows.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/geohash/_rows.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/geohash/_rows.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/geohash/_rows.js
diff --git a/src/fixtures/vislib/mock_data/histogram/_columns.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/histogram/_columns.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/histogram/_columns.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/histogram/_columns.js
diff --git a/src/fixtures/vislib/mock_data/histogram/_rows.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/histogram/_rows.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/histogram/_rows.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/histogram/_rows.js
diff --git a/src/fixtures/vislib/mock_data/histogram/_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/histogram/_series.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/histogram/_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/histogram/_series.js
diff --git a/src/fixtures/vislib/mock_data/histogram/_slices.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/histogram/_slices.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/histogram/_slices.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/histogram/_slices.js
diff --git a/src/fixtures/vislib/mock_data/not_enough_data/_one_point.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/not_enough_data/_one_point.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/not_enough_data/_one_point.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/not_enough_data/_one_point.js
diff --git a/src/fixtures/vislib/mock_data/range/_columns.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/range/_columns.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/range/_columns.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/range/_columns.js
diff --git a/src/fixtures/vislib/mock_data/range/_rows.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/range/_rows.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/range/_rows.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/range/_rows.js
diff --git a/src/fixtures/vislib/mock_data/range/_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/range/_series.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/range/_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/range/_series.js
diff --git a/src/fixtures/vislib/mock_data/significant_terms/_columns.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/significant_terms/_columns.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/significant_terms/_columns.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/significant_terms/_columns.js
diff --git a/src/fixtures/vislib/mock_data/significant_terms/_rows.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/significant_terms/_rows.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/significant_terms/_rows.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/significant_terms/_rows.js
diff --git a/src/fixtures/vislib/mock_data/significant_terms/_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/significant_terms/_series.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/significant_terms/_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/significant_terms/_series.js
diff --git a/src/fixtures/vislib/mock_data/stacked/_stacked.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/stacked/_stacked.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/stacked/_stacked.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/stacked/_stacked.js
diff --git a/src/fixtures/vislib/mock_data/terms/_columns.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/terms/_columns.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/terms/_columns.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/terms/_columns.js
diff --git a/src/fixtures/vislib/mock_data/terms/_rows.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/terms/_rows.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/terms/_rows.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/terms/_rows.js
diff --git a/src/fixtures/vislib/mock_data/terms/_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/terms/_series.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/terms/_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/terms/_series.js
diff --git a/src/fixtures/vislib/mock_data/terms/_seriesMultiple.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/terms/_seriesMultiple.js
similarity index 100%
rename from src/fixtures/vislib/mock_data/terms/_seriesMultiple.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/fixtures/mock_data/terms/_seriesMultiple.js
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/handler/handler.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/handler/handler.js
similarity index 87%
rename from src/legacy/ui/public/vislib/__tests__/lib/handler/handler.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/handler/handler.js
index d37d67567e8a5..b309c97d24000 100644
--- a/src/legacy/ui/public/vislib/__tests__/lib/handler/handler.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/handler/handler.js
@@ -21,13 +21,14 @@ import ngMock from 'ng_mock';
import expect from '@kbn/expect';
// Data
-import series from 'fixtures/vislib/mock_data/date_histogram/_series';
-import columns from 'fixtures/vislib/mock_data/date_histogram/_columns';
-import rows from 'fixtures/vislib/mock_data/date_histogram/_rows';
-import stackedSeries from 'fixtures/vislib/mock_data/date_histogram/_stacked_series';
+import series from '../fixtures/mock_data/date_histogram/_series';
+import columns from '../fixtures/mock_data/date_histogram/_columns';
+import rows from '../fixtures/mock_data/date_histogram/_rows';
+import stackedSeries from '../fixtures/mock_data/date_histogram/_stacked_series';
import $ from 'jquery';
-import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
-import '../../../../persisted_state';
+import 'ui/persisted_state';
+
+import getFixturesVislibVisFixtureProvider from '../fixtures/_vis_fixture';
const dateHistogramArray = [series, columns, rows, stackedSeries];
const names = ['series', 'columns', 'rows', 'stackedSeries'];
@@ -40,7 +41,8 @@ dateHistogramArray.forEach(function(data, i) {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- vis = Private(FixturesVislibVisFixtureProvider)();
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
+ vis = getVis();
persistedState = new ($injector.get('PersistedState'))();
vis.render(data, persistedState);
})
@@ -106,12 +108,12 @@ dateHistogramArray.forEach(function(data, i) {
describe('removeAll Method', function() {
beforeEach(function() {
ngMock.inject(function() {
- vis.handler.removeAll(vis.el);
+ vis.handler.removeAll(vis.element);
});
});
it('should remove all DOM elements from the el', function() {
- expect($(vis.el).children().length).to.be(0);
+ expect($(vis.element).children().length).to.be(0);
});
});
@@ -121,7 +123,7 @@ dateHistogramArray.forEach(function(data, i) {
});
it('should return an error classed DOM element with a text message', function() {
- expect($(vis.el).find('.error').length).to.be(1);
+ expect($(vis.element).find('.error').length).to.be(1);
expect($('.error h4').html()).to.be('This is an error!');
});
});
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/layout/layout.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/layout.js
similarity index 65%
rename from src/legacy/ui/public/vislib/__tests__/lib/layout/layout.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/layout.js
index 853a00d035a07..c8636f34ce6f8 100644
--- a/src/legacy/ui/public/vislib/__tests__/lib/layout/layout.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/layout.js
@@ -20,16 +20,16 @@
import d3 from 'd3';
import ngMock from 'ng_mock';
import expect from '@kbn/expect';
+import 'ui/persisted_state';
// Data
-import series from 'fixtures/vislib/mock_data/date_histogram/_series';
-import columns from 'fixtures/vislib/mock_data/date_histogram/_columns';
-import rows from 'fixtures/vislib/mock_data/date_histogram/_rows';
-import stackedSeries from 'fixtures/vislib/mock_data/date_histogram/_stacked_series';
+import series from '../fixtures/mock_data/date_histogram/_series';
+import columns from '../fixtures/mock_data/date_histogram/_columns';
+import rows from '../fixtures/mock_data/date_histogram/_rows';
+import stackedSeries from '../fixtures/mock_data/date_histogram/_stacked_series';
import $ from 'jquery';
import { Layout } from '../../../lib/layout/layout';
-import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
-import '../../../../persisted_state';
+import getFixturesVislibVisFixtureProvider from '../fixtures/_vis_fixture';
import { VisConfig } from '../../../lib/vis_config';
const dateHistogramArray = [series, columns, rows, stackedSeries];
@@ -46,7 +46,8 @@ dateHistogramArray.forEach(function(data, i) {
beforeEach(function() {
ngMock.inject(function(Private, $injector) {
- vis = Private(FixturesVislibVisFixtureProvider)();
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
+ vis = getVis();
persistedState = new ($injector.get('PersistedState'))();
vis.render(data, persistedState);
numberOfCharts = vis.handler.charts.length;
@@ -59,17 +60,17 @@ dateHistogramArray.forEach(function(data, i) {
describe('createLayout Method', function() {
it('should append all the divs', function() {
- expect($(vis.el).find('.visWrapper').length).to.be(1);
- expect($(vis.el).find('.visAxis--y').length).to.be(2);
- expect($(vis.el).find('.visWrapper__column').length).to.be(1);
- expect($(vis.el).find('.visAxis__column--y').length).to.be(2);
- expect($(vis.el).find('.y-axis-title').length).to.be.above(0);
- expect($(vis.el).find('.visAxis__splitAxes--y').length).to.be(2);
- expect($(vis.el).find('.visAxis__spacer--y').length).to.be(4);
- expect($(vis.el).find('.visWrapper__chart').length).to.be(numberOfCharts);
- expect($(vis.el).find('.visAxis--x').length).to.be(2);
- expect($(vis.el).find('.visAxis__splitAxes--x').length).to.be(2);
- expect($(vis.el).find('.x-axis-title').length).to.be.above(0);
+ expect($(vis.element).find('.visWrapper').length).to.be(1);
+ expect($(vis.element).find('.visAxis--y').length).to.be(2);
+ expect($(vis.element).find('.visWrapper__column').length).to.be(1);
+ expect($(vis.element).find('.visAxis__column--y').length).to.be(2);
+ expect($(vis.element).find('.y-axis-title').length).to.be.above(0);
+ expect($(vis.element).find('.visAxis__splitAxes--y').length).to.be(2);
+ expect($(vis.element).find('.visAxis__spacer--y').length).to.be(4);
+ expect($(vis.element).find('.visWrapper__chart').length).to.be(numberOfCharts);
+ expect($(vis.element).find('.visAxis--x').length).to.be(2);
+ expect($(vis.element).find('.visAxis__splitAxes--x').length).to.be(2);
+ expect($(vis.element).find('.x-axis-title').length).to.be.above(0);
});
});
@@ -81,35 +82,36 @@ dateHistogramArray.forEach(function(data, i) {
},
data,
persistedState,
- vis.el
+ vis.element,
+ () => undefined
);
testLayout = new Layout(visConfig);
});
it('should append a div with the correct class name', function() {
- expect($(vis.el).find('.chart').length).to.be(numberOfCharts);
+ expect($(vis.element).find('.chart').length).to.be(numberOfCharts);
});
it('should bind data to the DOM element', function() {
expect(
- !!$(vis.el)
+ !!$(vis.element)
.find('.chart')
.data()
).to.be(true);
});
it('should create children', function() {
- expect(typeof $(vis.el).find('.x-axis-div')).to.be('object');
+ expect(typeof $(vis.element).find('.x-axis-div')).to.be('object');
});
it('should call split function when provided', function() {
- expect(typeof $(vis.el).find('.x-axis-div')).to.be('object');
+ expect(typeof $(vis.element).find('.x-axis-div')).to.be('object');
});
it('should throw errors when incorrect arguments provided', function() {
expect(function() {
testLayout.layout({
- parent: vis.el,
+ parent: vis.element,
type: undefined,
class: 'chart',
});
@@ -131,7 +133,7 @@ dateHistogramArray.forEach(function(data, i) {
expect(function() {
testLayout.layout({
- parent: vis.el,
+ parent: vis.element,
type: function(d) {
return d;
},
@@ -143,26 +145,26 @@ dateHistogramArray.forEach(function(data, i) {
describe('appendElem Method', function() {
beforeEach(function() {
- vis.handler.layout.appendElem(vis.el, 'svg', 'column');
+ vis.handler.layout.appendElem(vis.element, 'svg', 'column');
vis.handler.layout.appendElem('.visChart', 'div', 'test');
});
it('should append DOM element to el with a class name', function() {
- expect(typeof $(vis.el).find('.column')).to.be('object');
- expect(typeof $(vis.el).find('.test')).to.be('object');
+ expect(typeof $(vis.element).find('.column')).to.be('object');
+ expect(typeof $(vis.element).find('.test')).to.be('object');
});
});
describe('removeAll Method', function() {
beforeEach(function() {
- d3.select(vis.el)
+ d3.select(vis.element)
.append('div')
.attr('class', 'visualize');
- vis.handler.layout.removeAll(vis.el);
+ vis.handler.layout.removeAll(vis.element);
});
it('should remove all DOM elements from the el', function() {
- expect($(vis.el).children().length).to.be(0);
+ expect($(vis.element).children().length).to.be(0);
});
});
});
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/layout/layout_types.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/layout_types.js
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/layout/layout_types.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/layout_types.js
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/splits/column_chart/splits.js
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/layout/splits/gauge_chart/splits.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/splits/gauge_chart/splits.js
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/layout/splits/gauge_chart/splits.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/splits/gauge_chart/splits.js
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/layout/types/column_layout.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/types/column_layout.js
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/layout/types/column_layout.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/layout/types/column_layout.js
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/types/point_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/types/point_series.js
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/types/point_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/types/point_series.js
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/types/testdata_linechart_percentile.json b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/types/testdata_linechart_percentile.json
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/types/testdata_linechart_percentile.json
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/types/testdata_linechart_percentile.json
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/types/testdata_linechart_percentile_result.json b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/types/testdata_linechart_percentile_result.json
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/lib/types/testdata_linechart_percentile_result.json
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/types/testdata_linechart_percentile_result.json
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/vis_config.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/vis_config.js
similarity index 98%
rename from src/legacy/ui/public/vislib/__tests__/lib/vis_config.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/vis_config.js
index c9dcd4737b51a..3f0253b4a4670 100644
--- a/src/legacy/ui/public/vislib/__tests__/lib/vis_config.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/vis_config.js
@@ -20,8 +20,8 @@
import d3 from 'd3';
import ngMock from 'ng_mock';
import expect from '@kbn/expect';
+import 'ui/persisted_state';
import { VisConfig } from '../../lib/vis_config';
-import '../../../persisted_state';
describe('Vislib VisConfig Class Test Suite', function() {
let el;
@@ -101,7 +101,8 @@ describe('Vislib VisConfig Class Test Suite', function() {
},
data,
new PersistedState(),
- el
+ el,
+ () => undefined
);
})
);
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/x_axis.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/x_axis.js
similarity index 98%
rename from src/legacy/ui/public/vislib/__tests__/lib/x_axis.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/x_axis.js
index 2fb7763756975..09fe067537c7f 100644
--- a/src/legacy/ui/public/vislib/__tests__/lib/x_axis.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/x_axis.js
@@ -21,8 +21,8 @@ import d3 from 'd3';
import _ from 'lodash';
import ngMock from 'ng_mock';
import expect from '@kbn/expect';
+import 'ui/persisted_state';
import $ from 'jquery';
-import '../../../persisted_state';
import { Axis } from '../../lib/axis';
import { VisConfig } from '../../lib/vis_config';
@@ -124,7 +124,8 @@ describe('Vislib xAxis Class Test Suite', function() {
},
data,
persistedState,
- $('.x-axis-div')[0]
+ $('.x-axis-div')[0],
+ () => undefined
);
xAxis = new Axis(visConfig, {
type: 'category',
diff --git a/src/legacy/ui/public/vislib/__tests__/lib/y_axis.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/y_axis.js
similarity index 99%
rename from src/legacy/ui/public/vislib/__tests__/lib/y_axis.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/y_axis.js
index 0189b8b960d32..e857aca3bf3ed 100644
--- a/src/legacy/ui/public/vislib/__tests__/lib/y_axis.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/lib/y_axis.js
@@ -21,8 +21,8 @@ import _ from 'lodash';
import d3 from 'd3';
import ngMock from 'ng_mock';
import expect from '@kbn/expect';
+import 'ui/persisted_state';
import $ from 'jquery';
-import '../../../persisted_state';
import { Axis } from '../../lib/axis';
import { VisConfig } from '../../lib/vis_config';
@@ -97,7 +97,8 @@ function createData(seriesData) {
},
data,
persistedState,
- node
+ node,
+ () => undefined
);
return new YAxis(
visConfig,
diff --git a/src/legacy/ui/public/vislib/__tests__/vis.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/vis.js
similarity index 92%
rename from src/legacy/ui/public/vislib/__tests__/vis.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/vis.js
index f10f44b7100d8..a6d1c4daf5d2c 100644
--- a/src/legacy/ui/public/vislib/__tests__/vis.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/vis.js
@@ -18,16 +18,17 @@
*/
import _ from 'lodash';
-import expect from '@kbn/expect';
+import $ from 'jquery';
import ngMock from 'ng_mock';
-import series from 'fixtures/vislib/mock_data/date_histogram/_series';
-import columns from 'fixtures/vislib/mock_data/date_histogram/_columns';
-import rows from 'fixtures/vislib/mock_data/date_histogram/_rows';
-import stackedSeries from 'fixtures/vislib/mock_data/date_histogram/_stacked_series';
-import $ from 'jquery';
-import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
-import '../../persisted_state';
+import expect from '@kbn/expect';
+import 'ui/persisted_state';
+
+import series from './lib/fixtures/mock_data/date_histogram/_series';
+import columns from './lib/fixtures/mock_data/date_histogram/_columns';
+import rows from './lib/fixtures/mock_data/date_histogram/_rows';
+import stackedSeries from './lib/fixtures/mock_data/date_histogram/_stacked_series';
+import getFixturesVislibVisFixtureProvider from './lib/fixtures/_vis_fixture';
const dataArray = [series, columns, rows, stackedSeries];
@@ -45,9 +46,10 @@ dataArray.forEach(function(data, i) {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- vis = Private(FixturesVislibVisFixtureProvider)();
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
+ vis = getVis();
persistedState = new ($injector.get('PersistedState'))();
- secondVis = Private(FixturesVislibVisFixtureProvider)();
+ secondVis = getVis();
})
);
@@ -99,7 +101,7 @@ dataArray.forEach(function(data, i) {
});
it('should not remove visualizations that have not been destroyed', function() {
- expect($(vis.el).find('.visWrapper').length).to.be(1);
+ expect($(vis.element).find('.visWrapper').length).to.be(1);
});
});
diff --git a/src/legacy/ui/public/vislib/__tests__/visualizations/area_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/area_chart.js
similarity index 93%
rename from src/legacy/ui/public/vislib/__tests__/visualizations/area_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/area_chart.js
index d81fd66f1e111..7fe350bd85e05 100644
--- a/src/legacy/ui/public/vislib/__tests__/visualizations/area_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/area_chart.js
@@ -18,20 +18,22 @@
*/
import d3 from 'd3';
-import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import _ from 'lodash';
-
import $ from 'jquery';
-import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
-import '../../../persisted_state';
+
+import expect from '@kbn/expect';
+import 'ui/persisted_state';
+
+import getFixturesVislibVisFixtureProvider from '../lib/fixtures/_vis_fixture';
+
const dataTypesArray = {
- 'series pos': require('fixtures/vislib/mock_data/date_histogram/_series'),
- 'series pos neg': require('fixtures/vislib/mock_data/date_histogram/_series_pos_neg'),
- 'series neg': require('fixtures/vislib/mock_data/date_histogram/_series_neg'),
- 'term columns': require('fixtures/vislib/mock_data/terms/_columns'),
- 'range rows': require('fixtures/vislib/mock_data/range/_rows'),
- stackedSeries: require('fixtures/vislib/mock_data/date_histogram/_stacked_series'),
+ 'series pos': require('../lib/fixtures/mock_data/date_histogram/_series'),
+ 'series pos neg': require('../lib/fixtures/mock_data/date_histogram/_series_pos_neg'),
+ 'series neg': require('../lib/fixtures/mock_data/date_histogram/_series_neg'),
+ 'term columns': require('../lib/fixtures/mock_data/terms/_columns'),
+ 'range rows': require('../lib/fixtures/mock_data/range/_rows'),
+ stackedSeries: require('../lib/fixtures/mock_data/date_histogram/_stacked_series'),
};
const visLibParams = {
@@ -49,7 +51,8 @@ _.forOwn(dataTypesArray, function(dataType, dataTypeName) {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- vis = Private(FixturesVislibVisFixtureProvider)(visLibParams);
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
+ vis = getVis(visLibParams);
persistedState = new ($injector.get('PersistedState'))();
vis.on('brush', _.noop);
vis.render(dataType, persistedState);
diff --git a/src/legacy/ui/public/vislib/__tests__/visualizations/chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/chart.js
similarity index 93%
rename from src/legacy/ui/public/vislib/__tests__/visualizations/chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/chart.js
index f876db0aa6b22..088d3377af4dd 100644
--- a/src/legacy/ui/public/vislib/__tests__/visualizations/chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/chart.js
@@ -18,15 +18,16 @@
*/
import d3 from 'd3';
-import expect from '@kbn/expect';
import ngMock from 'ng_mock';
-import { VislibVisProvider } from '../../vis';
-import '../../../persisted_state';
+
+import expect from '@kbn/expect';
+import 'ui/persisted_state';
+
import { Chart } from '../../visualizations/_chart';
+import getFixturesVislibVisFixtureProvider from '../lib/fixtures/_vis_fixture';
describe('Vislib _chart Test Suite', function() {
let persistedState;
- let Vis;
let vis;
let el;
let myChart;
@@ -111,7 +112,7 @@ describe('Vislib _chart Test Suite', function() {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- Vis = Private(VislibVisProvider);
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
persistedState = new ($injector.get('PersistedState'))();
el = d3
@@ -126,7 +127,7 @@ describe('Vislib _chart Test Suite', function() {
zeroFill: true,
};
- vis = new Vis(el[0][0], config);
+ vis = getVis(config, el[0][0]);
vis.render(data, persistedState);
myChart = vis.handler.charts[0];
diff --git a/src/legacy/ui/public/vislib/__tests__/visualizations/column_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/column_chart.js
similarity index 91%
rename from src/legacy/ui/public/vislib/__tests__/visualizations/column_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/column_chart.js
index 2253783e7e644..d02060ef29bdd 100644
--- a/src/legacy/ui/public/vislib/__tests__/visualizations/column_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/column_chart.js
@@ -17,24 +17,25 @@
* under the License.
*/
-import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import _ from 'lodash';
import d3 from 'd3';
+import expect from '@kbn/expect';
+import 'ui/persisted_state';
+
// Data
-import series from 'fixtures/vislib/mock_data/date_histogram/_series';
-import seriesPosNeg from 'fixtures/vislib/mock_data/date_histogram/_series_pos_neg';
-import seriesNeg from 'fixtures/vislib/mock_data/date_histogram/_series_neg';
-import termsColumns from 'fixtures/vislib/mock_data/terms/_columns';
-import histogramRows from 'fixtures/vislib/mock_data/histogram/_rows';
-import stackedSeries from 'fixtures/vislib/mock_data/date_histogram/_stacked_series';
-import { seriesMonthlyInterval } from 'fixtures/vislib/mock_data/date_histogram/_series_monthly_interval';
-import { rowsSeriesWithHoles } from 'fixtures/vislib/mock_data/date_histogram/_rows_series_with_holes';
-import rowsWithZeros from 'fixtures/vislib/mock_data/date_histogram/_rows';
+import series from '../lib/fixtures/mock_data/date_histogram/_series';
+import seriesPosNeg from '../lib/fixtures/mock_data/date_histogram/_series_pos_neg';
+import seriesNeg from '../lib/fixtures/mock_data/date_histogram/_series_neg';
+import termsColumns from '../lib/fixtures/mock_data/terms/_columns';
+import histogramRows from '../lib/fixtures/mock_data/histogram/_rows';
+import stackedSeries from '../lib/fixtures/mock_data/date_histogram/_stacked_series';
+import { seriesMonthlyInterval } from '../lib/fixtures/mock_data/date_histogram/_series_monthly_interval';
+import { rowsSeriesWithHoles } from '../lib/fixtures/mock_data/date_histogram/_rows_series_with_holes';
+import rowsWithZeros from '../lib/fixtures/mock_data/date_histogram/_rows';
import $ from 'jquery';
-import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
-import '../../../persisted_state';
+import getFixturesVislibVisFixtureProvider from '../lib/fixtures/_vis_fixture';
// tuple, with the format [description, mode, data]
const dataTypesArray = [
@@ -69,7 +70,8 @@ dataTypesArray.forEach(function(dataType) {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- vis = Private(FixturesVislibVisFixtureProvider)(visLibParams);
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
+ vis = getVis(visLibParams);
persistedState = new ($injector.get('PersistedState'))();
vis.on('brush', _.noop);
vis.render(data, persistedState);
@@ -257,7 +259,8 @@ describe('stackData method - data set with zeros in percentage mode', function()
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- vis = Private(FixturesVislibVisFixtureProvider)(visLibParams);
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
+ vis = getVis(visLibParams);
persistedState = new ($injector.get('PersistedState'))();
vis.on('brush', _.noop);
})
@@ -307,7 +310,8 @@ describe('datumWidth - split chart data set with holes', function() {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- vis = Private(FixturesVislibVisFixtureProvider)(visLibParams);
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
+ vis = getVis(visLibParams);
persistedState = new ($injector.get('PersistedState'))();
vis.on('brush', _.noop);
vis.render(rowsSeriesWithHoles, persistedState);
@@ -344,7 +348,8 @@ describe('datumWidth - monthly interval', function() {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- vis = Private(FixturesVislibVisFixtureProvider)(visLibParams);
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
+ vis = getVis(visLibParams);
persistedState = new ($injector.get('PersistedState'))();
vis.on('brush', _.noop);
vis.render(seriesMonthlyInterval, persistedState);
diff --git a/src/legacy/ui/public/vislib/__tests__/visualizations/gauge_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/gauge_chart.js
similarity index 94%
rename from src/legacy/ui/public/vislib/__tests__/visualizations/gauge_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/gauge_chart.js
index 45d9d4a2e374b..074b34e1c03c4 100644
--- a/src/legacy/ui/public/vislib/__tests__/visualizations/gauge_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/gauge_chart.js
@@ -17,13 +17,15 @@
* under the License.
*/
-import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import $ from 'jquery';
import _ from 'lodash';
-import data from 'fixtures/vislib/mock_data/terms/_seriesMultiple';
-import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
-import '../../../persisted_state';
+
+import expect from '@kbn/expect';
+import 'ui/persisted_state';
+
+import data from '../lib/fixtures/mock_data/terms/_seriesMultiple';
+import getFixturesVislibVisFixtureProvider from '../lib/fixtures/_vis_fixture';
describe('Vislib Gauge Chart Test Suite', function() {
let PersistedState;
@@ -89,7 +91,7 @@ describe('Vislib Gauge Chart Test Suite', function() {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- vislibVis = Private(FixturesVislibVisFixtureProvider);
+ vislibVis = getFixturesVislibVisFixtureProvider(Private);
PersistedState = $injector.get('PersistedState');
generateVis();
})
diff --git a/src/legacy/ui/public/vislib/__tests__/visualizations/heatmap_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/heatmap_chart.js
similarity index 92%
rename from src/legacy/ui/public/vislib/__tests__/visualizations/heatmap_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/heatmap_chart.js
index f1dc4bf07ee31..bf1dbad0b44cf 100644
--- a/src/legacy/ui/public/vislib/__tests__/visualizations/heatmap_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/heatmap_chart.js
@@ -17,20 +17,21 @@
* under the License.
*/
-import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import _ from 'lodash';
import d3 from 'd3';
+import expect from '@kbn/expect';
+import 'ui/persisted_state';
+
// Data
-import series from 'fixtures/vislib/mock_data/date_histogram/_series';
-import seriesPosNeg from 'fixtures/vislib/mock_data/date_histogram/_series_pos_neg';
-import seriesNeg from 'fixtures/vislib/mock_data/date_histogram/_series_neg';
-import termsColumns from 'fixtures/vislib/mock_data/terms/_columns';
-import stackedSeries from 'fixtures/vislib/mock_data/date_histogram/_stacked_series';
+import series from '../lib/fixtures/mock_data/date_histogram/_series';
+import seriesPosNeg from '../lib/fixtures/mock_data/date_histogram/_series_pos_neg';
+import seriesNeg from '../lib/fixtures/mock_data/date_histogram/_series_neg';
+import termsColumns from '../lib/fixtures/mock_data/terms/_columns';
+import stackedSeries from '../lib/fixtures/mock_data/date_histogram/_stacked_series';
import $ from 'jquery';
-import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
-import '../../../persisted_state';
+import getFixturesVislibVisFixtureProvider from '../lib/fixtures/_vis_fixture';
// tuple, with the format [description, mode, data]
const dataTypesArray = [
@@ -74,7 +75,7 @@ describe('Vislib Heatmap Chart Test Suite', function() {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- vislibVis = Private(FixturesVislibVisFixtureProvider);
+ vislibVis = getFixturesVislibVisFixtureProvider(Private);
PersistedState = $injector.get('PersistedState');
generateVis();
})
diff --git a/src/legacy/ui/public/vislib/__tests__/visualizations/line_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/line_chart.js
similarity index 92%
rename from src/legacy/ui/public/vislib/__tests__/visualizations/line_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/line_chart.js
index 354be1f0ced0f..d010944a19e47 100644
--- a/src/legacy/ui/public/vislib/__tests__/visualizations/line_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/line_chart.js
@@ -20,18 +20,19 @@
import d3 from 'd3';
import expect from '@kbn/expect';
import ngMock from 'ng_mock';
+import $ from 'jquery';
import _ from 'lodash';
+import 'ui/persisted_state';
+
// Data
-import seriesPos from 'fixtures/vislib/mock_data/date_histogram/_series';
-import seriesPosNeg from 'fixtures/vislib/mock_data/date_histogram/_series_pos_neg';
-import seriesNeg from 'fixtures/vislib/mock_data/date_histogram/_series_neg';
-import histogramColumns from 'fixtures/vislib/mock_data/histogram/_columns';
-import rangeRows from 'fixtures/vislib/mock_data/range/_rows';
-import termSeries from 'fixtures/vislib/mock_data/terms/_series';
-import $ from 'jquery';
-import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
-import '../../../persisted_state';
+import seriesPos from '../lib/fixtures/mock_data/date_histogram/_series';
+import seriesPosNeg from '../lib/fixtures/mock_data/date_histogram/_series_pos_neg';
+import seriesNeg from '../lib/fixtures/mock_data/date_histogram/_series_neg';
+import histogramColumns from '../lib/fixtures/mock_data/histogram/_columns';
+import rangeRows from '../lib/fixtures/mock_data/range/_rows';
+import termSeries from '../lib/fixtures/mock_data/terms/_series';
+import getFixturesVislibVisFixtureProvider from '../lib/fixtures/_vis_fixture';
const dataTypes = [
['series pos', seriesPos],
@@ -54,6 +55,7 @@ describe('Vislib Line Chart', function() {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
const visLibParams = {
type: 'line',
addLegend: true,
@@ -61,10 +63,10 @@ describe('Vislib Line Chart', function() {
drawLinesBetweenPoints: true,
};
- vis = Private(FixturesVislibVisFixtureProvider)(visLibParams);
+ vis = getVis(visLibParams);
persistedState = new ($injector.get('PersistedState'))();
- vis.on('brush', _.noop);
vis.render(data, persistedState);
+ vis.on('brush', _.noop);
})
);
diff --git a/src/legacy/ui/public/vislib/__tests__/visualizations/pie_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/pie_chart.js
similarity index 94%
rename from src/legacy/ui/public/vislib/__tests__/visualizations/pie_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/pie_chart.js
index 9d299c4d3a5df..381dfcd387cc2 100644
--- a/src/legacy/ui/public/vislib/__tests__/visualizations/pie_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/pie_chart.js
@@ -18,17 +18,20 @@
*/
import d3 from 'd3';
-import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import _ from 'lodash';
-import fixtures from 'fixtures/fake_hierarchical_data';
import $ from 'jquery';
-import FixturesVislibVisFixtureProvider from 'fixtures/vislib/_vis_fixture';
-import { Vis } from '../../../vis';
-import '../../../persisted_state';
+
+import expect from '@kbn/expect';
+// TODO: Remove ui imports once converting to jest
+import 'ui/persisted_state';
+import { vislibSlicesResponseHandlerProvider } from 'ui/vis/response_handlers/vislib';
+
+import fixtures from 'fixtures/fake_hierarchical_data';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
-import { vislibSlicesResponseHandlerProvider } from '../../../vis/response_handlers/vislib';
-import { tabifyAggResponse } from '../../../agg_response/tabify';
+
+import getFixturesVislibVisFixtureProvider from '../lib/fixtures/_vis_fixture';
+import { Vis, tabifyAggResponse } from '../../../legacy_imports';
const rowAgg = [
{ type: 'avg', schema: 'metric', params: { field: 'bytes' } },
@@ -129,7 +132,8 @@ describe('No global chart settings', function() {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- chart1 = Private(FixturesVislibVisFixtureProvider)(visLibParams1);
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
+ chart1 = getVis(visLibParams1);
persistedState = new ($injector.get('PersistedState'))();
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
responseHandler = vislibSlicesResponseHandlerProvider().handler;
@@ -163,7 +167,7 @@ describe('No global chart settings', function() {
});
it('should render chart titles for all charts', function() {
- expect($(chart1.el).find('.visAxis__splitTitles--y').length).to.be(1);
+ expect($(chart1.element).find('.visAxis__splitTitles--y').length).to.be(1);
});
describe('_validatePieData method', function() {
@@ -221,7 +225,8 @@ describe('Vislib PieChart Class Test Suite', function() {
beforeEach(ngMock.module('kibana'));
beforeEach(
ngMock.inject(function(Private, $injector) {
- vis = Private(FixturesVislibVisFixtureProvider)(visLibParams);
+ const getVis = getFixturesVislibVisFixtureProvider(Private);
+ vis = getVis(visLibParams);
persistedState = new ($injector.get('PersistedState'))();
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
responseHandler = vislibSlicesResponseHandlerProvider().handler;
diff --git a/src/legacy/ui/public/vislib/__tests__/visualizations/time_marker.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/time_marker.js
similarity index 97%
rename from src/legacy/ui/public/vislib/__tests__/visualizations/time_marker.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/time_marker.js
index cfe61d6f35198..ec22d43c08cb2 100644
--- a/src/legacy/ui/public/vislib/__tests__/visualizations/time_marker.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/time_marker.js
@@ -20,8 +20,8 @@
import d3 from 'd3';
import expect from '@kbn/expect';
import ngMock from 'ng_mock';
-import series from 'fixtures/vislib/mock_data/date_histogram/_series';
-import terms from 'fixtures/vislib/mock_data/terms/_columns';
+import series from '../lib/fixtures/mock_data/date_histogram/_series';
+import terms from '../lib/fixtures/mock_data/terms/_columns';
import $ from 'jquery';
import { TimeMarker } from '../../visualizations/time_marker';
diff --git a/src/legacy/ui/public/vislib/__tests__/visualizations/vis_types.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/vis_types.js
similarity index 100%
rename from src/legacy/ui/public/vislib/__tests__/visualizations/vis_types.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/__tests__/visualizations/vis_types.js
diff --git a/src/legacy/ui/public/vislib/_index.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/_index.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/_index.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/_index.scss
diff --git a/src/legacy/ui/public/vislib/_variables.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/_variables.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/_variables.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/_variables.scss
diff --git a/src/legacy/ui/public/vislib/components/labels/data_array.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/data_array.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/labels/data_array.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/data_array.js
diff --git a/src/legacy/ui/public/vislib/components/labels/flatten_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/flatten_series.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/labels/flatten_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/flatten_series.js
diff --git a/src/legacy/ui/public/vislib/components/labels/index.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/index.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/labels/index.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/index.js
diff --git a/src/legacy/ui/public/vislib/components/labels/labels.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/labels.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/labels/labels.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/labels.js
diff --git a/src/legacy/ui/public/vislib/components/labels/truncate_labels.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/truncate_labels.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/labels/truncate_labels.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/truncate_labels.js
diff --git a/src/legacy/ui/public/vislib/components/labels/uniq_labels.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/uniq_labels.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/labels/uniq_labels.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/labels/uniq_labels.js
diff --git a/src/legacy/ui/public/vislib/components/zero_injection/flatten_data.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/flatten_data.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/zero_injection/flatten_data.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/flatten_data.js
diff --git a/src/legacy/ui/public/vislib/components/zero_injection/inject_zeros.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/inject_zeros.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/zero_injection/inject_zeros.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/inject_zeros.js
diff --git a/src/legacy/ui/public/vislib/components/zero_injection/ordered_x_keys.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/ordered_x_keys.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/zero_injection/ordered_x_keys.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/ordered_x_keys.js
diff --git a/src/legacy/ui/public/vislib/components/zero_injection/uniq_keys.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/uniq_keys.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/zero_injection/uniq_keys.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/uniq_keys.js
diff --git a/src/legacy/ui/public/vislib/components/zero_injection/zero_fill_data_array.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/zero_fill_data_array.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/zero_injection/zero_fill_data_array.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/zero_fill_data_array.js
diff --git a/src/legacy/ui/public/vislib/components/zero_injection/zero_filled_array.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/zero_filled_array.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/zero_injection/zero_filled_array.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/zero_filled_array.js
diff --git a/src/legacy/ui/public/vislib/components/zero_injection/zero_injection.test.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/zero_injection.test.js
similarity index 100%
rename from src/legacy/ui/public/vislib/components/zero_injection/zero_injection.test.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/components/zero_injection/zero_injection.test.js
diff --git a/src/legacy/ui/public/vislib/errors.ts b/src/legacy/core_plugins/vis_type_vislib/public/vislib/errors.ts
similarity index 95%
rename from src/legacy/ui/public/vislib/errors.ts
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/errors.ts
index 0c6e720f0ef32..9014349c38d25 100644
--- a/src/legacy/ui/public/vislib/errors.ts
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/errors.ts
@@ -19,7 +19,7 @@
/* eslint-disable max-classes-per-file */
-import { KbnError } from '../../../../plugins/kibana_utils/public';
+import { KbnError } from '../../../../../plugins/kibana_utils/public';
export class VislibError extends KbnError {
constructor(message: string) {
diff --git a/src/legacy/ui/public/vislib/index.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/index.js
similarity index 100%
rename from src/legacy/ui/public/vislib/index.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/index.js
diff --git a/src/legacy/ui/public/vislib/lib/_alerts.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/_alerts.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/_alerts.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/_alerts.scss
diff --git a/src/legacy/ui/public/vislib/lib/_data_label.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/_data_label.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/_data_label.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/_data_label.js
diff --git a/src/legacy/ui/public/vislib/lib/_error_handler.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/_error_handler.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/_error_handler.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/_error_handler.js
diff --git a/src/legacy/ui/public/vislib/lib/_handler.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/_handler.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/_handler.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/_handler.scss
diff --git a/src/legacy/ui/public/vislib/lib/_index.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/_index.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/_index.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/_index.scss
diff --git a/src/legacy/ui/public/vislib/lib/alerts.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/alerts.js
similarity index 97%
rename from src/legacy/ui/public/vislib/lib/alerts.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/alerts.js
index cf79dabf1b07e..086b4e31be1a3 100644
--- a/src/legacy/ui/public/vislib/lib/alerts.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/alerts.js
@@ -71,11 +71,11 @@ export class Alerts {
const alerts = this.alerts;
const vis = this.vis;
- $(vis.el)
+ $(vis.element)
.find('.visWrapper__alerts')
.append($('
').addClass('visAlerts__tray'));
if (!alerts.size()) return;
- $(vis.el)
+ $(vis.element)
.find('.visAlerts__tray')
.append(alerts.value());
}
@@ -89,13 +89,13 @@ export class Alerts {
};
if (this.alertDefs.find(alertDef => alertDef.msg === alert.msg)) return;
this.alertDefs.push(alert);
- $(vis.el)
+ $(vis.element)
.find('.visAlerts__tray')
.append(this._addAlert(alert));
}
destroy() {
- $(this.vis.el)
+ $(this.vis.element)
.find('.visWrapper__alerts')
.remove();
}
diff --git a/src/legacy/ui/public/vislib/lib/axis/axis.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/axis.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/axis/axis.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/axis.js
diff --git a/src/legacy/ui/public/vislib/lib/axis/axis_config.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/axis_config.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/axis/axis_config.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/axis_config.js
diff --git a/src/legacy/ui/public/vislib/lib/axis/axis_labels.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/axis_labels.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/axis/axis_labels.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/axis_labels.js
diff --git a/src/legacy/ui/public/vislib/lib/axis/axis_scale.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/axis_scale.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/axis/axis_scale.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/axis_scale.js
diff --git a/src/legacy/ui/public/vislib/lib/axis/axis_title.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/axis_title.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/axis/axis_title.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/axis_title.js
diff --git a/src/legacy/ui/public/vislib/lib/axis/index.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/index.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/axis/index.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/index.js
diff --git a/src/legacy/ui/public/vislib/lib/axis/scale_modes.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/scale_modes.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/axis/scale_modes.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/scale_modes.js
diff --git a/src/legacy/ui/public/vislib/lib/axis/time_ticks.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/time_ticks.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/axis/time_ticks.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/time_ticks.js
diff --git a/src/legacy/ui/public/vislib/lib/axis/time_ticks.test.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/time_ticks.test.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/axis/time_ticks.test.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/axis/time_ticks.test.js
diff --git a/src/legacy/ui/public/vislib/lib/chart_grid.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/chart_grid.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/chart_grid.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/chart_grid.js
diff --git a/src/legacy/ui/public/vislib/lib/chart_title.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/chart_title.js
similarity index 98%
rename from src/legacy/ui/public/vislib/lib/chart_title.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/chart_title.js
index f79d14a3deaa6..1c84f98614b05 100644
--- a/src/legacy/ui/public/vislib/lib/chart_title.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/chart_title.js
@@ -19,8 +19,9 @@
import d3 from 'd3';
import _ from 'lodash';
+
import { ErrorHandler } from './_error_handler';
-import { Tooltip } from '../../vis/components/tooltip';
+import { Tooltip } from '../../legacy_imports';
export class ChartTitle extends ErrorHandler {
constructor(visConfig) {
diff --git a/src/legacy/ui/public/vislib/lib/data.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/data.js
similarity index 98%
rename from src/legacy/ui/public/vislib/lib/data.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/data.js
index c10449c681a3c..c7824c43eeec5 100644
--- a/src/legacy/ui/public/vislib/lib/data.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/data.js
@@ -19,11 +19,11 @@
import d3 from 'd3';
import _ from 'lodash';
+
import { injectZeros } from '../components/zero_injection/inject_zeros';
import { orderXValues } from '../components/zero_injection/ordered_x_keys';
import { labels } from '../components/labels/labels';
-import { vislibColor } from '../../vis/components/color/color';
-import { getFormat } from '../../visualize/loader/pipeline_helpers/utilities';
+import { getFormat } from '../../legacy_imports';
/**
* Provides an API for pulling values off the data
@@ -35,8 +35,9 @@ import { getFormat } from '../../visualize/loader/pipeline_helpers/utilities';
* @param attr {Object|*} Visualization options
*/
export class Data {
- constructor(data, uiState) {
+ constructor(data, uiState, vislibColor) {
this.uiState = uiState;
+ this.vislibColor = vislibColor;
this.data = this.copyDataObj(data);
this.type = this.getDataType();
this._cleanVisData();
@@ -472,7 +473,7 @@ export class Data {
const defaultColors = this.uiState.get('vis.defaultColors');
const overwriteColors = this.uiState.get('vis.colors');
const colors = defaultColors ? _.defaults({}, overwriteColors, defaultColors) : overwriteColors;
- return vislibColor(this.getLabels(), colors);
+ return this.vislibColor(this.getLabels(), colors);
}
/**
@@ -482,7 +483,7 @@ export class Data {
* @returns {Function} Performs lookup on string and returns hex color
*/
getPieColorFunc() {
- return vislibColor(
+ return this.vislibColor(
this.pieNames(this.getVisData()).map(function(d) {
return d.label;
}),
diff --git a/src/legacy/ui/public/vislib/lib/dispatch.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/dispatch.js
similarity index 92%
rename from src/legacy/ui/public/vislib/lib/dispatch.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/dispatch.js
index fb5cc127c27fd..404f7ef82d97f 100644
--- a/src/legacy/ui/public/vislib/lib/dispatch.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/dispatch.js
@@ -20,10 +20,8 @@
import d3 from 'd3';
import { get } from 'lodash';
import $ from 'jquery';
-import { SimpleEmitter } from '../../utils/simple_emitter';
-import chrome from 'ui/chrome';
-const config = chrome.getUiSettingsClient();
+import { SimpleEmitter } from '../../legacy_imports';
/**
* Handles event responses
@@ -33,9 +31,10 @@ const config = chrome.getUiSettingsClient();
* @param handler {Object} Reference to Handler Class Object
*/
export class Dispatch extends SimpleEmitter {
- constructor(handler) {
+ constructor(handler, uiSettings) {
super();
this.handler = handler;
+ this.uiSettings = uiSettings;
this._listeners = {};
}
@@ -196,7 +195,7 @@ export class Dispatch extends SimpleEmitter {
const addEvent = this.addEvent;
const $el = this.handler.el;
if (!this.handler.highlight) {
- this.handler.highlight = self.highlight;
+ this.handler.highlight = self.getHighlighter(self.uiSettings);
}
function hover(d, i) {
@@ -289,21 +288,23 @@ export class Dispatch extends SimpleEmitter {
}
/**
- * Highlight the element that is under the cursor
+ * return function to Highlight the element that is under the cursor
* by reducing the opacity of all the elements on the graph.
- * @param element {d3.Selection}
- * @method highlight
+ * @param uiSettings
+ * @method getHighlighter
*/
- highlight(element) {
- const label = this.getAttribute('data-label');
- if (!label) return;
- const dimming = config.get('visualization:dimmingOpacity');
- $(element)
- .parent()
- .find('[data-label]')
- .css('opacity', 1) //Opacity 1 is needed to avoid the css application
- .not((els, el) => String($(el).data('label')) === label)
- .css('opacity', justifyOpacity(dimming));
+ getHighlighter(uiSettings) {
+ return function highlight(element) {
+ const label = this.getAttribute('data-label');
+ if (!label) return;
+ const dimming = uiSettings.get('visualization:dimmingOpacity');
+ $(element)
+ .parent()
+ .find('[data-label]')
+ .css('opacity', 1) //Opacity 1 is needed to avoid the css application
+ .not((els, el) => String($(el).data('label')) === label)
+ .css('opacity', justifyOpacity(dimming));
+ };
}
/**
diff --git a/src/legacy/ui/public/vislib/lib/handler.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/handler.js
similarity index 96%
rename from src/legacy/ui/public/vislib/lib/handler.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/handler.js
index 6047faa0c6b15..b887b61578cc4 100644
--- a/src/legacy/ui/public/vislib/lib/handler.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/handler.js
@@ -20,15 +20,16 @@
import d3 from 'd3';
import _ from 'lodash';
import MarkdownIt from 'markdown-it';
+
import { NoResults } from '../errors';
-import { Binder } from '../../binder';
import { Layout } from './layout/layout';
import { ChartTitle } from './chart_title';
import { Alerts } from './alerts';
import { Axis } from './axis/axis';
import { ChartGrid as Grid } from './chart_grid';
import { visTypes as chartTypes } from '../visualizations/vis_types';
-import { dispatchRenderComplete } from '../../../../../plugins/kibana_utils/public';
+import { Binder } from '../../legacy_imports';
+import { dispatchRenderComplete } from '../../../../../../plugins/kibana_utils/public';
const markdownIt = new MarkdownIt({
html: false,
@@ -45,9 +46,10 @@ const markdownIt = new MarkdownIt({
* create the visualization
*/
export class Handler {
- constructor(vis, visConfig) {
+ constructor(vis, visConfig, deps) {
this.el = visConfig.get('el');
this.ChartClass = chartTypes[visConfig.get('type')];
+ this.deps = deps;
this.charts = [];
this.vis = vis;
@@ -151,7 +153,7 @@ export class Handler {
let loadedCount = 0;
const chartSelection = selection.selectAll('.chart');
chartSelection.each(function(chartData) {
- const chart = new self.ChartClass(self, this, chartData);
+ const chart = new self.ChartClass(self, this, chartData, self.deps);
self.vis.eventNames().forEach(function(event) {
self.enable(event, chart);
diff --git a/src/legacy/ui/public/vislib/lib/layout/_index.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/_index.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/_index.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/_index.scss
diff --git a/src/legacy/ui/public/vislib/lib/layout/_layout.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/_layout.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/_layout.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/_layout.scss
diff --git a/src/legacy/ui/public/vislib/lib/layout/index.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/index.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/index.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/index.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/layout.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/layout.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/layout.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/layout.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/layout_types.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/layout_types.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/layout_types.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/layout_types.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/splits/column_chart/chart_split.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/column_chart/chart_split.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/splits/column_chart/chart_split.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/column_chart/chart_split.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/column_chart/chart_title_split.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/splits/column_chart/chart_title_split.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/column_chart/chart_title_split.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/splits/column_chart/x_axis_split.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/column_chart/x_axis_split.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/splits/column_chart/x_axis_split.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/column_chart/x_axis_split.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/splits/column_chart/y_axis_split.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/column_chart/y_axis_split.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/splits/column_chart/y_axis_split.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/column_chart/y_axis_split.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/gauge_chart/chart_split.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_split.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/gauge_chart/chart_split.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/gauge_chart/chart_title_split.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/pie_chart/chart_split.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/splits/pie_chart/chart_split.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/pie_chart/chart_split.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/splits/pie_chart/chart_title_split.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/types/column_layout.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/types/column_layout.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/types/column_layout.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/types/column_layout.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/types/gauge_layout.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/types/gauge_layout.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/types/gauge_layout.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/types/gauge_layout.js
diff --git a/src/legacy/ui/public/vislib/lib/layout/types/pie_layout.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/types/pie_layout.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/layout/types/pie_layout.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/layout/types/pie_layout.js
diff --git a/src/legacy/ui/public/vislib/lib/types/gauge.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/gauge.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/types/gauge.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/gauge.js
diff --git a/src/legacy/ui/public/vislib/lib/types/index.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/index.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/types/index.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/index.js
diff --git a/src/legacy/ui/public/vislib/lib/types/pie.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/pie.js
similarity index 100%
rename from src/legacy/ui/public/vislib/lib/types/pie.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/pie.js
diff --git a/src/legacy/ui/public/vislib/lib/types/point_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/point_series.js
similarity index 98%
rename from src/legacy/ui/public/vislib/lib/types/point_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/point_series.js
index 332f7408ebc66..eab3bc02f4eec 100644
--- a/src/legacy/ui/public/vislib/lib/types/point_series.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/point_series.js
@@ -202,7 +202,7 @@ export const vislibPointSeriesTypes = {
'Positive and negative values are not accurately represented by stacked ' +
'area charts. Either changing the chart mode to "overlap" or using a ' +
'bar chart is recommended.',
- test: function(vis, data) {
+ test: function(_, data) {
if (!data.shouldBeStacked() || data.maxNumberOfSeries() < 2) return;
const hasPos = data.getYMax(data._getY) > 0;
@@ -216,7 +216,7 @@ export const vislibPointSeriesTypes = {
'Parts of or the entire area chart might not be displayed due to null ' +
'values in the data. A line chart is recommended when displaying data ' +
'with null values.',
- test: function(vis, data) {
+ test: function(_, data) {
return data.hasNullValues();
},
},
@@ -229,7 +229,7 @@ export const vislibPointSeriesTypes = {
const tooManySeries =
defaults.charts.length && defaults.charts[0].series.length > cfg.heatmapMaxBuckets;
if (hasCharts && tooManySeries) {
- defaults.error = i18n.translate('common.ui.vislib.heatmap.maxBucketsText', {
+ defaults.error = i18n.translate('kbnVislibVisTypes.vislib.heatmap.maxBucketsText', {
defaultMessage:
'There are too many series defined ({nr}). The configured maximum is {max}.',
values: {
diff --git a/src/legacy/ui/public/vislib/lib/types/point_series.test.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/point_series.test.js
similarity index 98%
rename from src/legacy/ui/public/vislib/lib/types/point_series.test.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/point_series.test.js
index cada6127282d8..38a6be548594f 100644
--- a/src/legacy/ui/public/vislib/lib/types/point_series.test.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/types/point_series.test.js
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-import stackedSeries from '../../../../../../fixtures/vislib/mock_data/date_histogram/_stacked_series';
+import stackedSeries from '../../__tests__/lib/fixtures/mock_data/date_histogram/_stacked_series';
import { vislibPointSeriesTypes } from './point_series';
describe('vislibPointSeriesTypes', () => {
diff --git a/src/legacy/ui/public/vislib/lib/vis_config.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/vis_config.js
similarity index 93%
rename from src/legacy/ui/public/vislib/lib/vis_config.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/vis_config.js
index 5f10e89474809..091e6b1752d8d 100644
--- a/src/legacy/ui/public/vislib/lib/vis_config.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/lib/vis_config.js
@@ -35,8 +35,8 @@ const DEFAULT_VIS_CONFIG = {
};
export class VisConfig {
- constructor(visConfigArgs, data, uiState, el) {
- this.data = new Data(data, uiState);
+ constructor(visConfigArgs, data, uiState, el, vislibColor) {
+ this.data = new Data(data, uiState, vislibColor);
const visType = visTypes[visConfigArgs.type];
const typeDefaults = visType(visConfigArgs, this.data);
diff --git a/src/legacy/ui/public/vislib/partials/touchdown.tmpl.html b/src/legacy/core_plugins/vis_type_vislib/public/vislib/partials/touchdown.tmpl.html
similarity index 100%
rename from src/legacy/ui/public/vislib/partials/touchdown.tmpl.html
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/partials/touchdown.tmpl.html
diff --git a/src/legacy/core_plugins/vis_type_vislib/public/vislib/vis.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/vis.js
new file mode 100644
index 0000000000000..32afb6a008b61
--- /dev/null
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/vis.js
@@ -0,0 +1,184 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import _ from 'lodash';
+import d3 from 'd3';
+import { EventEmitter } from 'events';
+
+import { VislibError } from './errors';
+import { VisConfig } from './lib/vis_config';
+import { Handler } from './lib/handler';
+
+/**
+ * Creates the visualizations.
+ *
+ * @class Vis
+ * @constructor
+ * @param element {HTMLElement} jQuery selected HTML element
+ * @param config {Object} Parameters that define the chart type and chart options
+ */
+export class Vis extends EventEmitter {
+ constructor(element, visConfigArgs, deps) {
+ super();
+ this.element = element.get ? element.get(0) : element;
+ this.visConfigArgs = _.cloneDeep(visConfigArgs);
+ this.visConfigArgs.dimmingOpacity = deps.uiSettings.get('visualization:dimmingOpacity');
+ this.visConfigArgs.heatmapMaxBuckets = deps.uiSettings.get('visualization:heatmap:maxBuckets');
+ this.deps = deps;
+ }
+
+ hasLegend() {
+ return this.visConfigArgs.addLegend;
+ }
+
+ initVisConfig(data, uiState) {
+ this.data = data;
+ this.uiState = uiState;
+ this.visConfig = new VisConfig(
+ this.visConfigArgs,
+ this.data,
+ this.uiState,
+ this.element,
+ this.deps.vislibColor
+ );
+ }
+
+ /**
+ * Renders the visualization
+ *
+ * @method render
+ * @param data {Object} Elasticsearch query results
+ */
+ render(data, uiState) {
+ if (!data) {
+ throw new Error('No valid data!');
+ }
+
+ if (this.handler) {
+ this.data = null;
+ this._runOnHandler('destroy');
+ }
+
+ this.initVisConfig(data, uiState);
+
+ this.handler = new Handler(this, this.visConfig, this.deps);
+ this._runOnHandler('render');
+ }
+
+ getLegendLabels() {
+ return this.visConfig ? this.visConfig.get('legend.labels', null) : null;
+ }
+
+ getLegendColors() {
+ return this.visConfig ? this.visConfig.get('legend.colors', null) : null;
+ }
+
+ _runOnHandler(method) {
+ try {
+ this.handler[method]();
+ } catch (error) {
+ if (error instanceof VislibError) {
+ error.displayToScreen(this.handler);
+ } else {
+ throw error;
+ }
+ }
+ }
+
+ /**
+ * Destroys the visualization
+ * Removes chart and all elements associated with it.
+ * Removes chart and all elements associated with it.
+ * Remove event listeners and pass destroy call down to owned objects.
+ *
+ * @method destroy
+ */
+ destroy() {
+ const selection = d3.select(this.element).select('.visWrapper');
+
+ if (this.handler) this._runOnHandler('destroy');
+
+ selection.remove();
+ }
+
+ /**
+ * Sets attributes on the visualization
+ *
+ * @method set
+ * @param name {String} An attribute name
+ * @param val {*} Value to which the attribute name is set
+ */
+ set(name, val) {
+ this.visConfigArgs[name] = val;
+ this.render(this.data, this.uiState);
+ }
+
+ /**
+ * Gets attributes from the visualization
+ *
+ * @method get
+ * @param name {String} An attribute name
+ * @returns {*} The value of the attribute name
+ */
+ get(name) {
+ return this.visConfig.get(name);
+ }
+
+ /**
+ * Turns on event listeners.
+ *
+ * @param event {String}
+ * @param listener{Function}
+ * @returns {*}
+ */
+ on(event, listener) {
+ const first = this.listenerCount(event) === 0;
+ const ret = EventEmitter.prototype.on.call(this, event, listener);
+ const added = this.listenerCount(event) > 0;
+
+ // if this is the first listener added for the event
+ // enable the event in the handler
+ if (first && added && this.handler) this.handler.enable(event);
+
+ return ret;
+ }
+
+ /**
+ * Turns off event listeners.
+ *
+ * @param event {String}
+ * @param listener{Function}
+ * @returns {*}
+ */
+ off(event, listener) {
+ const last = this.listenerCount(event) === 1;
+ const ret = EventEmitter.prototype.off.call(this, event, listener);
+ const removed = this.listenerCount(event) === 0;
+
+ // Once all listeners are removed, disable the events in the handler
+ if (last && removed && this.handler) this.handler.disable(event);
+ return ret;
+ }
+
+ removeAllListeners(event) {
+ const ret = EventEmitter.prototype.removeAllListeners.call(this, event);
+ this.handler.disable(event);
+ return ret;
+ }
+}
diff --git a/src/legacy/ui/public/vislib/vislib.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/vislib.js
similarity index 82%
rename from src/legacy/ui/public/vislib/vislib.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/vislib.js
index 847deb8273a73..024dee60ef2bf 100644
--- a/src/legacy/ui/public/vislib/vislib.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/vislib.js
@@ -23,8 +23,7 @@ import './lib/types';
import './lib/layout/layout_types';
import './lib/data';
import './visualizations/vis_types';
-import { mappedColors } from '../vis/components/color/mapped_colors';
-import { VislibVisProvider } from './vis';
+import { Vis } from './vis';
// prefetched for faster optimization runs
// end prefetching
@@ -36,11 +35,9 @@ import { VislibVisProvider } from './vis';
* @main vislib
* @return {Object} Contains the version number and the Vis Class for creating visualizations
*/
-export function VislibProvider(Private, $rootScope) {
- $rootScope.$on('$routeChangeStart', () => mappedColors.purge());
-
+export function VislibProvider() {
return {
version: '0.0.0',
- Vis: Private(VislibVisProvider),
+ Vis,
};
}
diff --git a/src/legacy/ui/public/vislib/visualizations/_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/_chart.js
similarity index 81%
rename from src/legacy/ui/public/vislib/visualizations/_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/_chart.js
index 2fbd96d6a070a..ac6e8130a846a 100644
--- a/src/legacy/ui/public/vislib/visualizations/_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/_chart.js
@@ -19,12 +19,10 @@
import d3 from 'd3';
import _ from 'lodash';
+
import { dataLabel } from '../lib/_data_label';
import { Dispatch } from '../lib/dispatch';
-import { Tooltip } from '../../vis/components/tooltip';
-import { getFormat } from '../../visualize/loader/pipeline_helpers/utilities';
-import { getHierarchicalTooltipFormatter } from '../../vis/components/tooltip/_hierarchical_tooltip_formatter';
-import { getPointSeriesTooltipFormatter } from '../../vis/components/tooltip/_pointseries_tooltip_formatter';
+import { Tooltip, getFormat } from '../../legacy_imports';
/**
* The Base Class for all visualizations.
@@ -36,26 +34,26 @@ import { getPointSeriesTooltipFormatter } from '../../vis/components/tooltip/_po
* @param chartData {Object} Elasticsearch query results for this specific chart
*/
export class Chart {
- constructor(handler, el, chartData) {
+ constructor(handler, element, chartData, deps) {
this.handler = handler;
- this.chartEl = el;
+ this.chartEl = element;
this.chartData = chartData;
this.tooltips = [];
- const events = (this.events = new Dispatch(handler));
+ const events = (this.events = new Dispatch(handler, deps.uiSettings));
const fieldFormatter = getFormat(this.handler.data.get('tooltipFormatter'));
const tooltipFormatterProvider =
this.handler.visConfig.get('type') === 'pie'
- ? getHierarchicalTooltipFormatter()
- : getPointSeriesTooltipFormatter();
+ ? deps.getHierarchicalTooltipFormatter()
+ : deps.getPointSeriesTooltipFormatter();
const tooltipFormatter = tooltipFormatterProvider(fieldFormatter);
if (this.handler.visConfig && this.handler.visConfig.get('addTooltip', false)) {
- const $el = this.handler.el;
+ const element = this.handler.el;
// Add tooltip
- this.tooltip = new Tooltip('chart', $el, tooltipFormatter, events);
+ this.tooltip = new Tooltip('chart', element, tooltipFormatter, events);
this.tooltips.push(this.tooltip);
}
diff --git a/src/legacy/ui/public/vislib/visualizations/gauge_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauge_chart.js
similarity index 97%
rename from src/legacy/ui/public/vislib/visualizations/gauge_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauge_chart.js
index c67b1b8881d69..729c664032603 100644
--- a/src/legacy/ui/public/vislib/visualizations/gauge_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauge_chart.js
@@ -22,8 +22,8 @@ import { Chart } from './_chart';
import { gaugeTypes } from './gauges/gauge_types';
export class GaugeChart extends Chart {
- constructor(handler, chartEl, chartData) {
- super(handler, chartEl, chartData);
+ constructor(handler, chartEl, chartData, deps) {
+ super(handler, chartEl, chartData, deps);
this.gaugeConfig = handler.visConfig.get('gauge', {});
this.gauge = new gaugeTypes[this.gaugeConfig.type](this);
}
diff --git a/src/legacy/ui/public/vislib/visualizations/gauges/_index.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/_index.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/visualizations/gauges/_index.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/_index.scss
diff --git a/src/legacy/ui/public/vislib/visualizations/gauges/_meter.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/_meter.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/visualizations/gauges/_meter.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/_meter.scss
diff --git a/src/legacy/ui/public/vislib/visualizations/gauges/gauge_types.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/gauge_types.js
similarity index 100%
rename from src/legacy/ui/public/vislib/visualizations/gauges/gauge_types.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/gauge_types.js
diff --git a/src/legacy/ui/public/vislib/visualizations/gauges/meter.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/meter.js
similarity index 99%
rename from src/legacy/ui/public/vislib/visualizations/gauges/meter.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/meter.js
index 25da3ba957181..f519914662251 100644
--- a/src/legacy/ui/public/vislib/visualizations/gauges/meter.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/gauges/meter.js
@@ -19,7 +19,8 @@
import d3 from 'd3';
import _ from 'lodash';
-import { getHeatmapColors } from '../../components/color/heatmap_color';
+
+import { getHeatmapColors } from '../../../legacy_imports';
const arcAngles = {
angleFactor: 0.75,
diff --git a/src/legacy/ui/public/vislib/visualizations/pie_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.js
similarity index 99%
rename from src/legacy/ui/public/vislib/visualizations/pie_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.js
index 6d51c69892bc0..a2cbf0fe295ce 100644
--- a/src/legacy/ui/public/vislib/visualizations/pie_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/pie_chart.js
@@ -42,8 +42,8 @@ const defaults = {
* @param chartData {Object} Elasticsearch query results for this specific chart
*/
export class PieChart extends Chart {
- constructor(handler, chartEl, chartData) {
- super(handler, chartEl, chartData);
+ constructor(handler, chartEl, chartData, deps) {
+ super(handler, chartEl, chartData, deps);
const charts = this.handler.data.getVisData();
this._validatePieData(charts);
this._attr = _.defaults(handler.visConfig.get('chart', {}), defaults);
diff --git a/src/legacy/ui/public/vislib/visualizations/point_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series.js
similarity index 97%
rename from src/legacy/ui/public/vislib/visualizations/point_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series.js
index 84dbea2ccc823..c838c51d34bf5 100644
--- a/src/legacy/ui/public/vislib/visualizations/point_series.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series.js
@@ -20,7 +20,8 @@
import d3 from 'd3';
import _ from 'lodash';
import $ from 'jquery';
-import { Tooltip } from '../../vis/components/tooltip';
+
+import { Tooltip } from '../../legacy_imports';
import { Chart } from './_chart';
import { TimeMarker } from './time_marker';
import { seriesTypes } from './point_series/series_types';
@@ -39,9 +40,10 @@ const touchdownTmpl = _.template(touchdownTmplHtml);
* @param chartData {Object} Elasticsearch query results for this specific chart
*/
export class PointSeries extends Chart {
- constructor(handler, chartEl, chartData) {
- super(handler, chartEl, chartData);
+ constructor(handler, chartEl, chartData, deps) {
+ super(handler, chartEl, chartData, deps);
+ this.deps = deps;
this.handler = handler;
this.chartData = chartData;
this.chartEl = chartEl;
@@ -255,7 +257,7 @@ export class PointSeries extends Chart {
if (!seriArgs.show) return;
const SeriClass =
seriTypes[seriArgs.type || self.handler.visConfig.get('chart.type')] || seriTypes.line;
- const series = new SeriClass(self.handler, svg, data.series[i], seriArgs);
+ const series = new SeriClass(self.handler, svg, data.series[i], seriArgs, this.deps);
series.events = self.events;
svg.call(series.draw());
self.series.push(series);
diff --git a/src/legacy/ui/public/vislib/visualizations/point_series/_index.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/_index.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/visualizations/point_series/_index.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/_index.scss
diff --git a/src/legacy/ui/public/vislib/visualizations/point_series/_labels.scss b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/_labels.scss
similarity index 100%
rename from src/legacy/ui/public/vislib/visualizations/point_series/_labels.scss
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/_labels.scss
diff --git a/src/legacy/ui/public/vislib/visualizations/point_series/_point_series.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/_point_series.js
similarity index 97%
rename from src/legacy/ui/public/vislib/visualizations/point_series/_point_series.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/_point_series.js
index b9f50b6d941e6..b882048a6b269 100644
--- a/src/legacy/ui/public/vislib/visualizations/point_series/_point_series.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/_point_series.js
@@ -18,14 +18,14 @@
*/
import _ from 'lodash';
-import { palettes } from '@elastic/eui/lib/services';
+import { euiPaletteColorBlind } from '@elastic/eui/lib/services';
const thresholdLineDefaults = {
show: false,
value: 10,
width: 1,
style: 'full',
- color: palettes.euiPaletteColorBlind.colors[9],
+ color: euiPaletteColorBlind()[9],
};
export class PointSeries {
diff --git a/src/legacy/ui/public/vislib/visualizations/point_series/area_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.js
similarity index 98%
rename from src/legacy/ui/public/vislib/visualizations/point_series/area_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.js
index 08147bacdcc98..274ae82271e96 100644
--- a/src/legacy/ui/public/vislib/visualizations/point_series/area_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/area_chart.js
@@ -43,8 +43,8 @@ const defaults = {
* chart
*/
export class AreaChart extends PointSeries {
- constructor(handler, chartEl, chartData, seriesConfigArgs) {
- super(handler, chartEl, chartData, seriesConfigArgs);
+ constructor(handler, chartEl, chartData, seriesConfigArgs, deps) {
+ super(handler, chartEl, chartData, seriesConfigArgs, deps);
this.seriesConfig = _.defaults(seriesConfigArgs || {}, defaults);
this.isOverlapping = this.seriesConfig.mode !== 'stacked';
diff --git a/src/legacy/ui/public/vislib/visualizations/point_series/column_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.js
similarity index 98%
rename from src/legacy/ui/public/vislib/visualizations/point_series/column_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.js
index 1f18141d86299..4b422d9b1419f 100644
--- a/src/legacy/ui/public/vislib/visualizations/point_series/column_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/column_chart.js
@@ -57,8 +57,8 @@ function datumWidth(defaultWidth, datum, nextDatum, scale, gutterWidth, groupCou
* @param chartData {Object} Elasticsearch query results for this specific chart
*/
export class ColumnChart extends PointSeries {
- constructor(handler, chartEl, chartData, seriesConfigArgs) {
- super(handler, chartEl, chartData, seriesConfigArgs);
+ constructor(handler, chartEl, chartData, seriesConfigArgs, deps) {
+ super(handler, chartEl, chartData, seriesConfigArgs, deps);
this.seriesConfig = _.defaults(seriesConfigArgs || {}, defaults);
this.labelOptions = _.defaults(handler.visConfig.get('labels', {}), defaults.showLabel);
}
diff --git a/src/legacy/ui/public/vislib/visualizations/point_series/heatmap_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.js
similarity index 98%
rename from src/legacy/ui/public/vislib/visualizations/point_series/heatmap_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.js
index 1bc33bd5bbade..948cf98a64352 100644
--- a/src/legacy/ui/public/vislib/visualizations/point_series/heatmap_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/heatmap_chart.js
@@ -19,10 +19,12 @@
import _ from 'lodash';
import moment from 'moment';
-import { PointSeries } from './_point_series';
-import { getHeatmapColors } from '../../components/color/heatmap_color';
+
import { isColorDark } from '@elastic/eui';
+import { PointSeries } from './_point_series';
+import { getHeatmapColors } from '../../../legacy_imports';
+
const defaults = {
color: undefined, // todo
fillColor: undefined, // todo
@@ -38,8 +40,8 @@ const defaults = {
* @param chartData {Object} Elasticsearch query results for this specific chart
*/
export class HeatmapChart extends PointSeries {
- constructor(handler, chartEl, chartData, seriesConfigArgs) {
- super(handler, chartEl, chartData, seriesConfigArgs);
+ constructor(handler, chartEl, chartData, seriesConfigArgs, deps) {
+ super(handler, chartEl, chartData, seriesConfigArgs, deps);
this.seriesConfig = _.defaults(seriesConfigArgs || {}, defaults);
this.handler.visConfig.set('legend', {
diff --git a/src/legacy/ui/public/vislib/visualizations/point_series/line_chart.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.js
similarity index 98%
rename from src/legacy/ui/public/vislib/visualizations/point_series/line_chart.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.js
index 57090b5424f93..0038b4401b302 100644
--- a/src/legacy/ui/public/vislib/visualizations/point_series/line_chart.js
+++ b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/line_chart.js
@@ -42,8 +42,8 @@ const defaults = {
* @param chartData {Object} Elasticsearch query results for this specific chart
*/
export class LineChart extends PointSeries {
- constructor(handler, chartEl, chartData, seriesConfigArgs) {
- super(handler, chartEl, chartData, seriesConfigArgs);
+ constructor(handler, chartEl, chartData, seriesConfigArgs, deps) {
+ super(handler, chartEl, chartData, seriesConfigArgs, deps);
this.seriesConfig = _.defaults(seriesConfigArgs || {}, defaults);
}
diff --git a/src/legacy/ui/public/vislib/visualizations/point_series/series_types.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/series_types.js
similarity index 100%
rename from src/legacy/ui/public/vislib/visualizations/point_series/series_types.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/point_series/series_types.js
diff --git a/src/legacy/ui/public/vislib/visualizations/time_marker.d.ts b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/time_marker.d.ts
similarity index 100%
rename from src/legacy/ui/public/vislib/visualizations/time_marker.d.ts
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/time_marker.d.ts
diff --git a/src/legacy/ui/public/vislib/visualizations/time_marker.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/time_marker.js
similarity index 100%
rename from src/legacy/ui/public/vislib/visualizations/time_marker.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/time_marker.js
diff --git a/src/legacy/ui/public/vislib/visualizations/vis_types.js b/src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/vis_types.js
similarity index 100%
rename from src/legacy/ui/public/vislib/visualizations/vis_types.js
rename to src/legacy/core_plugins/vis_type_vislib/public/vislib/visualizations/vis_types.js
diff --git a/src/legacy/core_plugins/visualizations/index.ts b/src/legacy/core_plugins/visualizations/index.ts
index cf2d123d8f184..a2779cfe4346d 100644
--- a/src/legacy/core_plugins/visualizations/index.ts
+++ b/src/legacy/core_plugins/visualizations/index.ts
@@ -26,7 +26,7 @@ export const visualizations: LegacyPluginInitializer = kibana =>
publicDir: resolve(__dirname, 'public'),
require: [],
uiExports: {
- interpreter: ['plugins/visualizations/expressions/boot'],
+ styleSheetPaths: resolve(__dirname, 'public/index.scss'),
},
});
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/_embeddables.scss b/src/legacy/core_plugins/visualizations/public/embeddable/_embeddables.scss
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/visualize_embeddable/_embeddables.scss
rename to src/legacy/core_plugins/visualizations/public/embeddable/_embeddables.scss
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/_index.scss b/src/legacy/core_plugins/visualizations/public/embeddable/_index.scss
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/visualize_embeddable/_index.scss
rename to src/legacy/core_plugins/visualizations/public/embeddable/_index.scss
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/_visualize_lab_disabled.scss b/src/legacy/core_plugins/visualizations/public/embeddable/_visualize_lab_disabled.scss
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/visualize_embeddable/_visualize_lab_disabled.scss
rename to src/legacy/core_plugins/visualizations/public/embeddable/_visualize_lab_disabled.scss
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/constants.ts b/src/legacy/core_plugins/visualizations/public/embeddable/constants.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/visualize_embeddable/constants.ts
rename to src/legacy/core_plugins/visualizations/public/embeddable/constants.ts
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/disabled_lab_embeddable.tsx b/src/legacy/core_plugins/visualizations/public/embeddable/disabled_lab_embeddable.tsx
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/visualize_embeddable/disabled_lab_embeddable.tsx
rename to src/legacy/core_plugins/visualizations/public/embeddable/disabled_lab_embeddable.tsx
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/disabled_lab_visualization.tsx b/src/legacy/core_plugins/visualizations/public/embeddable/disabled_lab_visualization.tsx
similarity index 92%
rename from src/legacy/core_plugins/kibana/public/visualize_embeddable/disabled_lab_visualization.tsx
rename to src/legacy/core_plugins/visualizations/public/embeddable/disabled_lab_visualization.tsx
index 52fa937bbe047..3d2af2c591a3c 100644
--- a/src/legacy/core_plugins/kibana/public/visualize_embeddable/disabled_lab_visualization.tsx
+++ b/src/legacy/core_plugins/visualizations/public/embeddable/disabled_lab_visualization.tsx
@@ -29,14 +29,14 @@ export function DisabledLabVisualization({ title }: { title: string }) {
/>
{title} }}
/>
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/get_index_pattern.ts b/src/legacy/core_plugins/visualizations/public/embeddable/get_index_pattern.ts
similarity index 89%
rename from src/legacy/core_plugins/kibana/public/visualize_embeddable/get_index_pattern.ts
rename to src/legacy/core_plugins/visualizations/public/embeddable/get_index_pattern.ts
index 36efc4b86d0d3..25aa77ec73579 100644
--- a/src/legacy/core_plugins/kibana/public/visualize_embeddable/get_index_pattern.ts
+++ b/src/legacy/core_plugins/visualizations/public/embeddable/get_index_pattern.ts
@@ -17,10 +17,9 @@
* under the License.
*/
-import { npStart } from 'ui/new_platform';
-
import { VisSavedObject } from './visualize_embeddable';
import { indexPatterns, IIndexPattern } from '../../../../../plugins/data/public';
+import { getUISettings, getSavedObjects } from '../np_ready/public/services';
export async function getIndexPattern(
savedVis: VisSavedObject
@@ -29,8 +28,8 @@ export async function getIndexPattern(
return savedVis.vis.indexPattern;
}
- const savedObjectsClient = npStart.core.savedObjects.client;
- const defaultIndex = npStart.core.uiSettings.get('defaultIndex');
+ const savedObjectsClient = getSavedObjects().client;
+ const defaultIndex = getUISettings().get('defaultIndex');
if (savedVis.vis.params.index_pattern) {
const indexPatternObjects = await savedObjectsClient.find({
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/index.ts b/src/legacy/core_plugins/visualizations/public/embeddable/index.ts
similarity index 100%
rename from src/legacy/core_plugins/kibana/public/visualize_embeddable/index.ts
rename to src/legacy/core_plugins/visualizations/public/embeddable/index.ts
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable.ts b/src/legacy/core_plugins/visualizations/public/embeddable/visualize_embeddable.ts
similarity index 99%
rename from src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable.ts
rename to src/legacy/core_plugins/visualizations/public/embeddable/visualize_embeddable.ts
index b7a3a0f000d72..c1b049ab5e969 100644
--- a/src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable.ts
+++ b/src/legacy/core_plugins/visualizations/public/embeddable/visualize_embeddable.ts
@@ -47,7 +47,7 @@ import {
APPLY_FILTER_TRIGGER,
} from '../../../../../plugins/embeddable/public';
import { dispatchRenderComplete } from '../../../../../plugins/kibana_utils/public';
-import { SavedSearch } from '../discover/np_ready/types';
+import { SavedSearch } from '../../../kibana/public/discover/np_ready/types';
const getKeys =
(o: T): Array => Object.keys(o) as Array;
diff --git a/src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable_factory.tsx b/src/legacy/core_plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx
similarity index 66%
rename from src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable_factory.tsx
rename to src/legacy/core_plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx
index dd6723fb578af..3f29f97afee48 100644
--- a/src/legacy/core_plugins/kibana/public/visualize_embeddable/visualize_embeddable_factory.tsx
+++ b/src/legacy/core_plugins/visualizations/public/embeddable/visualize_embeddable_factory.tsx
@@ -17,27 +17,9 @@
* under the License.
*/
-import 'uiExports/contextMenuActions';
-import 'uiExports/devTools';
-import 'uiExports/docViews';
-import 'uiExports/embeddableActions';
-import 'uiExports/fieldFormatEditors';
-import 'uiExports/fieldFormats';
-import 'uiExports/home';
-import 'uiExports/indexManagement';
-import 'uiExports/inspectorViews';
-import 'uiExports/savedObjectTypes';
-import 'uiExports/search';
-import 'uiExports/shareContextMenuExtensions';
-import 'uiExports/visTypes';
-import 'uiExports/visualize';
-
import { i18n } from '@kbn/i18n';
import chrome from 'ui/chrome';
-import { npSetup, npStart } from 'ui/new_platform';
-
-import { Legacy } from 'kibana';
import { SavedObjectAttributes } from 'kibana/server';
import {
@@ -46,9 +28,8 @@ import {
Container,
EmbeddableOutput,
} from '../../../../../plugins/embeddable/public';
-import { start as visualizations } from '../../../visualizations/public/np_ready/public/legacy';
-import { showNewVisModal } from '../visualize';
-import { SavedVisualizations } from '../visualize/np_ready/types';
+import { showNewVisModal } from '../../../kibana/public/visualize/np_ready/wizard/show_new_vis';
+import { SavedVisualizations } from '../../../kibana/public/visualize/np_ready/types';
import { DisabledLabEmbeddable } from './disabled_lab_embeddable';
import { getIndexPattern } from './get_index_pattern';
import {
@@ -58,7 +39,15 @@ import {
VisSavedObject,
} from './visualize_embeddable';
import { VISUALIZE_EMBEDDABLE_TYPE } from './constants';
-import { TypesStart } from '../../../visualizations/public/np_ready/public/types';
+
+import {
+ getUISettings,
+ getCapabilities,
+ getHttp,
+ getTypes,
+ getSavedObjects,
+ getUsageCollector,
+} from '../np_ready/public/services';
interface VisualizationAttributes extends SavedObjectAttributes {
visState: string;
@@ -71,60 +60,48 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
VisualizationAttributes
> {
public readonly type = VISUALIZE_EMBEDDABLE_TYPE;
- private readonly visTypes: TypesStart;
static async createVisualizeEmbeddableFactory(): Promise {
- return new VisualizeEmbeddableFactory(visualizations.types);
+ return new VisualizeEmbeddableFactory();
}
- constructor(visTypes: TypesStart) {
+ constructor() {
super({
savedObjectMetaData: {
- name: i18n.translate('kbn.visualize.savedObjectName', { defaultMessage: 'Visualization' }),
+ name: i18n.translate('visualizations.savedObjectName', { defaultMessage: 'Visualization' }),
includeFields: ['visState'],
type: 'visualization',
getIconForSavedObject: savedObject => {
- if (!visTypes) {
- return 'visualizeApp';
- }
return (
- visTypes.get(JSON.parse(savedObject.attributes.visState).type).icon || 'visualizeApp'
+ getTypes().get(JSON.parse(savedObject.attributes.visState).type).icon || 'visualizeApp'
);
},
getTooltipForSavedObject: savedObject => {
- if (!visTypes) {
- return '';
- }
return `${savedObject.attributes.title} (${
- visTypes.get(JSON.parse(savedObject.attributes.visState).type).title
+ getTypes().get(JSON.parse(savedObject.attributes.visState).type).title
})`;
},
showSavedObject: savedObject => {
- if (!visTypes) {
- return false;
- }
const typeName: string = JSON.parse(savedObject.attributes.visState).type;
- const visType = visTypes.get(typeName);
+ const visType = getTypes().get(typeName);
if (!visType) {
return false;
}
- if (npStart.core.uiSettings.get('visualize:enableLabs')) {
+ if (getUISettings().get('visualize:enableLabs')) {
return true;
}
return visType.stage !== 'experimental';
},
},
});
-
- this.visTypes = visTypes;
}
public isEditable() {
- return npStart.core.application.capabilities.visualize.save as boolean;
+ return getCapabilities().visualize.save as boolean;
}
public getDisplayName() {
- return i18n.translate('kbn.embeddable.visualizations.displayName', {
+ return i18n.translate('visualizations.displayName', {
defaultMessage: 'visualization',
});
}
@@ -135,16 +112,15 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
parent?: Container
): Promise {
const $injector = await chrome.dangerouslyGetActiveInjector();
- const config = $injector.get('config');
const savedVisualizations = $injector.get('savedVisualizations');
try {
const visId = savedObject.id as string;
const editUrl = visId
- ? npStart.core.http.basePath.prepend(`/app/kibana${savedVisualizations.urlFor(visId)}`)
+ ? getHttp().basePath.prepend(`/app/kibana${savedVisualizations.urlFor(visId)}`)
: '';
- const isLabsEnabled = config.get('visualize:enableLabs');
+ const isLabsEnabled = getUISettings().get('visualize:enableLabs');
if (!isLabsEnabled && savedObject.vis.type.stage === 'experimental') {
return new DisabledLabEmbeddable(savedObject.title, input);
@@ -192,18 +168,16 @@ export class VisualizeEmbeddableFactory extends EmbeddableFactory<
public async create() {
// TODO: This is a bit of a hack to preserve the original functionality. Ideally we will clean this up
// to allow for in place creation of visualizations without having to navigate away to a new URL.
- if (this.visTypes) {
- showNewVisModal(
- this.visTypes,
- {
- editorParams: ['addToDashboard'],
- },
- npStart.core.http.basePath.prepend,
- npStart.core.uiSettings,
- npStart.core.savedObjects,
- npSetup.plugins.usageCollection
- );
- }
+ showNewVisModal(
+ getTypes(),
+ {
+ editorParams: ['addToDashboard'],
+ },
+ getHttp().basePath.prepend,
+ getUISettings(),
+ getSavedObjects(),
+ getUsageCollector()
+ );
return undefined;
}
}
diff --git a/src/legacy/core_plugins/visualizations/public/expressions/boot.ts b/src/legacy/core_plugins/visualizations/public/expressions/boot.ts
deleted file mode 100644
index c30493e7d4c36..0000000000000
--- a/src/legacy/core_plugins/visualizations/public/expressions/boot.ts
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { npSetup } from 'ui/new_platform';
-import { visualization as visualizationFunction } from './visualization_function';
-import { visualization as visualizationRenderer } from './visualization_renderer';
-
-npSetup.plugins.expressions.registerFunction(visualizationFunction);
-npSetup.plugins.expressions.registerRenderer(visualizationRenderer);
diff --git a/src/legacy/core_plugins/visualizations/public/index.scss b/src/legacy/core_plugins/visualizations/public/index.scss
new file mode 100644
index 0000000000000..957d06be4daf0
--- /dev/null
+++ b/src/legacy/core_plugins/visualizations/public/index.scss
@@ -0,0 +1,3 @@
+@import 'src/legacy/ui/public/styles/styling_constants';
+
+@import './embeddable/_index';
diff --git a/src/legacy/core_plugins/visualizations/public/legacy_imports.ts b/src/legacy/core_plugins/visualizations/public/legacy_imports.ts
index 92d8ac2c7db3a..b750557c24b94 100644
--- a/src/legacy/core_plugins/visualizations/public/legacy_imports.ts
+++ b/src/legacy/core_plugins/visualizations/public/legacy_imports.ts
@@ -27,4 +27,7 @@ export {
} from '../../../ui/public/agg_types/buckets/date_histogram';
export { createFormat } from '../../../ui/public/visualize/loader/pipeline_helpers/utilities';
export { I18nContext } from '../../../ui/public/i18n';
+export { DefaultEditorController } from '../../../ui/public/vis/editors/default/default_editor_controller';
+import chrome from '../../../ui/public/chrome';
+export { chrome as legacyChrome };
import '../../../ui/public/directives/bind';
diff --git a/src/legacy/ui/public/visualize/loader/vis.js b/src/legacy/core_plugins/visualizations/public/np_ready/public/expressions/vis.js
similarity index 93%
rename from src/legacy/ui/public/visualize/loader/vis.js
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/expressions/vis.js
index ad946aa1212ff..81224b65f7786 100644
--- a/src/legacy/ui/public/visualize/loader/vis.js
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/expressions/vis.js
@@ -29,11 +29,9 @@
import { EventEmitter } from 'events';
import _ from 'lodash';
-import { PersistedState } from '../../persisted_state';
+import { PersistedState } from '../../../legacy_imports';
-import { start as visualizations } from '../../../../core_plugins/visualizations/public/np_ready/public/legacy';
-
-const visTypes = visualizations.types;
+import { getTypes } from '../services';
export class Vis extends EventEmitter {
constructor(visState = { type: 'histogram' }) {
@@ -64,7 +62,7 @@ export class Vis extends EventEmitter {
this.title = state.title || '';
const type = state.type || this.type;
if (_.isString(type)) {
- this.type = visTypes.get(type);
+ this.type = getTypes().get(type);
if (!this.type) {
throw new Error(`Invalid type "${type}"`);
}
diff --git a/src/legacy/core_plugins/visualizations/public/expressions/visualization_function.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/expressions/visualization_function.ts
similarity index 85%
rename from src/legacy/core_plugins/visualizations/public/expressions/visualization_function.ts
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/expressions/visualization_function.ts
index ddf1b11945422..24eb974f6edee 100644
--- a/src/legacy/core_plugins/visualizations/public/expressions/visualization_function.ts
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/expressions/visualization_function.ts
@@ -19,13 +19,10 @@
import { get } from 'lodash';
import { i18n } from '@kbn/i18n';
-import chrome from 'ui/chrome';
-import { FilterBarQueryFilterProvider } from 'ui/filter_manager/query_filter';
-import { PersistedState } from 'ui/persisted_state';
import { VisResponseValue } from 'src/plugins/visualizations/public';
import { ExpressionFunction, Render } from 'src/plugins/expressions/public';
-import { npStart } from 'ui/new_platform';
-import { start as visualizations } from '../np_ready/public/legacy';
+import { PersistedState } from '../../../legacy_imports';
+import { getTypes, getIndexPatterns, getFilterManager } from '../services';
interface Arguments {
index?: string | null;
@@ -90,15 +87,10 @@ export const visualization = (): ExpressionFunctionVisualization => ({
},
},
async fn(context, args, handlers) {
- const $injector = await chrome.dangerouslyGetActiveInjector();
- const Private = $injector.get('Private') as any;
- const indexPatterns = npStart.plugins.data.indexPatterns;
- const queryFilter = Private(FilterBarQueryFilterProvider);
-
const visConfigParams = args.visConfig ? JSON.parse(args.visConfig) : {};
const schemas = args.schemas ? JSON.parse(args.schemas) : {};
- const visType = visualizations.types.get(args.type || 'histogram') as any;
- const indexPattern = args.index ? await indexPatterns.get(args.index) : null;
+ const visType = getTypes().get(args.type || 'histogram') as any;
+ const indexPattern = args.index ? await getIndexPatterns().get(args.index) : null;
const uiStateParams = args.uiState ? JSON.parse(args.uiState) : {};
const uiState = new PersistedState(uiStateParams);
@@ -114,7 +106,7 @@ export const visualization = (): ExpressionFunctionVisualization => ({
filters: get(context, 'filters', null),
uiState,
inspectorAdapters: handlers.inspectorAdapters,
- queryFilter,
+ queryFilter: getFilterManager(),
forceFetch: true,
});
}
diff --git a/src/legacy/core_plugins/visualizations/public/expressions/visualization_renderer.tsx b/src/legacy/core_plugins/visualizations/public/np_ready/public/expressions/visualization_renderer.tsx
similarity index 89%
rename from src/legacy/core_plugins/visualizations/public/expressions/visualization_renderer.tsx
rename to src/legacy/core_plugins/visualizations/public/np_ready/public/expressions/visualization_renderer.tsx
index 40648a137c141..2a12884ecf7c8 100644
--- a/src/legacy/core_plugins/visualizations/public/expressions/visualization_renderer.tsx
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/expressions/visualization_renderer.tsx
@@ -17,12 +17,12 @@
* under the License.
*/
-import chrome from 'ui/chrome';
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
+import { legacyChrome } from '../../../legacy_imports';
// @ts-ignore
-import { Vis } from '../../../../ui/public/visualize/loader/vis';
-import { Visualization } from '../../../visualizations/public/np_ready/public/components';
+import { Vis } from './vis';
+import { Visualization } from '../components';
export const visualization = () => ({
name: 'visualization',
@@ -31,7 +31,7 @@ export const visualization = () => ({
render: async (domNode: HTMLElement, config: any, handlers: any) => {
const { visData, visConfig, params } = config;
const visType = config.visType || visConfig.type;
- const $injector = await chrome.dangerouslyGetActiveInjector();
+ const $injector = await legacyChrome.dangerouslyGetActiveInjector();
const $rootScope = $injector.get('$rootScope') as any;
if (handlers.vis) {
diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy.ts
index 1e86aa64d1fa8..41b23b276e88d 100644
--- a/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy.ts
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/legacy.ts
@@ -27,5 +27,5 @@ import { plugin } from '.';
const pluginInstance = plugin({} as PluginInitializerContext);
-export const setup = pluginInstance.setup(npSetup.core);
-export const start = pluginInstance.start(npStart.core);
+export const setup = pluginInstance.setup(npSetup.core, npSetup.plugins);
+export const start = pluginInstance.start(npStart.core, npStart.plugins);
diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts
index 88c5768a0b4e4..2fa85d86a794e 100644
--- a/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/mocks.ts
@@ -28,6 +28,10 @@ import { PluginInitializerContext } from 'src/core/public';
import { VisualizationsSetup, VisualizationsStart } from './';
import { VisualizationsPlugin } from './plugin';
import { coreMock } from '../../../../../../core/public/mocks';
+import { embeddablePluginMock } from '../../../../../../plugins/embeddable/public/mocks';
+import { expressionsPluginMock } from '../../../../../../plugins/expressions/public/mocks';
+import { dataPluginMock } from '../../../../../../plugins/data/public/mocks';
+import { usageCollectionPluginMock } from '../../../../../../plugins/usage_collection/public/mocks';
const createSetupContract = (): VisualizationsSetup => ({
types: {
@@ -49,8 +53,15 @@ const createStartContract = (): VisualizationsStart => ({
const createInstance = async () => {
const plugin = new VisualizationsPlugin({} as PluginInitializerContext);
- const setup = plugin.setup(coreMock.createSetup());
- const doStart = () => plugin.start(coreMock.createStart());
+ const setup = plugin.setup(coreMock.createSetup(), {
+ expressions: expressionsPluginMock.createSetupContract(),
+ embeddable: embeddablePluginMock.createStartContract(),
+ usageCollection: usageCollectionPluginMock.createSetupContract(),
+ });
+ const doStart = () =>
+ plugin.start(coreMock.createStart(), {
+ data: dataPluginMock.createStartContract(),
+ });
return {
plugin,
diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/plugin.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/plugin.ts
index ccf6aaf152ea4..cfd22f88167c5 100644
--- a/src/legacy/core_plugins/visualizations/public/np_ready/public/plugin.ts
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/plugin.ts
@@ -16,10 +16,28 @@
* specific language governing permissions and limitations
* under the License.
*/
+
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'src/core/public';
import { TypesService, TypesSetup, TypesStart } from './types';
-import { setUISettings, setTypes, setI18n } from './services';
-
+import {
+ setUISettings,
+ setTypes,
+ setI18n,
+ setCapabilities,
+ setHttp,
+ setIndexPatterns,
+ setSavedObjects,
+ setUsageCollector,
+ setFilterManager,
+} from './services';
+import { VisualizeEmbeddableFactory } from '../../embeddable/visualize_embeddable_factory';
+import { VISUALIZE_EMBEDDABLE_TYPE } from '../../embeddable';
+import { ExpressionsSetup } from '../../../../../../plugins/expressions/public';
+import { IEmbeddableSetup } from '../../../../../../plugins/embeddable/public';
+import { visualization as visualizationFunction } from './expressions/visualization_function';
+import { visualization as visualizationRenderer } from './expressions/visualization_renderer';
+import { DataPublicPluginStart } from '../../../../../../plugins/data/public';
+import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection/public';
/**
* Interface for this plugin's returned setup/start contracts.
*
@@ -34,6 +52,16 @@ export interface VisualizationsStart {
types: TypesStart;
}
+export interface VisualizationsSetupDeps {
+ expressions: ExpressionsSetup;
+ embeddable: IEmbeddableSetup;
+ usageCollection: UsageCollectionSetup;
+}
+
+export interface VisualizationsStartDeps {
+ data: DataPublicPluginStart;
+}
+
/**
* Visualizations Plugin - public
*
@@ -42,22 +70,46 @@ export interface VisualizationsStart {
*
* @internal
*/
-export class VisualizationsPlugin implements Plugin {
+export class VisualizationsPlugin
+ implements
+ Plugin<
+ VisualizationsSetup,
+ VisualizationsStart,
+ VisualizationsSetupDeps,
+ VisualizationsStartDeps
+ > {
private readonly types: TypesService = new TypesService();
constructor(initializerContext: PluginInitializerContext) {}
- public setup(core: CoreSetup) {
+ public setup(
+ core: CoreSetup,
+ { expressions, embeddable, usageCollection }: VisualizationsSetupDeps
+ ) {
setUISettings(core.uiSettings);
+ setUsageCollector(usageCollection);
+
+ expressions.registerFunction(visualizationFunction);
+ expressions.registerRenderer(visualizationRenderer);
+
+ const embeddableFactory = new VisualizeEmbeddableFactory();
+ embeddable.registerEmbeddableFactory(VISUALIZE_EMBEDDABLE_TYPE, embeddableFactory);
+
return {
types: this.types.setup(),
};
}
- public start(core: CoreStart) {
- setI18n(core.i18n);
+ public start(core: CoreStart, { data }: VisualizationsStartDeps) {
const types = this.types.start();
+ setI18n(core.i18n);
setTypes(types);
+ setCapabilities(core.application.capabilities);
+ setHttp(core.http);
+ setSavedObjects(core.savedObjects);
+ setIndexPatterns(data.indexPatterns);
+ setFilterManager(data.query.filterManager);
+
return {
types,
};
diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/services.ts b/src/legacy/core_plugins/visualizations/public/np_ready/public/services.ts
index 434612d11b28a..433c5c7b6df0d 100644
--- a/src/legacy/core_plugins/visualizations/public/np_ready/public/services.ts
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/services.ts
@@ -17,12 +17,40 @@
* under the License.
*/
-import { I18nStart, IUiSettingsClient } from 'src/core/public';
+import {
+ Capabilities,
+ HttpStart,
+ I18nStart,
+ IUiSettingsClient,
+ SavedObjectsStart,
+} from 'src/core/public';
import { TypesStart } from './types';
import { createGetterSetter } from '../../../../../../plugins/kibana_utils/public';
+import { FilterManager, IndexPatternsContract } from '../../../../../../plugins/data/public';
+import { UsageCollectionSetup } from '../../../../../../plugins/usage_collection/public';
export const [getUISettings, setUISettings] = createGetterSetter('UISettings');
+export const [getCapabilities, setCapabilities] = createGetterSetter('Capabilities');
+
+export const [getHttp, setHttp] = createGetterSetter('Http');
+
+export const [getSavedObjects, setSavedObjects] = createGetterSetter(
+ 'SavedObjects'
+);
+
export const [getTypes, setTypes] = createGetterSetter('Types');
export const [getI18n, setI18n] = createGetterSetter('I18n');
+
+export const [getFilterManager, setFilterManager] = createGetterSetter(
+ 'FilterManager'
+);
+
+export const [getIndexPatterns, setIndexPatterns] = createGetterSetter(
+ 'IndexPatterns'
+);
+
+export const [getUsageCollector, setUsageCollector] = createGetterSetter(
+ 'UsageCollection'
+);
diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/types/base_vis_type.js b/src/legacy/core_plugins/visualizations/public/np_ready/public/types/base_vis_type.js
index 2f60de3b80614..f849cbfb290ca 100644
--- a/src/legacy/core_plugins/visualizations/public/np_ready/public/types/base_vis_type.js
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/types/base_vis_type.js
@@ -18,7 +18,9 @@
*/
import _ from 'lodash';
+
import { createFiltersFromEvent, onBrushEvent } from '../filters';
+import { DefaultEditorController } from '../../../legacy_imports';
export class BaseVisType {
constructor(opts = {}) {
@@ -46,7 +48,7 @@ export class BaseVisType {
},
requestHandler: 'courier', // select one from registry or pass a function
responseHandler: 'none',
- editor: 'default',
+ editor: DefaultEditorController,
editorConfig: {
collections: {}, // collections used for configuration (list of positions, ...)
},
diff --git a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.js b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.js
index 115bbd2731840..4f1526c20cb6f 100644
--- a/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.js
+++ b/src/legacy/core_plugins/visualizations/public/np_ready/public/vis.js
@@ -97,6 +97,10 @@ class Vis extends EventEmitter {
}
}
+ setVisType(type) {
+ this.type.type = type;
+ }
+
updateState() {
this.setState(this.getCurrentState(true));
this.emit('update');
@@ -118,18 +122,6 @@ class Vis extends EventEmitter {
};
}
- getSerializableState(state) {
- return {
- title: state.title,
- type: state.type,
- params: _.cloneDeep(state.params),
- aggs: state.aggs.aggs
- .map(agg => agg.toJSON())
- .filter(agg => agg.enabled)
- .filter(Boolean),
- };
- }
-
copyCurrentState(includeDisabled = false) {
const state = this.getCurrentState(includeDisabled);
state.aggs = new AggConfigs(
diff --git a/src/legacy/server/config/schema.js b/src/legacy/server/config/schema.js
index a53e8e0498c42..88a794445870c 100644
--- a/src/legacy/server/config/schema.js
+++ b/src/legacy/server/config/schema.js
@@ -254,7 +254,11 @@ export default () =>
)
.default([]),
}).default(),
- manifestServiceUrl: Joi.string().default('https://catalogue.maps.elastic.co/v7.2/manifest'),
+ manifestServiceUrl: Joi.string()
+ .default('')
+ .allow(''),
+ emsFileApiUrl: Joi.string().default('https://vector-staging.maps.elastic.co'),
+ emsTileApiUrl: Joi.string().default('https://tiles.maps.elastic.co'),
emsLandingPageUrl: Joi.string().default('https://maps.elastic.co/v7.4'),
emsFontLibraryUrl: Joi.string().default(
'https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf'
diff --git a/src/legacy/ui/public/UI_SYSTEMS.md b/src/legacy/ui/public/UI_SYSTEMS.md
index 63fd602075653..37bfbcf92f640 100644
--- a/src/legacy/ui/public/UI_SYSTEMS.md
+++ b/src/legacy/ui/public/UI_SYSTEMS.md
@@ -6,7 +6,3 @@ In this directory you'll find various UI systems you can use to craft effective
* [banners](notify/banners/BANNERS.md)
* [toastNotifications](notify/toasts/TOAST_NOTIFICATIONS.md)
-
-## ui/vislib
-
-* [VisLib](vislib/VISLIB.md)
\ No newline at end of file
diff --git a/src/legacy/ui/public/_index.scss b/src/legacy/ui/public/_index.scss
index 747ad025ef691..f5a1d0a7922a7 100644
--- a/src/legacy/ui/public/_index.scss
+++ b/src/legacy/ui/public/_index.scss
@@ -26,5 +26,4 @@
// Can't import vis folder here because of cascading issues, it's imported in core_plugins/kibana
// @import './vis/index';
-@import './vislib/index';
@import './visualize/index';
diff --git a/src/legacy/ui/public/agg_types/agg_config.ts b/src/legacy/ui/public/agg_types/agg_config.ts
index 07e0d46e4eb70..0edf782318862 100644
--- a/src/legacy/ui/public/agg_types/agg_config.ts
+++ b/src/legacy/ui/public/agg_types/agg_config.ts
@@ -123,6 +123,7 @@ export class AggConfig {
public enabled: boolean;
public params: any;
public parent?: AggConfigs;
+ public brandNew?: boolean;
private __schema: Schema;
private __type: AggType;
diff --git a/src/legacy/ui/public/agg_types/agg_configs.ts b/src/legacy/ui/public/agg_types/agg_configs.ts
index 6e811afb1849d..bd2f261c0bf1d 100644
--- a/src/legacy/ui/public/agg_types/agg_configs.ts
+++ b/src/legacy/ui/public/agg_types/agg_configs.ts
@@ -126,10 +126,10 @@ export class AggConfigs {
return aggConfigs;
}
- createAggConfig(
+ createAggConfig = (
params: AggConfig | AggConfigOptions,
{ addToAggConfigs = true } = {}
- ) {
+ ) => {
let aggConfig;
if (params instanceof AggConfig) {
aggConfig = params;
@@ -141,7 +141,7 @@ export class AggConfigs {
this.aggs.push(aggConfig);
}
return aggConfig as T;
- }
+ };
/**
* Data-by-data comparison of this Aggregation
diff --git a/src/legacy/ui/public/vislib/components/color/colormaps.ts b/src/legacy/ui/public/color_maps/color_maps.ts
similarity index 100%
rename from src/legacy/ui/public/vislib/components/color/colormaps.ts
rename to src/legacy/ui/public/color_maps/color_maps.ts
diff --git a/src/legacy/ui/public/vislib/components/color/heatmap_color.js b/src/legacy/ui/public/color_maps/heatmap_color.js
similarity index 98%
rename from src/legacy/ui/public/vislib/components/color/heatmap_color.js
rename to src/legacy/ui/public/color_maps/heatmap_color.js
index 5e788cd1f3345..06d754235f88b 100644
--- a/src/legacy/ui/public/vislib/components/color/heatmap_color.js
+++ b/src/legacy/ui/public/color_maps/heatmap_color.js
@@ -18,7 +18,7 @@
*/
import _ from 'lodash';
-import { vislibColorMaps } from './colormaps';
+import { vislibColorMaps } from './color_maps';
function enforceBounds(x) {
if (x < 0) {
diff --git a/src/legacy/ui/public/color_maps/index.ts b/src/legacy/ui/public/color_maps/index.ts
new file mode 100644
index 0000000000000..50dfe682f4418
--- /dev/null
+++ b/src/legacy/ui/public/color_maps/index.ts
@@ -0,0 +1,24 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export * from './color_maps';
+// @ts-ignore
+export { getHeatmapColors } from './heatmap_color';
+// @ts-ignore
+export * from './truncated_color_maps';
diff --git a/src/legacy/ui/public/vislib/components/color/truncated_colormaps.js b/src/legacy/ui/public/color_maps/truncated_color_maps.js
similarity index 86%
rename from src/legacy/ui/public/vislib/components/color/truncated_colormaps.js
rename to src/legacy/ui/public/color_maps/truncated_color_maps.js
index ccf005b3726a8..cb7772c875e48 100644
--- a/src/legacy/ui/public/vislib/components/color/truncated_colormaps.js
+++ b/src/legacy/ui/public/color_maps/truncated_color_maps.js
@@ -17,14 +17,14 @@
* under the License.
*/
-import { vislibColorMaps } from './colormaps';
+import { vislibColorMaps } from './color_maps';
export const truncatedColorMaps = {};
const colormaps = vislibColorMaps;
for (const key in colormaps) {
if (colormaps.hasOwnProperty(key)) {
- //slice off lightest colors
+ // slice off lightest colors
truncatedColorMaps[key] = {
...colormaps[key],
value: colormaps[key].value.slice(Math.floor(colormaps[key].value.length / 4)),
@@ -32,7 +32,7 @@ for (const key in colormaps) {
}
}
-export const colorSchemas = Object.values(truncatedColorMaps).map(({ id, label }) => ({
+export const truncatedColorSchemas = Object.values(truncatedColorMaps).map(({ id, label }) => ({
value: id,
text: label,
}));
diff --git a/src/legacy/ui/public/directives/field_name/field_type_name.ts b/src/legacy/ui/public/directives/field_name/field_type_name.ts
index 14376b163d6f0..c8c886015cea3 100644
--- a/src/legacy/ui/public/directives/field_name/field_type_name.ts
+++ b/src/legacy/ui/public/directives/field_name/field_type_name.ts
@@ -61,6 +61,10 @@ export function getFieldTypeName(type: string) {
return i18n.translate('common.ui.directives.fieldNameIcons.stringFieldAriaLabel', {
defaultMessage: 'String field',
});
+ case 'nested':
+ return i18n.translate('common.ui.directives.fieldNameIcons.nestedFieldAriaLabel', {
+ defaultMessage: 'Nested field',
+ });
default:
return i18n.translate('common.ui.directives.fieldNameIcons.unknownFieldAriaLabel', {
defaultMessage: 'Unknown field',
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.js.snap
index 463c1bfb975f5..1f77660c9784c 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.js.snap
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/bytes/__snapshots__/bytes.test.js.snap
@@ -44,10 +44,7 @@ exports[`BytesFormatEditor should render normally 1`] = `
labelType="label"
>
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/__snapshots__/color.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/__snapshots__/color.test.js.snap
index d7026df761d94..7e49e93e4cc4f 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/__snapshots__/color.test.js.snap
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/color/__snapshots__/color.test.js.snap
@@ -75,6 +75,7 @@ exports[`ColorFormatEditor should render multiple colors 1`] = `
}
noItemsMessage="No items found"
responsive={true}
+ tableLayout="fixed"
/>
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/__snapshots__/date_nanos.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/__snapshots__/date_nanos.test.js.snap
index 04d59640554fd..cb570144fcee3 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/__snapshots__/date_nanos.test.js.snap
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/date_nanos/__snapshots__/date_nanos.test.js.snap
@@ -44,11 +44,8 @@ exports[`DateFormatEditor should render normally 1`] = `
labelType="label"
>
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.js.snap
index 9722a01986434..ef11d70926ad7 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.js.snap
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/duration/__snapshots__/duration.test.js.snap
@@ -20,11 +20,7 @@ exports[`DurationFormatEditor should render human readable output normally 1`] =
labelType="label"
>
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/__snapshots__/percent.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/__snapshots__/percent.test.js.snap
index fea665a918f06..30d1de270522e 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/__snapshots__/percent.test.js.snap
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/percent/__snapshots__/percent.test.js.snap
@@ -44,10 +44,7 @@ exports[`PercentFormatEditor should render normally 1`] = `
labelType="label"
>
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/__snapshots__/static_lookup.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/__snapshots__/static_lookup.test.js.snap
index 2891b99bba30c..2bfb0bbd15013 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/__snapshots__/static_lookup.test.js.snap
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/static_lookup/__snapshots__/static_lookup.test.js.snap
@@ -59,6 +59,7 @@ exports[`StaticLookupFormatEditor should render multiple lookup entries and unkn
"maxWidth": "400px",
}
}
+ tableLayout="fixed"
/>
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url.test.js.snap
index 4b246fecb8146..c727f54874db4 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url.test.js.snap
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url.test.js.snap
@@ -26,11 +26,7 @@ exports[`UrlFormatEditor should render label template help 1`] = `
labelType="label"
>
@@ -116,10 +109,7 @@ exports[`UrlFormatEditor should render label template help 1`] = `
labelType="label"
>
@@ -157,11 +147,7 @@ exports[`UrlFormatEditor should render normally 1`] = `
labelType="label"
>
@@ -247,10 +230,7 @@ exports[`UrlFormatEditor should render normally 1`] = `
labelType="label"
>
@@ -288,11 +268,7 @@ exports[`UrlFormatEditor should render url template help 1`] = `
labelType="label"
>
@@ -378,10 +351,7 @@ exports[`UrlFormatEditor should render url template help 1`] = `
labelType="label"
>
@@ -419,11 +389,7 @@ exports[`UrlFormatEditor should render width and height fields if image 1`] = `
labelType="label"
>
@@ -510,10 +473,7 @@ exports[`UrlFormatEditor should render width and height fields if image 1`] = `
labelType="label"
>
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url_template_flyout.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url_template_flyout.test.js.snap
index 39189caeedb32..849e307f7b527 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url_template_flyout.test.js.snap
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/editors/url/__snapshots__/url_template_flyout.test.js.snap
@@ -110,6 +110,7 @@ exports[`UrlTemplateFlyout should render normally 1`] = `
}
noItemsMessage="No items found"
responsive={true}
+ tableLayout="fixed"
/>
diff --git a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.js.snap b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.js.snap
index 25cbbb7c8684b..73a7c1141c601 100644
--- a/src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.js.snap
+++ b/src/legacy/ui/public/field_editor/components/field_format_editor/samples/__snapshots__/samples.test.js.snap
@@ -54,6 +54,7 @@ exports[`FormatEditorSamples should render normally 1`] = `
}
noItemsMessage="No items found"
responsive={true}
+ tableLayout="fixed"
/>
`;
diff --git a/src/legacy/ui/public/field_editor/field_editor.test.js b/src/legacy/ui/public/field_editor/field_editor.test.js
index f811ad9162728..cf61b6140f42c 100644
--- a/src/legacy/ui/public/field_editor/field_editor.test.js
+++ b/src/legacy/ui/public/field_editor/field_editor.test.js
@@ -50,9 +50,7 @@ jest.mock('@elastic/eui', () => ({
EuiText: 'eui-text',
EuiTextArea: 'eui-textArea',
htmlIdGenerator: () => 42,
- palettes: {
- euiPaletteColorBlind: { colors: ['red'] },
- },
+ euiPaletteColorBlind: () => ['red'],
}));
jest.mock('ui/scripting_languages', () => ({
diff --git a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js
index 06424ea48a40f..d3f74a540b960 100644
--- a/src/legacy/ui/public/new_platform/new_platform.karma_mock.js
+++ b/src/legacy/ui/public/new_platform/new_platform.karma_mock.js
@@ -131,6 +131,9 @@ export const npSetup = {
featureCatalogue: {
register: sinon.fake(),
},
+ environment: {
+ update: sinon.fake(),
+ },
},
},
};
diff --git a/src/legacy/ui/public/styles/_mixins.scss b/src/legacy/ui/public/styles/_mixins.scss
index ae529a4678d5d..2d78768684841 100644
--- a/src/legacy/ui/public/styles/_mixins.scss
+++ b/src/legacy/ui/public/styles/_mixins.scss
@@ -25,6 +25,7 @@
// Standardizes the look and layout of resizable area handles
@mixin kbnResizer($size: ($euiSizeM + 2px), $direction: horizontal) {
+ position: relative;
display: flex;
flex: 0 0 $size;
background-color: $euiPageBackgroundColor;
@@ -34,10 +35,8 @@
user-select: none;
@if ($direction == horizontal) {
- cursor: ew-resize;
width: $size;
} @else if ($direction == vertical) {
- cursor: ns-resize;
height: $size;
width: 100%;
} @else {
@@ -53,6 +52,21 @@
background-color: $euiColorPrimary;
color: $euiColorEmptyShade;
}
+
+ &::after {
+ content: "";
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+
+ @if ($direction == horizontal) {
+ cursor: ew-resize;
+ } @else if ($direction == vertical) {
+ cursor: ns-resize;
+ }
+ }
}
@mixin kibanaFullScreenGraphics($euiZLevel: $euiZLevel9) {
diff --git a/src/legacy/ui/public/styles/bootstrap/_custom_variables.less b/src/legacy/ui/public/styles/bootstrap/_custom_variables.less
index aa174684a622b..a348e7bfa86b8 100644
--- a/src/legacy/ui/public/styles/bootstrap/_custom_variables.less
+++ b/src/legacy/ui/public/styles/bootstrap/_custom_variables.less
@@ -345,7 +345,7 @@
//** Background color of the whole progress component
@progress-bg: shade(@gray-lighter, 13%);
//** Default progress bar color
-@progress-bar-bg: #00B3A4;
+@progress-bar-bg: #54B399;
//== List group
//
diff --git a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_files.json b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_files.json
index 3ef17ea35352c..cdbed7fa06367 100644
--- a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_files.json
+++ b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_files.json
@@ -24,7 +24,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/world_countries_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/world_countries_v1.geo.json",
"legacy_default": true
}
],
@@ -430,7 +430,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/australia_states_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/australia_states_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -629,7 +629,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/canada_provinces_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/canada_provinces_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -908,7 +908,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/china_provinces_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/china_provinces_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -1266,7 +1266,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/finland_regions_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/finland_regions_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -1634,7 +1634,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/france_departments_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/france_departments_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -1984,7 +1984,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/germany_states_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/germany_states_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -2328,7 +2328,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/ireland_counties_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/ireland_counties_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -2637,7 +2637,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/japan_prefectures_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/japan_prefectures_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -3003,7 +3003,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/netherlands_provinces_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/netherlands_provinces_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -3309,7 +3309,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/norway_counties_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/norway_counties_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -3671,7 +3671,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/spain_provinces_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/spain_provinces_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -4002,7 +4002,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/sweden_counties_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/sweden_counties_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -4311,7 +4311,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/switzerland_cantons_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/switzerland_cantons_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -4827,7 +4827,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/uk_subdivisions_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/uk_subdivisions_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -5074,7 +5074,7 @@
"formats": [
{
"type": "topojson",
- "url": "https://vector-staging.maps.elastic.co/files/usa_counties_v2.topo.json?elastic_tile_service_tos=agree",
+ "url": "/files/usa_counties_v2.topo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -5441,7 +5441,7 @@
"formats": [
{
"type": "geojson",
- "url": "https://vector-staging.maps.elastic.co/files/usa_states_v1.geo.json?elastic_tile_service_tos=agree",
+ "url": "/files/usa_states_v1.geo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
@@ -5731,7 +5731,7 @@
"formats": [
{
"type": "topojson",
- "url": "https://vector-staging.maps.elastic.co/files/usa_zip_codes_v2.topo.json?elastic_tile_service_tos=agree",
+ "url": "/files/usa_zip_codes_v2.topo.json?elastic_tile_service_tos=agree",
"legacy_default": true
}
],
diff --git a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_manifest.json b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_manifest.json
index aaf1edbf4860e..6030c8068884d 100644
--- a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_manifest.json
+++ b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_manifest.json
@@ -3,13 +3,13 @@
{
"id": "tiles_v2",
"name": "Elastic Maps Tile Service",
- "manifest": "https://tiles.foobar/manifest",
+ "manifest": "https://tiles.foobar/v7.6/manifest",
"type": "tms"
},
{
"id": "geo_layers",
"name": "Elastic Maps Vector Service",
- "manifest": "https://files.foobar/manifest",
+ "manifest": "https://files.foobar/v7.6/manifest",
"type": "file"
}
]
diff --git a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright.json b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright.json
index 6ea1686dadb8d..f757624ffbca7 100644
--- a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright.json
+++ b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright.json
@@ -7,6 +7,6 @@
"bounds": [-180, -85.0511, 180, 85.0511],
"format": "png",
"type": "baselayer",
- "tiles": ["https://raster-style.foobar/styles/osm-bright/{z}/{x}/{y}.png"],
+ "tiles": ["/raster/styles/osm-bright/{z}/{x}/{y}.png"],
"center": [0, 0, 2]
}
diff --git a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright_vector.json b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright_vector.json
index b14db52644459..52b70bff6b2ad 100644
--- a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright_vector.json
+++ b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright_vector.json
@@ -41,11 +41,11 @@
"sources": {
"openmaptiles": {
"type": "vector",
- "url": "https://tiles.maps.elastic.co/data/v3.json"
+ "url": "/data/v3.json"
}
},
- "sprite": "https://tiles.maps.elastic.co/styles/osm-bright/sprite",
- "glyphs": "https://tiles.maps.elastic.co/fonts/{fontstack}/{range}.pbf",
+ "sprite": "/styles/osm-bright/sprite",
+ "glyphs": "/fonts/{fontstack}/{range}.pbf",
"layers": [
{
"id": "background",
diff --git a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright_vector_source.json b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright_vector_source.json
index a32b627dba2c2..9961d54028b13 100644
--- a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright_vector_source.json
+++ b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_bright_vector_source.json
@@ -1,6 +1,6 @@
{
"tiles": [
- "https://tiles.maps.elastic.co/data/v3/{z}/{x}/{y}.pbf"
+ "/data/v3/{z}/{x}/{y}.pbf"
],
"name": "OpenMapTiles",
"format": "pbf",
diff --git a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_dark.json b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_dark.json
index 9481297b99a28..411d9d59b89c6 100644
--- a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_dark.json
+++ b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_dark.json
@@ -7,6 +7,6 @@
"bounds": [-180, -85.0511, 180, 85.0511],
"format": "png",
"type": "baselayer",
- "tiles": ["https://raster-style.foobar/styles/dark-matter/{z}/{x}/{y}.png"],
+ "tiles": ["/raster/styles/dark-matter/{z}/{x}/{y}.png"],
"center": [0, 0, 2]
}
diff --git a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_desaturated.json b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_desaturated.json
index cbbd35d59ce89..c89bbe73b603a 100644
--- a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_desaturated.json
+++ b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_style_desaturated.json
@@ -7,6 +7,6 @@
"bounds": [-180, -85.0511, 180, 85.0511],
"format": "png",
"type": "baselayer",
- "tiles": ["https://raster-style.foobar/styles/osm-bright-desaturated/{z}/{x}/{y}.png"],
+ "tiles": ["/raster/styles/osm-bright-desaturated/{z}/{x}/{y}.png"],
"center": [0, 0, 2]
}
diff --git a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_tiles.json b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_tiles.json
index 9df72817bb940..c038bb411daec 100644
--- a/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_tiles.json
+++ b/src/legacy/ui/public/vis/__tests__/map/ems_mocks/sample_tiles.json
@@ -19,12 +19,12 @@
{
"locale": "en",
"format": "vector",
- "url": "https://vector-style.foobar/styles/osm-bright/style.json"
+ "url": "/v7.6/styles/osm-bright/style.json"
},
{
"locale": "en",
"format": "raster",
- "url": "https://raster-style.foobar/styles/osm-bright.json"
+ "url": "/v7.6/styles/osm-bright.json"
}
]
},
@@ -47,12 +47,12 @@
{
"locale": "en",
"format": "vector",
- "url": "https://vector-style.foobar/styles/osm-bright-desaturated/style.json"
+ "url": "/v7.6/styles/osm-bright-desaturated/style.json"
},
{
"locale": "en",
"format": "raster",
- "url": "https://raster-style.foobar/styles/osm-bright-desaturated.json"
+ "url": "/v7.6/styles/osm-bright-desaturated.json"
}
]
},
@@ -75,12 +75,12 @@
{
"locale": "en",
"format": "vector",
- "url": "https://vector-style.foobar/styles/dark-matter/style.json"
+ "url": "/v7.6/styles/dark-matter/style.json"
},
{
"locale": "en",
"format": "raster",
- "url": "https://raster-style.foobar/styles/dark-matter.json"
+ "url": "/v7.6/styles/dark-matter.json"
}
]
}
diff --git a/src/legacy/ui/public/vis/__tests__/map/service_settings.js b/src/legacy/ui/public/vis/__tests__/map/service_settings.js
index 820b66897affa..61925760457c6 100644
--- a/src/legacy/ui/public/vis/__tests__/map/service_settings.js
+++ b/src/legacy/ui/public/vis/__tests__/map/service_settings.js
@@ -21,7 +21,6 @@ import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import url from 'url';
-import EMS_CATALOGUE from './ems_mocks/sample_manifest.json';
import EMS_FILES from './ems_mocks/sample_files.json';
import EMS_TILES from './ems_mocks/sample_tiles.json';
import EMS_STYLE_ROAD_MAP_BRIGHT from './ems_mocks/sample_style_bright';
@@ -34,14 +33,18 @@ describe('service_settings (FKA tilemaptest)', function() {
let mapConfig;
let tilemapsConfig;
- const manifestUrl = 'https://foobar/manifest';
- const manifestUrl2 = 'https://foobar_override/v1/manifest';
+ const emsFileApiUrl = 'https://files.foobar';
+ const emsTileApiUrl = 'https://tiles.foobar';
+
+ const emsTileApiUrl2 = 'https://tiles_override.foobar';
+ const emsFileApiUrl2 = 'https://files_override.foobar';
beforeEach(
ngMock.module('kibana', $provide => {
$provide.decorator('mapConfig', () => {
return {
- manifestServiceUrl: manifestUrl,
+ emsFileApiUrl,
+ emsTileApiUrl,
includeElasticMapsService: true,
emsTileLayerId: {
bright: 'road_map',
@@ -53,7 +56,8 @@ describe('service_settings (FKA tilemaptest)', function() {
})
);
- let manifestServiceUrlOriginal;
+ let emsTileApiUrlOriginal;
+ let emsFileApiUrlOriginal;
let tilemapsConfigDeprecatedOriginal;
let getManifestStub;
beforeEach(
@@ -61,26 +65,26 @@ describe('service_settings (FKA tilemaptest)', function() {
serviceSettings = $injector.get('serviceSettings');
getManifestStub = serviceSettings.__debugStubManifestCalls(async url => {
//simulate network calls
- if (url.startsWith('https://foobar')) {
- return EMS_CATALOGUE;
- } else if (url.startsWith('https://tiles.foobar')) {
- return EMS_TILES;
- } else if (url.startsWith('https://files.foobar')) {
- return EMS_FILES;
- } else if (url.startsWith('https://raster-style.foobar')) {
- if (url.includes('osm-bright-desaturated')) {
+ if (url.startsWith('https://tiles.foobar')) {
+ if (url.includes('/manifest')) {
+ return EMS_TILES;
+ } else if (url.includes('osm-bright-desaturated.json')) {
return EMS_STYLE_ROAD_MAP_DESATURATED;
- } else if (url.includes('osm-bright')) {
+ } else if (url.includes('osm-bright.json')) {
return EMS_STYLE_ROAD_MAP_BRIGHT;
- } else if (url.includes('dark-matter')) {
+ } else if (url.includes('dark-matter.json')) {
return EMS_STYLE_DARK_MAP;
}
+ } else if (url.startsWith('https://files.foobar')) {
+ return EMS_FILES;
}
});
mapConfig = $injector.get('mapConfig');
tilemapsConfig = $injector.get('tilemapsConfig');
- manifestServiceUrlOriginal = mapConfig.manifestServiceUrl;
+ emsTileApiUrlOriginal = mapConfig.emsTileApiUrl;
+ emsFileApiUrlOriginal = mapConfig.emsFileApiUrl;
+
tilemapsConfigDeprecatedOriginal = tilemapsConfig.deprecated;
$rootScope.$digest();
})
@@ -88,7 +92,8 @@ describe('service_settings (FKA tilemaptest)', function() {
afterEach(function() {
getManifestStub.removeStub();
- mapConfig.manifestServiceUrl = manifestServiceUrlOriginal;
+ mapConfig.emsTileApiUrl = emsTileApiUrlOriginal;
+ mapConfig.emsFileApiUrl = emsFileApiUrlOriginal;
tilemapsConfig.deprecated = tilemapsConfigDeprecatedOriginal;
});
@@ -110,7 +115,7 @@ describe('service_settings (FKA tilemaptest)', function() {
expect(attrs.url).to.contain('{z}');
const urlObject = url.parse(attrs.url, true);
- expect(urlObject.hostname).to.be('raster-style.foobar');
+ expect(urlObject.hostname).to.be('tiles.foobar');
expect(urlObject.query).to.have.property('my_app_name', 'kibana');
expect(urlObject.query).to.have.property('elastic_tile_service_tos', 'agree');
expect(urlObject.query).to.have.property('my_app_version');
@@ -161,7 +166,8 @@ describe('service_settings (FKA tilemaptest)', function() {
});
it('when overridden, should continue to work', async () => {
- mapConfig.manifestServiceUrl = manifestUrl2;
+ mapConfig.emsFileApiUrl = emsFileApiUrl2;
+ mapConfig.emsTileApiUrl = emsTileApiUrl2;
serviceSettings.addQueryParams({ foo: 'bar' });
tilemapServices = await serviceSettings.getTMSServices();
await assertQuery({ foo: 'bar' });
@@ -187,11 +193,11 @@ describe('service_settings (FKA tilemaptest)', function() {
id: 'road_map',
name: 'Road Map - Bright',
url:
- 'https://raster-style.foobar/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3',
+ 'https://tiles.foobar/raster/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3',
minZoom: 0,
maxZoom: 10,
attribution:
- 'OpenStreetMap contributors | OpenMapTiles | MapTiler | Elastic Maps Service
',
+ 'OpenStreetMap contributors | OpenMapTiles | MapTiler | Elastic Maps Service',
subdomains: [],
},
];
@@ -233,19 +239,19 @@ describe('service_settings (FKA tilemaptest)', function() {
);
expect(desaturationFalse.url).to.equal(
- 'https://raster-style.foobar/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
+ 'https://tiles.foobar/raster/styles/osm-bright/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
);
expect(desaturationFalse.maxZoom).to.equal(10);
expect(desaturationTrue.url).to.equal(
- 'https://raster-style.foobar/styles/osm-bright-desaturated/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
+ 'https://tiles.foobar/raster/styles/osm-bright-desaturated/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
);
expect(desaturationTrue.maxZoom).to.equal(18);
expect(darkThemeDesaturationFalse.url).to.equal(
- 'https://raster-style.foobar/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
+ 'https://tiles.foobar/raster/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
);
expect(darkThemeDesaturationFalse.maxZoom).to.equal(22);
expect(darkThemeDesaturationTrue.url).to.equal(
- 'https://raster-style.foobar/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
+ 'https://tiles.foobar/raster/styles/dark-matter/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3'
);
expect(darkThemeDesaturationTrue.maxZoom).to.equal(22);
});
diff --git a/src/legacy/ui/public/vis/components/tooltip/_hierarchical_tooltip_formatter.js b/src/legacy/ui/public/vis/components/tooltip/_hierarchical_tooltip_formatter.js
index 26a9c5b008f70..aef7bc3913a49 100644
--- a/src/legacy/ui/public/vis/components/tooltip/_hierarchical_tooltip_formatter.js
+++ b/src/legacy/ui/public/vis/components/tooltip/_hierarchical_tooltip_formatter.js
@@ -19,6 +19,9 @@
import _ from 'lodash';
import $ from 'jquery';
+
+import chrome from 'ui/chrome';
+
import { collectBranch } from './_collect_branch';
import numeral from 'numeral';
import template from './_hierarchical_tooltip.html';
@@ -68,6 +71,12 @@ export const getHierarchicalTooltipFormatter = () => {
return _tooltipFormatter;
};
+export const initializeHierarchicalTooltipFormatter = async () => {
+ const $injector = await chrome.dangerouslyGetActiveInjector();
+ const Private = $injector.get('Private');
+ _tooltipFormatter = Private(HierarchicalTooltipFormatterProvider);
+};
+
export const setHierarchicalTooltipFormatter = Private => {
_tooltipFormatter = Private(HierarchicalTooltipFormatterProvider);
};
diff --git a/src/legacy/ui/public/vis/components/tooltip/_pointseries_tooltip_formatter.js b/src/legacy/ui/public/vis/components/tooltip/_pointseries_tooltip_formatter.js
index fa0b030c736c1..88c9e3d67b4a9 100644
--- a/src/legacy/ui/public/vis/components/tooltip/_pointseries_tooltip_formatter.js
+++ b/src/legacy/ui/public/vis/components/tooltip/_pointseries_tooltip_formatter.js
@@ -18,6 +18,9 @@
*/
import $ from 'jquery';
+
+import chrome from 'ui/chrome';
+
import template from './_pointseries_tooltip.html';
export function PointSeriesTooltipFormatterProvider($compile, $rootScope) {
@@ -75,6 +78,12 @@ export const getPointSeriesTooltipFormatter = () => {
return _tooltipFormatter;
};
+export const initializePointSeriesTooltipFormatter = async () => {
+ const $injector = await chrome.dangerouslyGetActiveInjector();
+ const Private = $injector.get('Private');
+ _tooltipFormatter = Private(PointSeriesTooltipFormatterProvider);
+};
+
export const setPointSeriesTooltipFormatter = Private => {
_tooltipFormatter = Private(PointSeriesTooltipFormatterProvider);
};
diff --git a/src/legacy/ui/public/vis/editor_size.ts b/src/legacy/ui/public/vis/editor_size.ts
new file mode 100644
index 0000000000000..5fdda4c2dad41
--- /dev/null
+++ b/src/legacy/ui/public/vis/editor_size.ts
@@ -0,0 +1,36 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export enum DefaultEditorSize {
+ SMALL = 'small',
+ MEDIUM = 'medium',
+ LARGE = 'large',
+}
+
+export const getInitialWidth = (size: DefaultEditorSize) => {
+ switch (size) {
+ case DefaultEditorSize.SMALL:
+ return 15;
+ case DefaultEditorSize.LARGE:
+ return 50;
+ case DefaultEditorSize.MEDIUM:
+ default:
+ return 30;
+ }
+};
diff --git a/src/legacy/ui/public/vis/editors/config/editor_config_providers.test.ts b/src/legacy/ui/public/vis/editors/config/editor_config_providers.test.ts
index fa15f8642c4dc..0a5d0ea748b5e 100644
--- a/src/legacy/ui/public/vis/editors/config/editor_config_providers.test.ts
+++ b/src/legacy/ui/public/vis/editors/config/editor_config_providers.test.ts
@@ -19,7 +19,6 @@
import { EditorConfigProviderRegistry } from './editor_config_providers';
import { EditorParamConfig, FixedParam, NumericIntervalParam, TimeIntervalParam } from './types';
-import { AggType } from '../../../agg_types';
import { AggConfig } from '../..';
jest.mock('ui/new_platform');
@@ -49,10 +48,9 @@ describe('EditorConfigProvider', () => {
const provider = jest.fn(() => ({}));
registry.register(provider);
expect(provider).not.toHaveBeenCalled();
- const aggType = {} as AggType;
const aggConfig = {} as AggConfig;
- registry.getConfigForAgg(aggType, indexPattern, aggConfig);
- expect(provider).toHaveBeenCalledWith(aggType, indexPattern, aggConfig);
+ registry.getConfigForAgg(indexPattern, aggConfig);
+ expect(provider).toHaveBeenCalledWith(indexPattern, aggConfig);
});
it('should call all registered providers with given parameters', () => {
@@ -62,11 +60,10 @@ describe('EditorConfigProvider', () => {
registry.register(provider2);
expect(provider).not.toHaveBeenCalled();
expect(provider2).not.toHaveBeenCalled();
- const aggType = {} as AggType;
const aggConfig = {} as AggConfig;
- registry.getConfigForAgg(aggType, indexPattern, aggConfig);
- expect(provider).toHaveBeenCalledWith(aggType, indexPattern, aggConfig);
- expect(provider2).toHaveBeenCalledWith(aggType, indexPattern, aggConfig);
+ registry.getConfigForAgg(indexPattern, aggConfig);
+ expect(provider).toHaveBeenCalledWith(indexPattern, aggConfig);
+ expect(provider2).toHaveBeenCalledWith(indexPattern, aggConfig);
});
describe('merging configs', () => {
@@ -75,7 +72,7 @@ describe('EditorConfigProvider', () => {
}
function getOutputConfig(reg: EditorConfigProviderRegistry) {
- return reg.getConfigForAgg({} as AggType, indexPattern, {} as AggConfig).singleParam;
+ return reg.getConfigForAgg(indexPattern, {} as AggConfig).singleParam;
}
it('should have hidden true if at least one config was hidden true', () => {
diff --git a/src/legacy/ui/public/vis/editors/config/editor_config_providers.ts b/src/legacy/ui/public/vis/editors/config/editor_config_providers.ts
index c7fb937b97424..80dc2bcd68f08 100644
--- a/src/legacy/ui/public/vis/editors/config/editor_config_providers.ts
+++ b/src/legacy/ui/public/vis/editors/config/editor_config_providers.ts
@@ -19,18 +19,13 @@
import { TimeIntervalParam } from 'ui/vis/editors/config/types';
import { AggConfig } from '../..';
-import { AggType } from '../../../agg_types';
import { IndexPattern } from '../../../../../../plugins/data/public';
import { leastCommonMultiple } from '../../lib/least_common_multiple';
import { parseEsInterval } from '../../../../../core_plugins/data/public';
import { leastCommonInterval } from '../../lib/least_common_interval';
import { EditorConfig, EditorParamConfig, FixedParam, NumericIntervalParam } from './types';
-type EditorConfigProvider = (
- aggType: AggType,
- indexPattern: IndexPattern,
- aggConfig: AggConfig
-) => EditorConfig;
+type EditorConfigProvider = (indexPattern: IndexPattern, aggConfig: AggConfig) => EditorConfig;
class EditorConfigProviderRegistry {
private providers: Set = new Set();
@@ -39,14 +34,8 @@ class EditorConfigProviderRegistry {
this.providers.add(configProvider);
}
- public getConfigForAgg(
- aggType: AggType,
- indexPattern: IndexPattern,
- aggConfig: AggConfig
- ): EditorConfig {
- const configs = Array.from(this.providers).map(provider =>
- provider(aggType, indexPattern, aggConfig)
- );
+ public getConfigForAgg(indexPattern: IndexPattern, aggConfig: AggConfig): EditorConfig {
+ const configs = Array.from(this.providers).map(provider => provider(indexPattern, aggConfig));
return this.mergeConfigs(configs);
}
diff --git a/src/legacy/ui/public/vis/editors/default/_default.scss b/src/legacy/ui/public/vis/editors/default/_default.scss
index 2a32eadd55b1e..7562583b037df 100644
--- a/src/legacy/ui/public/vis/editors/default/_default.scss
+++ b/src/legacy/ui/public/vis/editors/default/_default.scss
@@ -1,8 +1,4 @@
.visEditor--default {
- // Prevent the default editor from overflowing. Without that you can cause
- // a weird issue where the complete page can be scrolled out of view if
- // the editor within the sidebar is too height.
- overflow-y: hidden;
flex: 1 1 auto;
display: flex;
@@ -16,12 +12,11 @@
*/
.visEditor__collapsibleSidebar {
- @include flex-parent(0, 0, auto);
- margin-right: $euiSizeL;
- flex-direction: row;
+ background: $euiColorLightestShade;
min-width: $vis-editor-sidebar-min-width;
- width: $vis-editor-sidebar-min-width;
max-width: 100%;
+ position: relative;
+ flex-shrink: 0;
@include euiBreakpoint('xs', 's', 'm') {
// If we are on a small screen we force the editor to take 100% width.
@@ -33,35 +28,25 @@
}
}
-.visEditor__collapsibleSidebar.closed {
+// !importants on width are required to override resizable panel inline widths
+.visEditor__collapsibleSidebar-isClosed {
min-width: 0;
-}
-
-.visEditor__collapsibleSidebar--small {
- width: 15%;
-}
+ width: $euiSizeXL !important; // Just enough room for the collapse button
-.visEditor__collapsibleSidebar--medium {
- width: 30%;
-}
+ .visEditorSidebar {
+ display: none;
+ }
-.visEditor__collapsibleSidebar--large {
- width: 50%;
+ @include euiBreakpoint('xs', 's', 'm') {
+ height: $euiSizeXXL; // Just enough room for the collapse button
+ width: 100% !important;
+ }
}
-
-/**
- * Actual sidebar
- */
-
-.visEditor__sidebar {
- @include flex-parent(1, 0, auto);
-
- // overridden for tablet and desktop
- @include euiBreakpoint('l', 'xl') {
- flex-basis: $vis-editor-sidebar-basis;
- max-width: calc(100% - #{$vis-editor-resizer-width});
- }
+.visEditor__collapsibleSidebarButton {
+ position: absolute;
+ right: $euiSizeXS;
+ top: $euiSizeS;
}
/**
@@ -69,17 +54,30 @@
*/
.visEditor__resizer {
- @include kbnResizer($vis-editor-resizer-width);
-
+ @include kbnResizer($euiSizeM);
@include euiBreakpoint('xs', 's', 'm') {
display: none;
}
}
+.visEditor__resizer-isHidden {
+ display: none;
+}
+
/**
* Canvas area
*/
+.visEditor__visualization {
+ display: flex;
+ flex-basis: 100%;
+
+ @include euiBreakpoint('xs', 's', 'm') {
+ // If we are on a small screen we force the visualization to take 100% width.
+ width: 100% !important;
+ }
+}
+
.visEditor__canvas {
background-color: $euiColorEmptyShade;
display: flex;
diff --git a/src/legacy/ui/public/vis/editors/default/_index.scss b/src/legacy/ui/public/vis/editors/default/_index.scss
index d5938a0298d36..6abb45dc546a3 100644
--- a/src/legacy/ui/public/vis/editors/default/_index.scss
+++ b/src/legacy/ui/public/vis/editors/default/_index.scss
@@ -1,6 +1,4 @@
-$vis-editor-sidebar-basis: (100/12) * 2%; // two of twelve columns
$vis-editor-sidebar-min-width: 350px;
-$vis-editor-resizer-width: $euiSizeM;
// Main layout
@import './default';
diff --git a/src/legacy/ui/public/vis/editors/default/_sidebar.scss b/src/legacy/ui/public/vis/editors/default/_sidebar.scss
index e6b75b1a1f783..cbe7172d62341 100644
--- a/src/legacy/ui/public/vis/editors/default/_sidebar.scss
+++ b/src/legacy/ui/public/vis/editors/default/_sidebar.scss
@@ -2,18 +2,22 @@
// LAYOUT
//
-.visEditorSidebar__container {
- @include flex-parent(1, 1, auto);
- background-color: $euiColorLightestShade;
+.visEditorSidebar {
+ min-width: $vis-editor-sidebar-min-width;
}
.visEditorSidebar__form {
@include flex-parent(1, 1, auto);
+ max-width: 100%;
}
.visEditorSidebar__config {
padding: $euiSizeS;
+ > * {
+ flex-grow: 0;
+ }
+
@include euiBreakpoint('l', 'xl') {
@include flex-parent(1, 1, 1px);
@include euiScrollBar;
@@ -21,64 +25,26 @@
}
}
+.visEditorSidebar__config-isHidden {
+ display: none;
+}
+
//
// NAVIGATION
//
.visEditorSidebar__indexPattern {
- font-weight: $euiFontWeightBold;
- padding: $euiSizeXS $euiSizeS;
- background-color: shadeOrTint($euiColorPrimary, 60%, 60%);
- color: $euiColorEmptyShade;
- line-height: $euiSizeL;
+ @include euiTextTruncate;
+ padding: $euiSizeS $euiSizeXL $euiSizeS $euiSizeS; // Extra padding on the right for the collapse button
}
-.visEditorSidebar__nav {
- min-height: 0;
-
- .navbar-right {
- // Match correct bootstrap container spacing to pull buttons fully right
- margin-right: -15px;
- }
+.visEditorSidebar__indexPatternPlaceholder {
+ min-height: $euiSizeXXL;
+ border-bottom: $euiBorderThin;
}
-/**
- * 1. TODO: Override bootstrap styles. Remove !important once we're rid of bootstrap.
- */
-.visEditorSidebar__navLink {
- padding: 2px $euiSizeS !important; /* 1 */
- color: $euiColorDarkShade !important; /* 1 */
-
- &.visEditorSidebar__navLink-isSelected {
- border-bottom: 2px solid $euiColorPrimary;
- border-color: $euiColorPrimary !important;
- color: $euiColorPrimary !important;
-
- &:before {
- display: none;
- }
-
- &:hover {
- background-color: transparent;
- }
- }
-}
-
-/**
- * 1. TODO: Override bootstrap styles. Remove !important once we're rid of bootstrap.
- */
-.visEditorSidebar__navLink--danger {
- color: $euiColorEmptyShade !important; /* 1 */
- background-color: $euiColorDanger;
-
- &:hover {
- background-color: shadeOrTint($euiColorDanger, 12%, 0%) !important; /* 1 */
- }
-}
-
-.visEditorSidebar__navButtonLink {
- // Make the line-height the same size as the icon for better alignment
- line-height: $euiSize;
+.visEditorSidebar__nav {
+ flex-grow: 0;
}
//
@@ -104,15 +70,6 @@
}
}
-.visEditorSidebar__sectionTitle {
- @include euiFontSizeL;
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: $euiSizeM;
- text-transform: capitalize;
-}
-
// Collapsible section
.visEditorSidebar__collapsible {
@@ -127,15 +84,6 @@
// FORMS
//
-.visEditorSidebar__input,
-.visEditorSidebar__select {
- @include __legacyInputStyles__bad;
-}
-
-.visEditorSidebar__select {
- @include __legacySelectStyles__bad;
-}
-
.visEditorSidebar__formRow {
display: flex;
align-items: center;
@@ -155,14 +103,6 @@
flex: 1 1 60%;
}
-.visEditorSidebar__formRow--expand {
- .visEditorSidebar__formLabel,
- .visEditorSidebar__formControl {
- flex-basis: auto;
- flex-grow: 0;
- }
-}
-
.visEditorSidebar__aggGroupAccordionButtonContent {
font-size: $euiFontSizeS;
@@ -170,3 +110,15 @@
color: $euiColorDarkShade;
}
}
+
+.visEditorSidebar__controls {
+ border-top: $euiBorderThin;
+ padding: $euiSizeS;
+ display: flex;
+ justify-content: flex-end;
+ align-items: center;
+
+ .visEditorSidebar__autoApplyButton {
+ margin-left: $euiSizeM;
+ }
+}
diff --git a/src/legacy/ui/public/vis/editors/default/agg_group.js b/src/legacy/ui/public/vis/editors/default/agg_group.js
deleted file mode 100644
index 8fc4934022cf6..0000000000000
--- a/src/legacy/ui/public/vis/editors/default/agg_group.js
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import 'ngreact';
-import { wrapInI18nContext } from 'ui/i18n';
-import { uiModules } from '../../../modules';
-import { DefaultEditorAggGroup } from './components/agg_group';
-
-uiModules
- .get('app/visualize')
- .directive('visEditorAggGroupWrapper', reactDirective =>
- reactDirective(wrapInI18nContext(DefaultEditorAggGroup), [
- ['metricAggs', { watchDepth: 'reference' }], // we watch reference to identify each aggs change in useEffects
- ['schemas', { watchDepth: 'collection' }],
- ['state', { watchDepth: 'reference' }],
- ['addSchema', { watchDepth: 'reference' }],
- ['onAggParamsChange', { watchDepth: 'reference' }],
- ['onAggTypeChange', { watchDepth: 'reference' }],
- ['onToggleEnableAgg', { watchDepth: 'reference' }],
- ['removeAgg', { watchDepth: 'reference' }],
- ['reorderAggs', { watchDepth: 'reference' }],
- ['setTouched', { watchDepth: 'reference' }],
- ['setValidity', { watchDepth: 'reference' }],
- 'groupName',
- 'formIsTouched',
- 'lastParentPipelineAggTitle',
- 'currentTab',
- ])
- )
- .directive('visEditorAggGroup', function() {
- return {
- restrict: 'E',
- scope: true,
- require: '?^ngModel',
- template: function() {
- return ``;
- },
- link: function($scope, $el, attr, ngModelCtrl) {
- $scope.groupName = attr.groupName;
- $scope.$bind('schemas', attr.schemas);
- // The model can become touched either onBlur event or when the form is submitted.
- // We also watch $touched to identify when the form is submitted.
- $scope.$watch(
- () => {
- return ngModelCtrl.$touched;
- },
- value => {
- $scope.formIsTouched = value;
- }
- );
-
- $scope.setValidity = isValid => {
- ngModelCtrl.$setValidity(`aggGroup${$scope.groupName}`, isValid);
- };
-
- $scope.setTouched = isTouched => {
- if (isTouched) {
- ngModelCtrl.$setTouched();
- } else {
- ngModelCtrl.$setUntouched();
- }
- };
- },
- };
- });
diff --git a/src/legacy/ui/public/vis/editors/default/agg_groups.ts b/src/legacy/ui/public/vis/editors/default/agg_groups.ts
index f55e6ecd79155..e84306144fa63 100644
--- a/src/legacy/ui/public/vis/editors/default/agg_groups.ts
+++ b/src/legacy/ui/public/vis/editors/default/agg_groups.ts
@@ -18,11 +18,14 @@
*/
import { i18n } from '@kbn/i18n';
+import { $Values } from '@kbn/utility-types';
-export enum AggGroupNames {
- Buckets = 'buckets',
- Metrics = 'metrics',
-}
+export const AggGroupNames = Object.freeze({
+ Buckets: 'buckets' as 'buckets',
+ Metrics: 'metrics' as 'metrics',
+ None: 'none' as 'none',
+});
+export type AggGroupNames = $Values;
export const aggGroupNamesMap = () => ({
[AggGroupNames.Metrics]: i18n.translate('common.ui.vis.editors.aggGroups.metricsText', {
diff --git a/src/legacy/ui/public/vis/editors/default/components/__snapshots__/agg.test.tsx.snap b/src/legacy/ui/public/vis/editors/default/components/__snapshots__/agg.test.tsx.snap
index b78503b298d04..aed0285fd3405 100644
--- a/src/legacy/ui/public/vis/editors/default/components/__snapshots__/agg.test.tsx.snap
+++ b/src/legacy/ui/public/vis/editors/default/components/__snapshots__/agg.test.tsx.snap
@@ -57,9 +57,9 @@ exports[`DefaultEditorAgg component should init with the default set of props 1`
groupName="metrics"
indexPattern={Object {}}
metricAggs={Array []}
- onAggParamsChange={[MockFunction]}
onAggTypeChange={[Function]}
- setTouched={[MockFunction]}
+ setAggParamValue={[MockFunction]}
+ setTouched={[Function]}
setValidity={[Function]}
state={Object {}}
/>
diff --git a/src/legacy/ui/public/vis/editors/default/components/__snapshots__/agg_group.test.tsx.snap b/src/legacy/ui/public/vis/editors/default/components/__snapshots__/agg_group.test.tsx.snap
index 29af0887db2b8..373ff6b4c3ee4 100644
--- a/src/legacy/ui/public/vis/editors/default/components/__snapshots__/agg_group.test.tsx.snap
+++ b/src/legacy/ui/public/vis/editors/default/components/__snapshots__/agg_group.test.tsx.snap
@@ -5,6 +5,7 @@ exports[`DefaultEditorAgg component should init with the default set of props 1`
onDragEnd={[Function]}
>
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg.test.tsx b/src/legacy/ui/public/vis/editors/default/components/agg.test.tsx
index c19f101fa2c32..6849d00158b06 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg.test.tsx
+++ b/src/legacy/ui/public/vis/editors/default/components/agg.test.tsx
@@ -26,6 +26,7 @@ import { act } from 'react-dom/test-utils';
import { DefaultEditorAggParams } from './agg_params';
import { AggType } from 'ui/agg_types';
import { IndexPattern } from '../../../../../../../plugins/data/public';
+import { AGGS_ACTION_KEYS } from './agg_group_state';
jest.mock('./agg_params', () => ({
DefaultEditorAggParams: () => null,
@@ -33,18 +34,18 @@ jest.mock('./agg_params', () => ({
describe('DefaultEditorAgg component', () => {
let defaultProps: DefaultEditorAggProps;
- let onAggParamsChange: jest.Mock;
- let setTouched: jest.Mock;
+ let setAggParamValue: jest.Mock;
+ let setStateParamValue: jest.Mock;
let onToggleEnableAgg: jest.Mock;
let removeAgg: jest.Mock;
- let setValidity: jest.Mock;
+ let setAggsState: jest.Mock;
beforeEach(() => {
- onAggParamsChange = jest.fn();
- setTouched = jest.fn();
+ setAggParamValue = jest.fn();
+ setStateParamValue = jest.fn();
onToggleEnableAgg = jest.fn();
removeAgg = jest.fn();
- setValidity = jest.fn();
+ setAggsState = jest.fn();
defaultProps = {
agg: {
@@ -66,10 +67,10 @@ describe('DefaultEditorAgg component', () => {
isRemovable: false,
metricAggs: [],
state: {} as VisState,
- onAggParamsChange,
+ setAggParamValue,
+ setStateParamValue,
onAggTypeChange: () => {},
- setValidity,
- setTouched,
+ setAggsState,
onToggleEnableAgg,
removeAgg,
};
@@ -98,7 +99,11 @@ describe('DefaultEditorAgg component', () => {
.setValidity(false);
});
comp.update();
- expect(setValidity).toBeCalledWith(false);
+ expect(setAggsState).toBeCalledWith({
+ type: AGGS_ACTION_KEYS.VALID,
+ payload: false,
+ aggId: defaultProps.agg.id,
+ });
expect(
comp.find('.visEditorSidebar__aggGroupAccordionButtonContent span').exists()
@@ -119,7 +124,11 @@ describe('DefaultEditorAgg component', () => {
.setValidity(true);
});
comp.update();
- expect(setValidity).toBeCalledWith(true);
+ expect(setAggsState).toBeCalledWith({
+ type: AGGS_ACTION_KEYS.VALID,
+ payload: true,
+ aggId: defaultProps.agg.id,
+ });
expect(comp.find('.visEditorSidebar__aggGroupAccordionButtonContent span').text()).toBe(
'Agg description'
@@ -128,16 +137,20 @@ describe('DefaultEditorAgg component', () => {
it('should call setTouched when accordion is collapsed', () => {
const comp = mount();
- expect(defaultProps.setTouched).toBeCalledTimes(0);
+ expect(defaultProps.setAggsState).toBeCalledTimes(0);
comp.find('.euiAccordion__button').simulate('click');
// make sure that the accordion is collapsed
expect(comp.find('.euiAccordion-isOpen').exists()).toBeFalsy();
- expect(defaultProps.setTouched).toBeCalledWith(true);
+ expect(defaultProps.setAggsState).toBeCalledWith({
+ type: AGGS_ACTION_KEYS.TOUCHED,
+ payload: true,
+ aggId: defaultProps.agg.id,
+ });
});
- it('should call setValidity inside onSetValidity', () => {
+ it('should call setAggsState inside setValidity', () => {
const comp = mount();
act(() => {
@@ -147,7 +160,11 @@ describe('DefaultEditorAgg component', () => {
.setValidity(false);
});
- expect(setValidity).toBeCalledWith(false);
+ expect(setAggsState).toBeCalledWith({
+ type: AGGS_ACTION_KEYS.VALID,
+ payload: false,
+ aggId: defaultProps.agg.id,
+ });
expect(
comp.find('.visEditorSidebar__aggGroupAccordionButtonContent span').exists()
@@ -197,7 +214,7 @@ describe('DefaultEditorAgg component', () => {
const comp = mount();
comp.find('[data-test-subj="toggleDisableAggregationBtn disable"] button').simulate('click');
- expect(defaultProps.onToggleEnableAgg).toBeCalledWith(defaultProps.agg, false);
+ expect(defaultProps.onToggleEnableAgg).toBeCalledWith(defaultProps.agg.id, false);
});
it('should disable the disableAggregation button', () => {
@@ -217,7 +234,7 @@ describe('DefaultEditorAgg component', () => {
const comp = mount();
comp.find('[data-test-subj="toggleDisableAggregationBtn enable"] button').simulate('click');
- expect(defaultProps.onToggleEnableAgg).toBeCalledWith(defaultProps.agg, true);
+ expect(defaultProps.onToggleEnableAgg).toBeCalledWith(defaultProps.agg.id, true);
});
it('should call removeAgg', () => {
@@ -225,7 +242,7 @@ describe('DefaultEditorAgg component', () => {
const comp = mount();
comp.find('[data-test-subj="removeDimensionBtn"] button').simulate('click');
- expect(defaultProps.removeAgg).toBeCalledWith(defaultProps.agg);
+ expect(defaultProps.removeAgg).toBeCalledWith(defaultProps.agg.id);
});
});
@@ -269,8 +286,8 @@ describe('DefaultEditorAgg component', () => {
const comp = mount();
comp.setProps({ agg: { ...defaultProps.agg, type: { name: 'histogram' } } });
- expect(defaultProps.onAggParamsChange).toHaveBeenCalledWith(
- defaultProps.agg.params,
+ expect(defaultProps.setAggParamValue).toHaveBeenCalledWith(
+ defaultProps.agg.id,
'min_doc_count',
true
);
@@ -283,8 +300,8 @@ describe('DefaultEditorAgg component', () => {
const comp = mount();
comp.setProps({ agg: { ...defaultProps.agg, type: { name: 'date_histogram' } } });
- expect(defaultProps.onAggParamsChange).toHaveBeenCalledWith(
- defaultProps.agg.params,
+ expect(defaultProps.setAggParamValue).toHaveBeenCalledWith(
+ defaultProps.agg.id,
'min_doc_count',
0
);
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg.tsx b/src/legacy/ui/public/vis/editors/default/components/agg.tsx
index 345c9254ff6c1..5c5905abdb9f0 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg.tsx
+++ b/src/legacy/ui/public/vis/editors/default/components/agg.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
-import React, { useState, useEffect } from 'react';
+import React, { useState, useEffect, useCallback } from 'react';
import {
EuiAccordion,
EuiToolTip,
@@ -31,6 +31,7 @@ import { i18n } from '@kbn/i18n';
import { AggConfig } from '../../..';
import { DefaultEditorAggParams } from './agg_params';
import { DefaultEditorAggCommonProps } from './agg_common_props';
+import { AGGS_ACTION_KEYS, AggsAction } from './agg_group_state';
export interface DefaultEditorAggProps extends DefaultEditorAggCommonProps {
agg: AggConfig;
@@ -41,6 +42,7 @@ export interface DefaultEditorAggProps extends DefaultEditorAggCommonProps {
isDraggable: boolean;
isLastBucket: boolean;
isRemovable: boolean;
+ setAggsState: React.Dispatch;
}
function DefaultEditorAgg({
@@ -57,12 +59,12 @@ function DefaultEditorAgg({
metricAggs,
lastParentPipelineAggTitle,
state,
- onAggParamsChange,
+ setAggParamValue,
+ setStateParamValue,
onAggTypeChange,
onToggleEnableAgg,
removeAgg,
- setTouched,
- setValidity,
+ setAggsState,
}: DefaultEditorAggProps) {
const [isEditorOpen, setIsEditorOpen] = useState((agg as any).brandNew);
const [validState, setValidState] = useState(true);
@@ -103,8 +105,8 @@ function DefaultEditorAgg({
useEffect(() => {
if (isLastBucketAgg && ['date_histogram', 'histogram'].includes(agg.type.name)) {
- onAggParamsChange(
- agg.params,
+ setAggParamValue(
+ agg.id,
'min_doc_count',
// "histogram" agg has an editor for "min_doc_count" param, which accepts boolean
// "date_histogram" agg doesn't have an editor for "min_doc_count" param, it should be set as a numeric value
@@ -113,17 +115,38 @@ function DefaultEditorAgg({
}
}, [lastParentPipelineAggTitle, isLastBucket, agg.type]);
- const onToggle = (isOpen: boolean) => {
- setIsEditorOpen(isOpen);
- if (!isOpen) {
- setTouched(true);
- }
- };
+ const setTouched = useCallback(
+ (touched: boolean) => {
+ setAggsState({
+ type: AGGS_ACTION_KEYS.TOUCHED,
+ payload: touched,
+ aggId: agg.id,
+ });
+ },
+ [setAggsState]
+ );
- const onSetValidity = (isValid: boolean) => {
- setValidity(isValid);
- setValidState(isValid);
- };
+ const setValidity = useCallback(
+ (isValid: boolean) => {
+ setAggsState({
+ type: AGGS_ACTION_KEYS.VALID,
+ payload: isValid,
+ aggId: agg.id,
+ });
+ setValidState(isValid);
+ },
+ [setAggsState]
+ );
+
+ const onToggle = useCallback(
+ (isOpen: boolean) => {
+ setIsEditorOpen(isOpen);
+ if (!isOpen) {
+ setTouched(true);
+ }
+ },
+ [setTouched]
+ );
const renderAggButtons = () => {
const actionIcons = [];
@@ -146,7 +169,7 @@ function DefaultEditorAgg({
color: 'text',
disabled: isDisabled,
type: 'eye',
- onClick: () => onToggleEnableAgg(agg, false),
+ onClick: () => onToggleEnableAgg(agg.id, false),
tooltip: i18n.translate('common.ui.vis.editors.agg.disableAggButtonTooltip', {
defaultMessage: 'Disable aggregation',
}),
@@ -158,7 +181,7 @@ function DefaultEditorAgg({
id: 'enableAggregation',
color: 'text',
type: 'eyeClosed',
- onClick: () => onToggleEnableAgg(agg, true),
+ onClick: () => onToggleEnableAgg(agg.id, true),
tooltip: i18n.translate('common.ui.vis.editors.agg.enableAggButtonTooltip', {
defaultMessage: 'Enable aggregation',
}),
@@ -180,7 +203,7 @@ function DefaultEditorAgg({
id: 'removeDimension',
color: 'danger',
type: 'cross',
- onClick: () => removeAgg(agg),
+ onClick: () => removeAgg(agg.id),
tooltip: i18n.translate('common.ui.vis.editors.agg.removeDimensionButtonTooltip', {
defaultMessage: 'Remove dimension',
}),
@@ -248,9 +271,10 @@ function DefaultEditorAgg({
{SchemaComponent && (
)}
>
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_common_props.ts b/src/legacy/ui/public/vis/editors/default/components/agg_common_props.ts
index 232eaba76f3a1..a0ddc9a757cc7 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_common_props.ts
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_common_props.ts
@@ -18,29 +18,32 @@
*/
import { AggType } from 'ui/agg_types';
-import { AggConfig, VisState, VisParams } from '../../..';
-import { AggParams } from '../agg_params';
+import { AggConfig, VisState, VisParams } from 'ui/vis';
import { AggGroupNames } from '../agg_groups';
+import { Schema } from '../schemas';
-export type OnAggParamsChange = <
- Params extends AggParams | VisParams,
- ParamName extends keyof Params
->(
- params: Params,
- paramName: ParamName,
- value: Params[ParamName]
-) => void;
+type AggId = AggConfig['id'];
+type AggParams = AggConfig['params'];
-export interface DefaultEditorAggCommonProps {
+export type AddSchema = (schemas: Schema) => void;
+export type ReorderAggs = (sourceAgg: AggConfig, destinationAgg: AggConfig) => void;
+
+export interface DefaultEditorCommonProps {
formIsTouched: boolean;
groupName: AggGroupNames;
- lastParentPipelineAggTitle?: string;
metricAggs: AggConfig[];
state: VisState;
- onAggParamsChange: OnAggParamsChange;
- onAggTypeChange: (agg: AggConfig, aggType: AggType) => void;
- onToggleEnableAgg: (agg: AggConfig, isEnable: boolean) => void;
- removeAgg: (agg: AggConfig) => void;
- setTouched: (isTouched: boolean) => void;
- setValidity: (isValid: boolean) => void;
+ setAggParamValue: (
+ aggId: AggId,
+ paramName: T,
+ value: AggParams[T]
+ ) => void;
+ onAggTypeChange: (aggId: AggId, aggType: AggType) => void;
+}
+
+export interface DefaultEditorAggCommonProps extends DefaultEditorCommonProps {
+ lastParentPipelineAggTitle?: string;
+ setStateParamValue: (paramName: T, value: VisParams[T]) => void;
+ onToggleEnableAgg: (aggId: AggId, isEnable: boolean) => void;
+ removeAgg: (aggId: AggId) => void;
}
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_group.test.tsx b/src/legacy/ui/public/vis/editors/default/components/agg_group.test.tsx
index 05e8c44b9c720..ae36503c16133 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_group.test.tsx
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_group.test.tsx
@@ -109,8 +109,9 @@ describe('DefaultEditorAgg component', () => {
reorderAggs,
addSchema: () => {},
removeAgg: () => {},
- onAggParamsChange: () => {},
- onAggTypeChange: () => {},
+ setAggParamValue: jest.fn(),
+ setStateParamValue: jest.fn(),
+ onAggTypeChange: jest.fn(),
onToggleEnableAgg: () => {},
};
});
@@ -127,46 +128,6 @@ describe('DefaultEditorAgg component', () => {
expect(setTouched).toBeCalledWith(false);
});
- it('should mark group as touched when all invalid aggs are touched', () => {
- defaultProps.groupName = AggGroupNames.Buckets;
- const comp = mount();
- act(() => {
- const aggProps = comp.find(DefaultEditorAgg).props();
- aggProps.setValidity(false);
- aggProps.setTouched(true);
- });
-
- expect(setTouched).toBeCalledWith(true);
- });
-
- it('should mark group as touched when the form applied', () => {
- const comp = mount();
- act(() => {
- comp
- .find(DefaultEditorAgg)
- .first()
- .props()
- .setValidity(false);
- });
- expect(setTouched).toBeCalledWith(false);
- comp.setProps({ formIsTouched: true });
-
- expect(setTouched).toBeCalledWith(true);
- });
-
- it('should mark group as invalid when at least one agg is invalid', () => {
- const comp = mount();
- act(() => {
- comp
- .find(DefaultEditorAgg)
- .first()
- .props()
- .setValidity(false);
- });
-
- expect(setValidity).toBeCalledWith(false);
- });
-
it('should last bucket has truthy isLastBucket prop', () => {
defaultProps.groupName = AggGroupNames.Buckets;
const comp = mount();
@@ -182,10 +143,10 @@ describe('DefaultEditorAgg component', () => {
comp.props().onDragEnd({ source: { index: 0 }, destination: { index: 1 } });
});
- expect(reorderAggs).toHaveBeenCalledWith([
- defaultProps.state.aggs.aggs[1],
+ expect(reorderAggs).toHaveBeenCalledWith(
defaultProps.state.aggs.aggs[0],
- ]);
+ defaultProps.state.aggs.aggs[1]
+ );
});
it('should show add button when schemas count is less than max', () => {
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_group.tsx b/src/legacy/ui/public/vis/editors/default/components/agg_group.tsx
index 528914f4fd006..7416c36bd5cf1 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_group.tsx
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_group.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
-import React, { useEffect, useReducer, useMemo } from 'react';
+import React, { useEffect, useReducer, useMemo, useCallback } from 'react';
import {
EuiTitle,
EuiDragDropContext,
@@ -34,7 +34,7 @@ import { AggConfig } from '../../../../agg_types/agg_config';
import { aggGroupNamesMap, AggGroupNames } from '../agg_groups';
import { DefaultEditorAgg } from './agg';
import { DefaultEditorAggAdd } from './agg_add';
-import { DefaultEditorAggCommonProps } from './agg_common_props';
+import { AddSchema, ReorderAggs, DefaultEditorAggCommonProps } from './agg_common_props';
import {
isInvalidAggsTouched,
isAggRemovable,
@@ -46,8 +46,10 @@ import { Schema } from '../schemas';
export interface DefaultEditorAggGroupProps extends DefaultEditorAggCommonProps {
schemas: Schema[];
- addSchema: (schemas: Schema) => void;
- reorderAggs: (group: AggConfig[]) => void;
+ addSchema: AddSchema;
+ reorderAggs: ReorderAggs;
+ setValidity(modelName: string, value: boolean): void;
+ setTouched(isTouched: boolean): void;
}
function DefaultEditorAggGroup({
@@ -58,7 +60,8 @@ function DefaultEditorAggGroup({
state,
schemas = [],
addSchema,
- onAggParamsChange,
+ setAggParamValue,
+ setStateParamValue,
onAggTypeChange,
onToggleEnableAgg,
removeAgg,
@@ -66,10 +69,12 @@ function DefaultEditorAggGroup({
setTouched,
setValidity,
}: DefaultEditorAggGroupProps) {
- const groupNameLabel = aggGroupNamesMap()[groupName];
+ const groupNameLabel = (aggGroupNamesMap() as any)[groupName];
// e.g. buckets can have no aggs
- const group: AggConfig[] =
- state.aggs.aggs.filter((agg: AggConfig) => agg.schema.group === groupName) || [];
+ const group: AggConfig[] = useMemo(
+ () => state.aggs.aggs.filter((agg: AggConfig) => agg.schema.group === groupName) || [],
+ [state.aggs.aggs]
+ );
const stats = {
max: 0,
@@ -101,7 +106,7 @@ function DefaultEditorAggGroup({
// when isAllAggsTouched is true, it means that all invalid aggs are touched and we will set ngModel's touched to true
// which indicates that Apply button can be changed to Error button (when all invalid ngModels are touched)
setTouched(isAllAggsTouched);
- }, [isAllAggsTouched]);
+ }, [isAllAggsTouched, setTouched]);
useEffect(() => {
// when not all invalid aggs are touched and formIsTouched becomes true, it means that Apply button was clicked.
@@ -118,38 +123,21 @@ function DefaultEditorAggGroup({
}, [formIsTouched]);
useEffect(() => {
- setValidity(isGroupValid);
- }, [isGroupValid]);
-
- const onDragEnd: DragDropContextProps['onDragEnd'] = ({ source, destination }) => {
- if (source && destination) {
- const orderedGroup = Array.from(group);
- const [removed] = orderedGroup.splice(source.index, 1);
- orderedGroup.splice(destination.index, 0, removed);
-
- reorderAggs(orderedGroup);
- }
- };
-
- const setTouchedHandler = (aggId: string, touched: boolean) => {
- setAggsState({
- type: AGGS_ACTION_KEYS.TOUCHED,
- payload: touched,
- aggId,
- });
- };
-
- const setValidityHandler = (aggId: string, valid: boolean) => {
- setAggsState({
- type: AGGS_ACTION_KEYS.VALID,
- payload: valid,
- aggId,
- });
- };
+ setValidity(`aggGroup__${groupName}`, isGroupValid);
+ }, [groupName, isGroupValid, setValidity]);
+
+ const onDragEnd: DragDropContextProps['onDragEnd'] = useCallback(
+ ({ source, destination }) => {
+ if (source && destination) {
+ reorderAggs(group[source.index], group[destination.index]);
+ }
+ },
+ [reorderAggs, group]
+ );
return (
-
+
{groupNameLabel}
@@ -184,12 +172,12 @@ function DefaultEditorAggGroup({
lastParentPipelineAggTitle={lastParentPipelineAggTitle}
metricAggs={metricAggs}
state={state}
- onAggParamsChange={onAggParamsChange}
+ setAggParamValue={setAggParamValue}
+ setStateParamValue={setStateParamValue}
onAggTypeChange={onAggTypeChange}
onToggleEnableAgg={onToggleEnableAgg}
removeAgg={removeAgg}
- setTouched={isTouched => setTouchedHandler(agg.id, isTouched)}
- setValidity={isValid => setValidityHandler(agg.id, isValid)}
+ setAggsState={setAggsState}
/>
)}
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_group_state.tsx b/src/legacy/ui/public/vis/editors/default/components/agg_group_state.tsx
index 980889743c20d..0b787e45a5008 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_group_state.tsx
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_group_state.tsx
@@ -33,7 +33,7 @@ export interface AggsState {
[aggId: string]: AggsItem;
}
-interface AggsAction {
+export interface AggsAction {
type: AGGS_ACTION_KEYS;
payload: boolean;
aggId: string;
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_param.tsx b/src/legacy/ui/public/vis/editors/default/components/agg_param.tsx
index 72c802d7d237e..d3bbf3cc9903a 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_param.tsx
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_param.tsx
@@ -17,18 +17,59 @@
* under the License.
*/
-import React, { useEffect } from 'react';
+import React, { useCallback, useEffect } from 'react';
import { AggParamEditorProps, AggParamCommonProps } from './agg_param_props';
-import { OnAggParamsChange } from './agg_common_props';
+import { DefaultEditorAggCommonProps } from './agg_common_props';
+import { AGG_PARAMS_ACTION_KEYS, AggParamsAction } from './agg_params_state';
interface DefaultEditorAggParamProps extends AggParamCommonProps {
paramEditor: React.ComponentType>;
- onChange: OnAggParamsChange;
+ setAggParamValue: DefaultEditorAggCommonProps['setAggParamValue'];
+ onChangeParamsState: React.Dispatch;
}
function DefaultEditorAggParam(props: DefaultEditorAggParamProps) {
- const { agg, aggParam, paramEditor: ParamEditor, onChange, setValidity, ...rest } = props;
+ const {
+ agg,
+ aggParam,
+ paramEditor: ParamEditor,
+ setAggParamValue,
+ onChangeParamsState,
+ ...rest
+ } = props;
+
+ const setValidity = useCallback(
+ (valid: boolean) => {
+ onChangeParamsState({
+ type: AGG_PARAMS_ACTION_KEYS.VALID,
+ paramName: aggParam.name,
+ payload: valid,
+ });
+ },
+ [onChangeParamsState, aggParam.name]
+ );
+
+ // setTouched can be called from sub-agg which passes a parameter
+ const setTouched = useCallback(
+ (isTouched: boolean = true) => {
+ onChangeParamsState({
+ type: AGG_PARAMS_ACTION_KEYS.TOUCHED,
+ paramName: aggParam.name,
+ payload: isTouched,
+ });
+ },
+ [onChangeParamsState, aggParam.name]
+ );
+
+ const setValue = useCallback(
+ (value: T) => {
+ if (props.value !== value) {
+ setAggParamValue(agg.id, aggParam.name, value);
+ }
+ },
+ [setAggParamValue, agg.id, aggParam.name, props.value]
+ );
useEffect(() => {
if (aggParam.shouldShow && !aggParam.shouldShow(agg)) {
@@ -45,7 +86,8 @@ function DefaultEditorAggParam(props: DefaultEditorAggParamProps) {
agg={agg}
aggParam={aggParam}
setValidity={setValidity}
- setValue={(value: T) => onChange(agg.params, aggParam.name, value)}
+ setTouched={setTouched}
+ setValue={setValue}
{...rest}
/>
);
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_param_props.ts b/src/legacy/ui/public/vis/editors/default/components/agg_param_props.ts
index df77ea9e43eab..953f49d84f5c5 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_param_props.ts
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_param_props.ts
@@ -22,28 +22,27 @@ import { AggConfig } from '../../../../agg_types/agg_config';
import { ComboBoxGroupedOptions } from '../utils';
import { EditorConfig } from '../../config/types';
import { VisState } from '../../..';
-import { SubAggParamsProp } from './agg_params';
import { Field } from '../../../../../../../plugins/data/public';
// NOTE: we cannot export the interface with export { InterfaceName }
// as there is currently a bug on babel typescript transform plugin for it
// https://github.com/babel/babel/issues/7641
//
-export interface AggParamCommonProps {
+export interface AggParamCommonProps {
agg: AggConfig;
- aggParam: AggParam;
+ aggParam: P;
disabled?: boolean;
editorConfig: EditorConfig;
+ formIsTouched: boolean;
indexedFields?: ComboBoxGroupedOptions;
showValidation: boolean;
state: VisState;
value?: T;
metricAggs: AggConfig[];
- subAggParams: SubAggParamsProp;
- setValidity(isValid: boolean): void;
- setTouched(): void;
}
-export interface AggParamEditorProps extends AggParamCommonProps {
+export interface AggParamEditorProps extends AggParamCommonProps {
setValue(value?: T): void;
+ setValidity(isValid: boolean): void;
+ setTouched(): void;
}
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_params.test.tsx b/src/legacy/ui/public/vis/editors/default/components/agg_params.test.tsx
index 9f3f5bff3f56e..8c59d69da9478 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_params.test.tsx
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_params.test.tsx
@@ -21,6 +21,7 @@ import React from 'react';
import { mount, shallow } from 'enzyme';
import { AggConfig, VisState } from '../../..';
import { DefaultEditorAggParams, DefaultEditorAggParamsProps } from './agg_params';
+import { AggGroupNames } from '../agg_groups';
import { IndexPattern } from '../../../../../../../plugins/data/public';
const mockEditorConfig = {
@@ -79,7 +80,7 @@ jest.mock('./agg_param', () => ({
}));
describe('DefaultEditorAggParams component', () => {
- let onAggParamsChange: jest.Mock;
+ let setAggParamValue: jest.Mock;
let onAggTypeChange: jest.Mock;
let setTouched: jest.Mock;
let setValidity: jest.Mock;
@@ -87,7 +88,7 @@ describe('DefaultEditorAggParams component', () => {
let defaultProps: DefaultEditorAggParamsProps;
beforeEach(() => {
- onAggParamsChange = jest.fn();
+ setAggParamValue = jest.fn();
onAggTypeChange = jest.fn();
setTouched = jest.fn();
setValidity = jest.fn();
@@ -99,13 +100,16 @@ describe('DefaultEditorAggParams component', () => {
params: [{ name: 'interval', deserialize: intervalDeserialize }],
},
params: {},
+ schema: {
+ title: '',
+ },
} as any) as AggConfig,
- groupName: 'metrics',
+ groupName: AggGroupNames.Metrics,
formIsTouched: false,
indexPattern: {} as IndexPattern,
metricAggs: [],
state: {} as VisState,
- onAggParamsChange,
+ setAggParamValue,
onAggTypeChange,
setTouched,
setValidity,
@@ -131,16 +135,16 @@ describe('DefaultEditorAggParams component', () => {
it('should set fixed and default values when editorConfig is defined (works in rollup index)', () => {
mount();
- expect(onAggParamsChange).toHaveBeenNthCalledWith(
+ expect(setAggParamValue).toHaveBeenNthCalledWith(
1,
- defaultProps.agg.params,
+ defaultProps.agg.id,
'useNormalizedEsInterval',
false
);
expect(intervalDeserialize).toHaveBeenCalledWith('1m');
- expect(onAggParamsChange).toHaveBeenNthCalledWith(
+ expect(setAggParamValue).toHaveBeenNthCalledWith(
2,
- defaultProps.agg.params,
+ defaultProps.agg.id,
'interval',
'deserialized'
);
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_params.tsx b/src/legacy/ui/public/vis/editors/default/components/agg_params.tsx
index c62e2837908c7..0f47d9a555d21 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_params.tsx
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_params.tsx
@@ -17,60 +17,48 @@
* under the License.
*/
-import React, { useReducer, useEffect, useMemo } from 'react';
+import React, { useCallback, useReducer, useEffect, useMemo } from 'react';
import { EuiForm, EuiAccordion, EuiSpacer, EuiFormRow } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import useUnmount from 'react-use/lib/useUnmount';
-import { VisState } from 'ui/vis';
-import { aggTypes, AggType, AggParam, AggConfig } from 'ui/agg_types/';
+import { AggConfig } from 'ui/agg_types/';
import { IndexPattern } from '../../../../../../../plugins/data/public';
import { DefaultEditorAggSelect } from './agg_select';
import { DefaultEditorAggParam } from './agg_param';
import {
getAggParamsToRender,
- getError,
getAggTypeOptions,
- ParamInstance,
isInvalidParamsTouched,
} from './agg_params_helper';
import {
aggTypeReducer,
- AGG_TYPE_ACTION_KEYS,
aggParamsReducer,
AGG_PARAMS_ACTION_KEYS,
initAggParamsState,
- AggParamsItem,
} from './agg_params_state';
import { editorConfigProviders } from '../../config/editor_config_providers';
import { FixedParam, TimeIntervalParam, EditorParamConfig } from '../../config/types';
import { AggGroupNames } from '../agg_groups';
-import { OnAggParamsChange } from './agg_common_props';
+import { DefaultEditorCommonProps } from './agg_common_props';
const FIXED_VALUE_PROP = 'fixedValue';
const DEFAULT_PROP = 'default';
type EditorParamConfigType = EditorParamConfig & {
[key: string]: unknown;
};
-export interface SubAggParamsProp {
- formIsTouched: boolean;
- onAggParamsChange: OnAggParamsChange;
- onAggTypeChange: (agg: AggConfig, aggType: AggType) => void;
-}
-export interface DefaultEditorAggParamsProps extends SubAggParamsProp {
+
+export interface DefaultEditorAggParamsProps extends DefaultEditorCommonProps {
agg: AggConfig;
aggError?: string;
aggIndex?: number;
aggIsTooLow?: boolean;
className?: string;
disabledParams?: string[];
- groupName: string;
indexPattern: IndexPattern;
- metricAggs: AggConfig[];
- state: VisState;
- setTouched: (isTouched: boolean) => void;
setValidity: (isValid: boolean) => void;
+ setTouched: (isTouched: boolean) => void;
}
function DefaultEditorAggParams({
@@ -84,20 +72,34 @@ function DefaultEditorAggParams({
formIsTouched,
indexPattern,
metricAggs,
- state = {} as VisState,
- onAggParamsChange,
+ state,
+ setAggParamValue,
onAggTypeChange,
setTouched,
setValidity,
}: DefaultEditorAggParamsProps) {
- const groupedAggTypeOptions = getAggTypeOptions(agg, indexPattern, groupName);
- const errors = getError(agg, aggIsTooLow);
-
- const editorConfig = useMemo(
- () => editorConfigProviders.getConfigForAgg((aggTypes as any)[groupName], indexPattern, agg),
- [groupName, agg.type]
- );
- const params = getAggParamsToRender({ agg, editorConfig, metricAggs, state });
+ const groupedAggTypeOptions = useMemo(() => getAggTypeOptions(agg, indexPattern, groupName), [
+ agg,
+ indexPattern,
+ groupName,
+ ]);
+ const error = aggIsTooLow
+ ? i18n.translate('common.ui.vis.editors.aggParams.errors.aggWrongRunOrderErrorMessage', {
+ defaultMessage: '"{schema}" aggs must run before all other buckets!',
+ values: { schema: agg.schema.title },
+ })
+ : '';
+
+ const editorConfig = useMemo(() => editorConfigProviders.getConfigForAgg(indexPattern, agg), [
+ indexPattern,
+ agg,
+ ]);
+ const params = useMemo(() => getAggParamsToRender({ agg, editorConfig, metricAggs, state }), [
+ agg,
+ editorConfig,
+ metricAggs,
+ state,
+ ]);
const allParams = [...params.basic, ...params.advanced];
const [paramsState, onChangeParamsState] = useReducer(
aggParamsReducer,
@@ -107,21 +109,30 @@ function DefaultEditorAggParams({
const [aggType, onChangeAggType] = useReducer(aggTypeReducer, { touched: false, valid: true });
const isFormValid =
- !errors.length &&
+ !error &&
aggType.valid &&
Object.entries(paramsState).every(([, paramState]) => paramState.valid);
const isAllInvalidParamsTouched =
- !!errors.length || isInvalidParamsTouched(agg.type, aggType, paramsState);
+ !!error || isInvalidParamsTouched(agg.type, aggType, paramsState);
+
+ const onAggSelect = useCallback(
+ value => {
+ if (agg.type !== value) {
+ onAggTypeChange(agg.id, value);
+ // reset touched and valid of params
+ onChangeParamsState({ type: AGG_PARAMS_ACTION_KEYS.RESET });
+ }
+ },
+ [onAggTypeChange, agg]
+ );
// reset validity before component destroyed
useUnmount(() => setValidity(true));
useEffect(() => {
Object.entries(editorConfig).forEach(([param, paramConfig]) => {
- const paramOptions = agg.type.params.find(
- (paramOption: AggParam) => paramOption.name === param
- );
+ const paramOptions = agg.type.params.find(paramOption => paramOption.name === param);
const hasFixedValue = paramConfig.hasOwnProperty(FIXED_VALUE_PROP);
const hasDefault = paramConfig.hasOwnProperty(DEFAULT_PROP);
@@ -142,7 +153,11 @@ function DefaultEditorAggParams({
} else {
newValue = typedParamConfig[property];
}
- onAggParamsChange(agg.params, param, newValue);
+
+ // this check is obligatory to avoid infinite render, because setAggParamValue creates a brand new agg object
+ if (agg.params[param] !== newValue) {
+ setAggParamValue(agg.id, param, newValue);
+ }
}
});
}, [editorConfig]);
@@ -160,43 +175,11 @@ function DefaultEditorAggParams({
setTouched(isAllInvalidParamsTouched);
}, [isAllInvalidParamsTouched]);
- const renderParam = (paramInstance: ParamInstance, model: AggParamsItem) => {
- return (
- {
- onChangeParamsState({
- type: AGG_PARAMS_ACTION_KEYS.VALID,
- paramName: paramInstance.aggParam.name,
- payload: valid,
- });
- }}
- // setTouched can be called from sub-agg which passes a parameter
- setTouched={(isTouched: boolean = true) => {
- onChangeParamsState({
- type: AGG_PARAMS_ACTION_KEYS.TOUCHED,
- paramName: paramInstance.aggParam.name,
- payload: isTouched,
- });
- }}
- subAggParams={{
- onAggParamsChange,
- onAggTypeChange,
- formIsTouched,
- }}
- {...paramInstance}
- />
- );
- };
-
return (
= 1 && groupName === AggGroupNames.Buckets}
showValidation={formIsTouched || aggType.touched}
- setValue={value => {
- onAggTypeChange(agg, value);
- // reset touched and valid of params
- onChangeParamsState({ type: AGG_PARAMS_ACTION_KEYS.RESET });
- }}
- setTouched={() => onChangeAggType({ type: AGG_TYPE_ACTION_KEYS.TOUCHED, payload: true })}
- setValidity={valid => onChangeAggType({ type: AGG_TYPE_ACTION_KEYS.VALID, payload: valid })}
+ setValue={onAggSelect}
+ onChangeAggType={onChangeAggType}
/>
- {params.basic.map((param: ParamInstance) => {
+ {params.basic.map(param => {
const model = paramsState[param.aggParam.name] || {
touched: false,
valid: true,
};
- return renderParam(param, model);
+ return (
+
+ );
})}
{params.advanced.length ? (
@@ -238,12 +226,23 @@ function DefaultEditorAggParams({
)}
>
- {params.advanced.map((param: ParamInstance) => {
+ {params.advanced.map(param => {
const model = paramsState[param.aggParam.name] || {
touched: false,
valid: true,
};
- return renderParam(param, model);
+
+ return (
+
+ );
})}
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.test.ts b/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.test.ts
index fb37dd5d94618..c983bb7813de7 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.test.ts
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.test.ts
@@ -22,7 +22,6 @@ import { AggType } from 'ui/agg_types';
import { IndexedArray } from 'ui/indexed_array';
import {
getAggParamsToRender,
- getError,
getAggTypeOptions,
isInvalidParamsTouched,
} from './agg_params_helper';
@@ -162,20 +161,6 @@ describe('DefaultEditorAggParams helpers', () => {
});
});
- describe('getError', () => {
- it('should not have any errors', () => {
- const errors = getError({ schema: { title: 'Split series' } } as AggConfig, false);
-
- expect(errors).toEqual([]);
- });
-
- it('should push an error if an agg is too low', () => {
- const errors = getError({ schema: { title: 'Split series' } } as AggConfig, true);
-
- expect(errors).toEqual(['"Split series" aggs must run before all other buckets!']);
- });
- });
-
describe('getAggTypeOptions', () => {
it('should return agg type options grouped by subtype', () => {
const indexPattern = {} as IndexPattern;
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.ts b/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.ts
index e0e014f69ef3f..3970238a68435 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.ts
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_params_helper.ts
@@ -18,7 +18,6 @@
*/
import { get, isEmpty } from 'lodash';
-import { i18n } from '@kbn/i18n';
import { aggTypeFilters } from 'ui/agg_types/filter';
import { aggTypes, AggParam, FieldParamType, AggType } from 'ui/agg_types';
import { aggTypeFieldFilters } from 'ui/agg_types/param_types/filter';
@@ -91,27 +90,13 @@ function getAggParamsToRender({ agg, editorConfig, metricAggs, state }: ParamIns
metricAggs,
state,
value: agg.params[param.name],
- } as ParamInstance);
+ });
}
});
return params;
}
-function getError(agg: AggConfig, aggIsTooLow: boolean) {
- const errors = [];
- if (aggIsTooLow) {
- errors.push(
- i18n.translate('common.ui.vis.editors.aggParams.errors.aggWrongRunOrderErrorMessage', {
- defaultMessage: '"{schema}" aggs must run before all other buckets!',
- values: { schema: agg.schema.title },
- })
- );
- }
-
- return errors;
-}
-
function getAggTypeOptions(
agg: AggConfig,
indexPattern: IndexPattern,
@@ -148,4 +133,4 @@ function isInvalidParamsTouched(
return invalidParams.every(param => param.touched);
}
-export { getAggParamsToRender, getError, getAggTypeOptions, isInvalidParamsTouched };
+export { getAggParamsToRender, getAggTypeOptions, isInvalidParamsTouched };
diff --git a/src/legacy/ui/public/vis/editors/default/components/agg_select.tsx b/src/legacy/ui/public/vis/editors/default/components/agg_select.tsx
index 443c655912a55..6b6bb93b29b3e 100644
--- a/src/legacy/ui/public/vis/editors/default/components/agg_select.tsx
+++ b/src/legacy/ui/public/vis/editors/default/components/agg_select.tsx
@@ -17,7 +17,7 @@
* under the License.
*/
import { get, has } from 'lodash';
-import React, { useEffect } from 'react';
+import React, { useEffect, useCallback } from 'react';
import { EuiComboBox, EuiComboBoxOptionProps, EuiFormRow, EuiLink, EuiText } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
@@ -26,6 +26,7 @@ import { AggType } from 'ui/agg_types';
import { documentationLinks } from '../../../../documentation_links/documentation_links';
import { ComboBoxGroupedOptions } from '../utils';
import { IndexPattern } from '../../../../../../../plugins/data/public';
+import { AGG_TYPE_ACTION_KEYS, AggTypeAction } from './agg_params_state';
interface DefaultEditorAggSelectProps {
aggError?: string;
@@ -35,9 +36,8 @@ interface DefaultEditorAggSelectProps {
showValidation: boolean;
isSubAggregation: boolean;
value: AggType;
- setValidity: (isValid: boolean) => void;
+ onChangeAggType: React.Dispatch;
setValue: (aggType: AggType) => void;
- setTouched: () => void;
}
function DefaultEditorAggSelect({
@@ -49,8 +49,7 @@ function DefaultEditorAggSelect({
aggTypeOptions,
showValidation,
isSubAggregation,
- setTouched,
- setValidity,
+ onChangeAggType,
}: DefaultEditorAggSelectProps) {
const selectedOptions: ComboBoxGroupedOptions = value
? [{ label: value.title, target: value }]
@@ -101,6 +100,25 @@ function DefaultEditorAggSelect({
const isValid = !!value && !errors.length;
+ const onChange = useCallback(
+ (options: EuiComboBoxOptionProps[]) => {
+ const selectedOption = get(options, '0.target');
+ if (selectedOption) {
+ setValue(selectedOption as AggType);
+ }
+ },
+ [setValue]
+ );
+
+ const setTouched = useCallback(
+ () => onChangeAggType({ type: AGG_TYPE_ACTION_KEYS.TOUCHED, payload: true }),
+ [onChangeAggType]
+ );
+ const setValidity = useCallback(
+ valid => onChangeAggType({ type: AGG_TYPE_ACTION_KEYS.VALID, payload: valid }),
+ [onChangeAggType]
+ );
+
useEffect(() => {
setValidity(isValid);
}, [isValid]);
@@ -111,13 +129,6 @@ function DefaultEditorAggSelect({
}
}, [errors.length]);
- const onChange = (options: EuiComboBoxOptionProps[]) => {
- const selectedOption = get(options, '0.target');
- if (selectedOption) {
- setValue(selectedOption as AggType);
- }
- };
-
return (
;
+ vis: Vis;
+}
+
+function DefaultEditorControls({
+ applyChanges,
+ isDirty,
+ isInvalid,
+ isTouched,
+ dispatch,
+ vis,
+}: DefaultEditorControlsProps) {
+ const { enableAutoApply } = vis.type.editorConfig;
+ const [autoApplyEnabled, setAutoApplyEnabled] = useState(false);
+ const toggleAutoApply = useCallback(e => setAutoApplyEnabled(e.target.checked), []);
+ const onClickDiscard = useCallback(() => dispatch(discardChanges(vis)), [dispatch, vis]);
+
+ useDebounce(
+ () => {
+ if (autoApplyEnabled && isDirty) {
+ applyChanges();
+ }
+ },
+ 300,
+ [isDirty, autoApplyEnabled, applyChanges]
+ );
+
+ return (
+
+ {!autoApplyEnabled && (
+
+
+
+
+
+
+
+
+ {isInvalid && isTouched ? (
+
+
+
+
+
+ ) : (
+
+
+
+ )}
+
+
+ )}
+ {enableAutoApply && (
+
+
+
+ )}
+
+ );
+}
+
+export { DefaultEditorControls };
diff --git a/src/legacy/ui/public/vis/editors/default/components/sidebar/data_tab.tsx b/src/legacy/ui/public/vis/editors/default/components/sidebar/data_tab.tsx
new file mode 100644
index 0000000000000..4481ec5cb9b83
--- /dev/null
+++ b/src/legacy/ui/public/vis/editors/default/components/sidebar/data_tab.tsx
@@ -0,0 +1,135 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React, { useMemo, useCallback } from 'react';
+import { findLast } from 'lodash';
+import { EuiSpacer } from '@elastic/eui';
+
+import { parentPipelineAggHelper } from 'ui/agg_types/metrics/lib/parent_pipeline_agg_helper';
+import { AggConfig } from 'ui/agg_types';
+import { MetricAggType } from 'ui/agg_types/metrics/metric_agg_type';
+import { VisState } from 'ui/vis';
+import { DefaultEditorAggGroup } from '../agg_group';
+import { AggGroupNames } from '../../agg_groups';
+import {
+ EditorAction,
+ addNewAgg,
+ removeAgg,
+ reorderAggs,
+ setAggParamValue,
+ changeAggType,
+ toggleEnabledAgg,
+} from './state';
+import { ISchemas } from '../../schemas';
+import { AddSchema, ReorderAggs, DefaultEditorAggCommonProps } from '../agg_common_props';
+
+export interface DefaultEditorDataTabProps {
+ dispatch: React.Dispatch;
+ formIsTouched: boolean;
+ isTabSelected: boolean;
+ metricAggs: AggConfig[];
+ schemas: ISchemas;
+ state: VisState;
+ setTouched(isTouched: boolean): void;
+ setValidity(modelName: string, value: boolean): void;
+ setStateValue: DefaultEditorAggCommonProps['setStateParamValue'];
+}
+
+function DefaultEditorDataTab({
+ dispatch,
+ formIsTouched,
+ metricAggs,
+ schemas,
+ state,
+ setTouched,
+ setValidity,
+ setStateValue,
+}: DefaultEditorDataTabProps) {
+ const lastParentPipelineAgg = useMemo(
+ () =>
+ findLast(
+ metricAggs,
+ ({ type }: { type: MetricAggType }) => type.subtype === parentPipelineAggHelper.subtype
+ ),
+ [metricAggs]
+ );
+ const lastParentPipelineAggTitle = lastParentPipelineAgg && lastParentPipelineAgg.type.title;
+
+ const addSchema: AddSchema = useCallback(schema => dispatch(addNewAgg(schema)), [dispatch]);
+
+ const onAggRemove: DefaultEditorAggCommonProps['removeAgg'] = useCallback(
+ aggId => dispatch(removeAgg(aggId)),
+ [dispatch]
+ );
+
+ const onReorderAggs: ReorderAggs = useCallback((...props) => dispatch(reorderAggs(...props)), [
+ dispatch,
+ ]);
+
+ const onAggParamValueChange: DefaultEditorAggCommonProps['setAggParamValue'] = useCallback(
+ (...props) => dispatch(setAggParamValue(...props)),
+ [dispatch]
+ );
+
+ const onAggTypeChange: DefaultEditorAggCommonProps['onAggTypeChange'] = useCallback(
+ (...props) => dispatch(changeAggType(...props)),
+ [dispatch]
+ );
+
+ const onToggleEnableAgg: DefaultEditorAggCommonProps['onToggleEnableAgg'] = useCallback(
+ (...props) => dispatch(toggleEnabledAgg(...props)),
+ [dispatch]
+ );
+
+ const commonProps = {
+ addSchema,
+ formIsTouched,
+ lastParentPipelineAggTitle,
+ metricAggs,
+ state,
+ reorderAggs: onReorderAggs,
+ setAggParamValue: onAggParamValueChange,
+ setStateParamValue: setStateValue,
+ onAggTypeChange,
+ onToggleEnableAgg,
+ setValidity,
+ setTouched,
+ removeAgg: onAggRemove,
+ };
+
+ return (
+ <>
+
+
+
+
+
+ >
+ );
+}
+
+export { DefaultEditorDataTab };
diff --git a/src/legacy/ui/public/vis/editors/default/components/sidebar/index.ts b/src/legacy/ui/public/vis/editors/default/components/sidebar/index.ts
new file mode 100644
index 0000000000000..31228aad85d1e
--- /dev/null
+++ b/src/legacy/ui/public/vis/editors/default/components/sidebar/index.ts
@@ -0,0 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+export { DefaultEditorSideBar } from './sidebar';
+export { DefaultEditorDataTab } from './data_tab';
+export { OptionTab } from './navbar';
diff --git a/src/legacy/ui/public/vis/editors/default/components/sidebar/navbar.tsx b/src/legacy/ui/public/vis/editors/default/components/sidebar/navbar.tsx
new file mode 100644
index 0000000000000..a1b5003a092f7
--- /dev/null
+++ b/src/legacy/ui/public/vis/editors/default/components/sidebar/navbar.tsx
@@ -0,0 +1,59 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React from 'react';
+import { EuiTabs, EuiTab } from '@elastic/eui';
+
+import { VisOptionsProps } from '../../vis_options_props';
+import { DefaultEditorDataTabProps } from './data_tab';
+
+export interface OptionTab {
+ editor: React.ComponentType;
+ name: string;
+ title: string;
+}
+
+interface DefaultEditorNavBarProps {
+ optionTabs: OptionTab[];
+ selectedTab: string;
+ setSelectedTab(name: string): void;
+}
+
+function DefaultEditorNavBar({
+ selectedTab,
+ setSelectedTab,
+ optionTabs,
+}: DefaultEditorNavBarProps) {
+ return (
+
+ {optionTabs.map(({ name, title }) => (
+ setSelectedTab(name)}
+ >
+ {title}
+
+ ))}
+
+ );
+}
+
+export { DefaultEditorNavBar };
diff --git a/src/legacy/ui/public/vis/editors/default/components/sidebar/sidebar.tsx b/src/legacy/ui/public/vis/editors/default/components/sidebar/sidebar.tsx
new file mode 100644
index 0000000000000..bf35c46dbb7b5
--- /dev/null
+++ b/src/legacy/ui/public/vis/editors/default/components/sidebar/sidebar.tsx
@@ -0,0 +1,226 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import React, { useMemo, useState, useCallback, KeyboardEventHandler, useEffect } from 'react';
+import { get, isEqual } from 'lodash';
+import { i18n } from '@kbn/i18n';
+import { keyCodes, EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiTitle } from '@elastic/eui';
+
+import { Vis } from 'ui/vis';
+import { PersistedState } from 'ui/persisted_state';
+import { DefaultEditorNavBar, OptionTab } from './navbar';
+import { DefaultEditorControls } from './controls';
+import { setStateParamValue, useEditorReducer, useEditorFormState } from './state';
+import { AggGroupNames } from '../../agg_groups';
+import { DefaultEditorAggCommonProps } from '../agg_common_props';
+
+interface DefaultEditorSideBarProps {
+ isCollapsed: boolean;
+ onClickCollapse: () => void;
+ optionTabs: OptionTab[];
+ uiState: PersistedState;
+ vis: Vis;
+}
+
+function DefaultEditorSideBar({
+ isCollapsed,
+ onClickCollapse,
+ optionTabs,
+ uiState,
+ vis,
+}: DefaultEditorSideBarProps) {
+ const [selectedTab, setSelectedTab] = useState(optionTabs[0].name);
+ const [isDirty, setDirty] = useState(false);
+ const [state, dispatch] = useEditorReducer(vis);
+ const { formState, setTouched, setValidity, resetValidity } = useEditorFormState();
+
+ const responseAggs = useMemo(() => state.aggs.getResponseAggs(), [state.aggs]);
+ const metricAggs = useMemo(
+ () => responseAggs.filter(agg => get(agg, 'schema.group') === AggGroupNames.Metrics),
+ [responseAggs]
+ );
+ const hasHistogramAgg = useMemo(() => responseAggs.some(agg => agg.type.name === 'histogram'), [
+ responseAggs,
+ ]);
+
+ const setStateValidity = useCallback(
+ (value: boolean) => {
+ setValidity('visOptions', value);
+ },
+ [setValidity]
+ );
+
+ const setStateValue: DefaultEditorAggCommonProps['setStateParamValue'] = useCallback(
+ (paramName, value) => {
+ const shouldUpdate = !isEqual(state.params[paramName], value);
+
+ if (shouldUpdate) {
+ dispatch(setStateParamValue(paramName, value));
+ }
+ },
+ [dispatch, state.params]
+ );
+
+ const applyChanges = useCallback(() => {
+ if (formState.invalid || !isDirty) {
+ setTouched(true);
+
+ return;
+ }
+
+ vis.setCurrentState(state);
+ vis.updateState();
+ vis.emit('dirtyStateChange', {
+ isDirty: false,
+ });
+ setTouched(false);
+ }, [vis, state, formState.invalid, setDirty, setTouched, isDirty]);
+
+ const onSubmit: KeyboardEventHandler = useCallback(
+ event => {
+ if (event.ctrlKey && event.keyCode === keyCodes.ENTER) {
+ event.preventDefault();
+ event.stopPropagation();
+
+ applyChanges();
+ }
+ },
+ [applyChanges]
+ );
+
+ useEffect(() => {
+ vis.on('dirtyStateChange', ({ isDirty: dirty }: { isDirty: boolean }) => {
+ setDirty(dirty);
+
+ if (!dirty) {
+ resetValidity();
+ }
+ });
+ }, [resetValidity, vis]);
+
+ const dataTabProps = {
+ dispatch,
+ formIsTouched: formState.touched,
+ metricAggs,
+ state,
+ schemas: vis.type.schemas,
+ setValidity,
+ setTouched,
+ setStateValue,
+ };
+
+ const optionTabProps = {
+ aggs: state.aggs,
+ hasHistogramAgg,
+ stateParams: state.params,
+ vis,
+ uiState,
+ setValue: setStateValue,
+ setValidity: setStateValidity,
+ setTouched,
+ };
+
+ return (
+ <>
+
+
+