* [NP] Migrate Tagcloud to NP * Fixed eslint issue * Added styles import and disabled eslint in some lines with paths * Added a simple server part and moved tests * Imported setFormatService to fix initialization * Fixed import of setFormatService * Removed unnecessary eslint disable comment
|
@ -49,7 +49,7 @@
|
|||
"visTypeMarkdown": "src/plugins/vis_type_markdown",
|
||||
"visTypeMetric": "src/plugins/vis_type_metric",
|
||||
"visTypeTable": "src/plugins/vis_type_table",
|
||||
"visTypeTagCloud": "src/legacy/core_plugins/vis_type_tagcloud",
|
||||
"visTypeTagCloud": "src/plugins/vis_type_tagcloud",
|
||||
"visTypeTimeseries": ["src/legacy/core_plugins/vis_type_timeseries", "src/plugins/vis_type_timeseries"],
|
||||
"visTypeVega": "src/legacy/core_plugins/vis_type_vega",
|
||||
"visTypeVislib": "src/legacy/core_plugins/vis_type_vislib",
|
||||
|
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
@ -21,7 +21,6 @@ import expect from '@kbn/expect';
|
|||
import _ from 'lodash';
|
||||
import d3 from 'd3';
|
||||
|
||||
import { TagCloud } from '../tag_cloud';
|
||||
import { fromNode, delay } from 'bluebird';
|
||||
import { ImageComparator } from 'test_utils/image_comparator';
|
||||
import simpleloadPng from './simpleload.png';
|
||||
|
@ -29,6 +28,9 @@ import simpleloadPng from './simpleload.png';
|
|||
// Replace with mock when converting to jest tests
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { seedColors } from '../../../../../../plugins/charts/public/services/colors/seed_colors';
|
||||
// Will be replaced with new path when tests are moved
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { TagCloud } from '../../../../../../plugins/vis_type_tagcloud/public/components/tag_cloud';
|
||||
|
||||
describe('tag cloud tests', function() {
|
||||
const minValue = 1;
|
|
@ -20,7 +20,6 @@
|
|||
import expect from '@kbn/expect';
|
||||
import ngMock from 'ng_mock';
|
||||
import { ImageComparator } from 'test_utils/image_comparator';
|
||||
import { createTagCloudVisualization } from '../tag_cloud_visualization';
|
||||
import basicdrawPng from './basicdraw.png';
|
||||
import afterresizePng from './afterresize.png';
|
||||
import afterparamChange from './afterparamchange.png';
|
||||
|
@ -32,7 +31,14 @@ import { ExprVis } from '../../../../../../plugins/visualizations/public/express
|
|||
import { seedColors } from '../../../../../../plugins/charts/public/services/colors/seed_colors';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { BaseVisType } from '../../../../../../plugins/visualizations/public/vis_types/base_vis_type';
|
||||
import { createTagCloudVisTypeDefinition } from '../../tag_cloud_type';
|
||||
// Will be replaced with new path when tests are moved
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { createTagCloudVisTypeDefinition } from '../../../../../../plugins/vis_type_tagcloud/public/tag_cloud_type';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { createTagCloudVisualization } from '../../../../../../plugins/vis_type_tagcloud/public/components/tag_cloud_visualization';
|
||||
import { npStart } from 'ui/new_platform';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { setFormatService } from '../../../../../../plugins/vis_type_tagcloud/public/services';
|
||||
|
||||
const THRESHOLD = 0.65;
|
||||
const PIXEL_DIFF = 64;
|
||||
|
@ -66,6 +72,8 @@ describe('TagCloudVisualizationTest', function() {
|
|||
},
|
||||
});
|
||||
|
||||
before(() => setFormatService(npStart.plugins.data.fieldFormats));
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
|
||||
describe('TagCloudVisualization - basics', function() {
|
|
@ -1,44 +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 { resolve } from 'path';
|
||||
import { Legacy } from 'kibana';
|
||||
|
||||
import { LegacyPluginApi, LegacyPluginInitializer } from '../../../../src/legacy/types';
|
||||
|
||||
const tagCloudPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) =>
|
||||
new Plugin({
|
||||
id: 'tagcloud',
|
||||
require: ['kibana', 'elasticsearch'],
|
||||
publicDir: resolve(__dirname, 'public'),
|
||||
uiExports: {
|
||||
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 tagCloudPluginInitializer;
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"name": "tagcloud",
|
||||
"version": "kibana"
|
||||
}
|
26
src/plugins/vis_type_tagcloud/config.ts
Normal file
|
@ -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>;
|
7
src/plugins/vis_type_tagcloud/kibana.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"id": "visTypeTagcloud",
|
||||
"version": "kibana",
|
||||
"ui": true,
|
||||
"server": true,
|
||||
"requiredPlugins": ["data", "expressions", "visualizations", "charts"]
|
||||
}
|
|
@ -20,9 +20,9 @@
|
|||
import React from 'react';
|
||||
import { EuiPanel } from '@elastic/eui';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
|
||||
import { ValidatedDualRange } from '../../../../../../src/plugins/kibana_react/public';
|
||||
import { SelectOption, SwitchOption } from '../../../../../plugins/charts/public';
|
||||
import { VisOptionsProps } from '../../../vis_default_editor/public';
|
||||
import { ValidatedDualRange } from '../../../kibana_react/public';
|
||||
import { SelectOption, SwitchOption } from '../../../charts/public';
|
||||
import { TagCloudVisParams } from '../types';
|
||||
|
||||
function TagCloudOptions({ stateParams, setValue, vis }: VisOptionsProps<TagCloudVisParams>) {
|
|
@ -1,5 +1,3 @@
|
|||
@import 'src/legacy/ui/public/styles/styling_constants';
|
||||
|
||||
// Prefix all styles with "tgc" to avoid conflicts.
|
||||
// Examples
|
||||
// tgcChart
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from '../../../../core/public';
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { TagCloudPlugin as Plugin } from './plugin';
|
||||
|
||||
export function plugin(initializerContext: PluginInitializerContext) {
|
|
@ -17,15 +17,18 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from '../../../../core/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../../../plugins/expressions/public';
|
||||
import { VisualizationsSetup } from '../../../../plugins/visualizations/public';
|
||||
import { ChartsPluginSetup } from '../../../../plugins/charts/public';
|
||||
import { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'kibana/public';
|
||||
import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public';
|
||||
import { VisualizationsSetup } from '../../visualizations/public';
|
||||
import { ChartsPluginSetup } from '../../charts/public';
|
||||
|
||||
import { createTagCloudFn } from './tag_cloud_fn';
|
||||
import { createTagCloudVisTypeDefinition } from './tag_cloud_type';
|
||||
import { DataPublicPluginStart } from '../../../../plugins/data/public';
|
||||
import { DataPublicPluginStart } from '../../data/public';
|
||||
import { setFormatService } from './services';
|
||||
import { ConfigSchema } from '../config';
|
||||
|
||||
import './index.scss';
|
||||
|
||||
/** @internal */
|
||||
export interface TagCloudPluginSetupDependencies {
|
||||
|
@ -46,9 +49,9 @@ export interface TagCloudVisPluginStartDependencies {
|
|||
|
||||
/** @internal */
|
||||
export class TagCloudPlugin implements Plugin<void, void> {
|
||||
initializerContext: PluginInitializerContext;
|
||||
initializerContext: PluginInitializerContext<ConfigSchema>;
|
||||
|
||||
constructor(initializerContext: PluginInitializerContext) {
|
||||
constructor(initializerContext: PluginInitializerContext<ConfigSchema>) {
|
||||
this.initializerContext = initializerContext;
|
||||
}
|
||||
|
|
@ -17,11 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { createGetterSetter } from '../../../../plugins/kibana_utils/public';
|
||||
import { DataPublicPluginStart } from '../../../../plugins/data/public';
|
||||
import { createGetterSetter } from '../../kibana_utils/public';
|
||||
import { DataPublicPluginStart } from '../../data/public';
|
||||
|
||||
export const [getFormatService, setFormatService] = createGetterSetter<
|
||||
DataPublicPluginStart['fieldFormats']
|
||||
>('data.fieldFormats');
|
||||
|
||||
export { npStart } from 'ui/new_platform';
|
|
@ -19,8 +19,7 @@
|
|||
|
||||
import { createTagCloudFn } from './tag_cloud_fn';
|
||||
|
||||
// eslint-disable-next-line
|
||||
import { functionWrapper } from '../../../../plugins/expressions/common/expression_functions/specs/tests/utils';
|
||||
import { functionWrapper } from '../../expressions/common/expression_functions/specs/tests/utils';
|
||||
|
||||
describe('interpreter/functions#tagcloud', () => {
|
||||
const fn = functionWrapper(createTagCloudFn());
|
|
@ -19,11 +19,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import {
|
||||
ExpressionFunctionDefinition,
|
||||
KibanaDatatable,
|
||||
Render,
|
||||
} from '../../../../plugins/expressions/public';
|
||||
import { ExpressionFunctionDefinition, KibanaDatatable, Render } from '../../expressions/public';
|
||||
import { TagCloudVisParams } from './types';
|
||||
|
||||
const name = 'tagcloud';
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { Schemas } from '../../../../plugins/vis_default_editor/public';
|
||||
import { Schemas } from '../../vis_default_editor/public';
|
||||
|
||||
import { TagCloudOptions } from './components/tag_cloud_options';
|
||||
|
|
@ -17,18 +17,18 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { PluginInitializerContext } from 'kibana/public';
|
||||
import { npSetup, npStart } from 'ui/new_platform';
|
||||
import { TagCloudPluginSetupDependencies } from './plugin';
|
||||
import { plugin } from '.';
|
||||
import { PluginConfigDescriptor } from 'kibana/server';
|
||||
|
||||
const plugins: Readonly<TagCloudPluginSetupDependencies> = {
|
||||
expressions: npSetup.plugins.expressions,
|
||||
visualizations: npSetup.plugins.visualizations,
|
||||
charts: npSetup.plugins.charts,
|
||||
import { configSchema, ConfigSchema } from '../config';
|
||||
|
||||
export const config: PluginConfigDescriptor<ConfigSchema> = {
|
||||
schema: configSchema,
|
||||
deprecations: ({ renameFromRoot }) => [
|
||||
renameFromRoot('tagcloud.enabled', 'vis_type_tagcloud.enabled'),
|
||||
],
|
||||
};
|
||||
|
||||
const pluginInstance = plugin({} as PluginInitializerContext);
|
||||
|
||||
export const setup = pluginInstance.setup(npSetup.core, plugins);
|
||||
export const start = pluginInstance.start(npStart.core, { data: npStart.plugins.data });
|
||||
export const plugin = () => ({
|
||||
setup() {},
|
||||
start() {},
|
||||
});
|