Skip to content

Commit

Permalink
[Table Vis] Shim new platform (#40732)
Browse files Browse the repository at this point in the history
* [Table Vis] Shim new platform

* fix mocha tests

* fix mocha tests

* fix _agg_config test

* cleanup

* remove setup.ts

* Set the correct type for the "Data" dependency
  • Loading branch information
alexwizp authored Jul 24, 2019
1 parent 5e26720 commit 1ba5a62
Show file tree
Hide file tree
Showing 22 changed files with 611 additions and 419 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,27 @@
*/

import { resolve } from 'path';
import { Legacy } from 'kibana';

export default function (kibana) {
import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types';

return new kibana.Plugin({
const tableVisPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
new Plugin({
id: 'table_vis',
require: ['kibana', 'elasticsearch', 'visualizations', 'interpreter', 'data'],
publicDir: resolve(__dirname, 'public'),
uiExports: {
visTypes: [
'plugins/table_vis/table_vis'
],
interpreter: ['plugins/table_vis/table_vis_fn'],
styleSheetPaths: resolve(__dirname, 'public/index.scss'),
hacks: [resolve(__dirname, 'public/legacy')],
injectDefaultVars: server => ({}),
},
});
init: (server: Legacy.Server) => ({}),
config(Joi: any) {
return Joi.object({
enabled: Joi.boolean().default(true),
}).default();
},
} as Legacy.PluginSpecOptions);

}
// eslint-disable-next-line import/no-default-export
export default tableVisPluginInitializer;
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ import expect from '@kbn/expect';
import ngMock from 'ng_mock';
import { legacyResponseHandlerProvider } from 'ui/vis/response_handlers/legacy';
import { VisProvider } from 'ui/vis';
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import { AppStateProvider } from 'ui/state_management/app_state';
import { tabifyAggResponse } from 'ui/agg_response/tabify';

describe('Table Vis Controller', function () {
import { createTableVisTypeDefinition } from '../table_vis_type';
import { visualizations } from '../../../visualizations/public';

describe('Table Vis - Controller', async function () {
let $rootScope;
let $compile;
let Private;
Expand All @@ -37,10 +41,20 @@ describe('Table Vis Controller', function () {
let AppState;
let tableAggResponse;
let tabifiedResponse;
let legacyDependencies;

beforeEach(ngMock.module('kibana', 'kibana/table_vis'));
beforeEach(ngMock.inject(function ($injector) {
Private = $injector.get('Private');
legacyDependencies = {
// eslint-disable-next-line new-cap
createAngularVisualization: VisFactoryProvider(Private).createAngularVisualization
};

visualizations.types.VisTypesRegistryProvider.register(() =>
createTableVisTypeDefinition(legacyDependencies)
);

$rootScope = $injector.get('$rootScope');
$compile = $injector.get('$compile');
fixtures = require('fixtures/fake_hierarchical_data');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ import { VisProvider } from 'ui/vis';
import { tabifyAggResponse } from 'ui/agg_response/tabify';
import { round } from 'lodash';

describe('AggTable Directive', function () {
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { createTableVisTypeDefinition } from '../../table_vis_type';
import { visualizations } from '../../../../visualizations/public';

describe('Table Vis - AggTable Directive', function () {

let $rootScope;
let $compile;
let Vis;
let indexPattern;
let settings;
let tableAggResponse;
let legacyDependencies;
const tabifiedData = {};

const init = () => {
Expand Down Expand Up @@ -82,6 +87,15 @@ describe('AggTable Directive', function () {

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function ($injector, Private, config) {
legacyDependencies = {
// eslint-disable-next-line new-cap
createAngularVisualization: VisFactoryProvider(Private).createAngularVisualization
};

visualizations.types.VisTypesRegistryProvider.register(() =>
createTableVisTypeDefinition(legacyDependencies)
);

tableAggResponse = legacyResponseHandlerProvider().handler;
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
Vis = Private(VisProvider);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logsta
import { VisProvider } from 'ui/vis';
import { tabifyAggResponse } from 'ui/agg_response/tabify';

describe('AggTableGroup Directive', function () {
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { createTableVisTypeDefinition } from '../../table_vis_type';
import { visualizations } from '../../../../visualizations/public';

describe('Table Vis - AggTableGroup Directive', function () {
let $rootScope;
let $compile;
let Vis;
let indexPattern;
let tableAggResponse;
let legacyDependencies;
const tabifiedData = {};

const init = () => {
Expand All @@ -56,6 +60,15 @@ describe('AggTableGroup Directive', function () {

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function ($injector, Private) {
legacyDependencies = {
// eslint-disable-next-line new-cap
createAngularVisualization: VisFactoryProvider(Private).createAngularVisualization
};

visualizations.types.VisTypesRegistryProvider.register(() =>
createTableVisTypeDefinition(legacyDependencies)
);

tableAggResponse = legacyResponseHandlerProvider().handler;
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
Vis = Private(VisProvider);
Expand Down
Loading

0 comments on commit 1ba5a62

Please sign in to comment.