Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kertal committed Apr 17, 2020
1 parent 6498567 commit ade3bfa
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 14 deletions.
26 changes: 26 additions & 0 deletions src/plugins/vis_type_table/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* 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 { schema, TypeOf } from '@kbn/config-schema';

export const configSchema = schema.object({
enabled: schema.boolean({ defaultValue: true }),
});

export type ConfigSchema = TypeOf<typeof configSchema>;
2 changes: 1 addition & 1 deletion src/plugins/vis_type_table/kibana.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "visTypeTable",
"version": "kibana",
"server": false,
"server": true,
"ui": true,
"requiredPlugins": [
"expressions",
Expand Down
9 changes: 3 additions & 6 deletions src/plugins/vis_type_table/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@ export class TableVisPlugin implements Plugin<Promise<void>, void> {
{ expressions, visualizations }: TablePluginSetupDependencies
) {
expressions.registerFunction(createTableVisFn);
this.createBaseVisualization = (coreStart: CoreStart) => {
visualizations.createBaseVisualization(
getTableVisTypeDefinition(coreStart, this.initializerContext)
);
};
visualizations.createBaseVisualization(
getTableVisTypeDefinition(core, this.initializerContext)
);
}

public start(core: CoreStart, { data, visualizations }: TablePluginStartDependencies) {
this.createBaseVisualization(core);
setFormatService(data.fieldFormats);
}
}
4 changes: 2 additions & 2 deletions src/plugins/vis_type_table/public/table_vis_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { CoreStart, PluginInitializerContext } from 'kibana/public';
import { CoreSetup, PluginInitializerContext } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { AggGroupNames } from '../../data/public';
import { Schemas } from '../../vis_default_editor/public';
Expand All @@ -27,7 +27,7 @@ import tableVisTemplate from './table_vis.html';
import { TableOptions } from './components/table_vis_options';
import { getTableVisualizationControllerClass } from './vis_controller';

export function getTableVisTypeDefinition(core: CoreStart, context: PluginInitializerContext) {
export function getTableVisTypeDefinition(core: CoreSetup, context: PluginInitializerContext) {
return {
type: 'table',
name: 'table',
Expand Down
11 changes: 6 additions & 5 deletions src/plugins/vis_type_table/public/vis_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
import { CoreStart, PluginInitializerContext } from 'kibana/public';
import { CoreSetup, PluginInitializerContext } from 'kibana/public';
import angular, { IModule, auto, IRootScopeService, IScope, ICompileService } from 'angular';
import $ from 'jquery';

Expand All @@ -27,7 +27,7 @@ import { initTableVisLegacyModule } from './table_vis_legacy_module';
const innerAngularName = 'kibana/table_vis';

export function getTableVisualizationControllerClass(
core: CoreStart,
core: CoreSetup,
context: PluginInitializerContext
) {
return class TableVisualizationController {
Expand Down Expand Up @@ -55,15 +55,16 @@ export function getTableVisualizationControllerClass(
return this.injector;
}

initLocalAngular() {
async initLocalAngular() {
if (!this.tableVisModule) {
this.tableVisModule = getAngularModule(innerAngularName, core, context);
const [coreStart] = await core.getStartServices();
this.tableVisModule = getAngularModule(innerAngularName, coreStart, context);
initTableVisLegacyModule(this.tableVisModule);
}
}

async render(esResponse: object, visParams: VisParams) {
this.initLocalAngular();
await this.initLocalAngular();

return new Promise(async (resolve, reject) => {
if (!this.$rootScope) {
Expand Down
34 changes: 34 additions & 0 deletions src/plugins/vis_type_table/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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 { PluginConfigDescriptor } from 'kibana/server';

import { configSchema, ConfigSchema } from '../config';

export const config: PluginConfigDescriptor<ConfigSchema> = {
schema: configSchema,
deprecations: ({ renameFromRoot }) => [
renameFromRoot('table_vis.enabled', 'vis_type_table.enabled'),
],
};

export const plugin = () => ({
setup() {},
start() {},
});

0 comments on commit ade3bfa

Please sign in to comment.