diff --git a/.i18nrc.json b/.i18nrc.json index e18f529b92ac3..2edf178e37bd5 100644 --- a/.i18nrc.json +++ b/.i18nrc.json @@ -47,7 +47,7 @@ "uiActions": "src/plugins/ui_actions", "visDefaultEditor": "src/plugins/vis_default_editor", "visTypeMarkdown": "src/legacy/core_plugins/vis_type_markdown", - "visTypeMetric": "src/legacy/core_plugins/vis_type_metric", + "visTypeMetric": "src/plugins/vis_type_metric", "visTypeTable": "src/legacy/core_plugins/vis_type_table", "visTypeTagCloud": "src/legacy/core_plugins/vis_type_tagcloud", "visTypeTimeseries": ["src/legacy/core_plugins/vis_type_timeseries", "src/plugins/vis_type_timeseries"], diff --git a/src/legacy/core_plugins/vis_type_metric/index.ts b/src/legacy/core_plugins/vis_type_metric/index.ts deleted file mode 100644 index 8e6654e40f0fc..0000000000000 --- a/src/legacy/core_plugins/vis_type_metric/index.ts +++ /dev/null @@ -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 metricPluginInitializer: LegacyPluginInitializer = ({ Plugin }: LegacyPluginApi) => - new Plugin({ - id: 'metric_vis', - 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 metricPluginInitializer; diff --git a/src/legacy/core_plugins/vis_type_metric/package.json b/src/legacy/core_plugins/vis_type_metric/package.json deleted file mode 100644 index e570261fc30dd..0000000000000 --- a/src/legacy/core_plugins/vis_type_metric/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "name": "metric_vis", - "version": "kibana" -} diff --git a/src/plugins/vis_type_metric/config.ts b/src/plugins/vis_type_metric/config.ts new file mode 100644 index 0000000000000..6749bd83de39f --- /dev/null +++ b/src/plugins/vis_type_metric/config.ts @@ -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; diff --git a/src/plugins/vis_type_metric/kibana.json b/src/plugins/vis_type_metric/kibana.json new file mode 100644 index 0000000000000..24135d257b317 --- /dev/null +++ b/src/plugins/vis_type_metric/kibana.json @@ -0,0 +1,8 @@ +{ + "id": "visTypeMetric", + "version": "8.0.0", + "kibanaVersion": "kibana", + "server": true, + "ui": true, + "requiredPlugins": ["data", "visualizations", "charts","expressions"] +} diff --git a/src/legacy/core_plugins/vis_type_metric/public/__snapshots__/metric_vis_fn.test.ts.snap b/src/plugins/vis_type_metric/public/__snapshots__/metric_vis_fn.test.ts.snap similarity index 100% rename from src/legacy/core_plugins/vis_type_metric/public/__snapshots__/metric_vis_fn.test.ts.snap rename to src/plugins/vis_type_metric/public/__snapshots__/metric_vis_fn.test.ts.snap diff --git a/src/legacy/core_plugins/vis_type_metric/public/_metric_vis.scss b/src/plugins/vis_type_metric/public/_metric_vis.scss similarity index 100% rename from src/legacy/core_plugins/vis_type_metric/public/_metric_vis.scss rename to src/plugins/vis_type_metric/public/_metric_vis.scss diff --git a/src/legacy/core_plugins/vis_type_metric/public/components/__snapshots__/metric_vis_component.test.tsx.snap b/src/plugins/vis_type_metric/public/components/__snapshots__/metric_vis_component.test.tsx.snap similarity index 100% rename from src/legacy/core_plugins/vis_type_metric/public/components/__snapshots__/metric_vis_component.test.tsx.snap rename to src/plugins/vis_type_metric/public/components/__snapshots__/metric_vis_component.test.tsx.snap diff --git a/src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_component.test.tsx b/src/plugins/vis_type_metric/public/components/metric_vis_component.test.tsx similarity index 97% rename from src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_component.test.tsx rename to src/plugins/vis_type_metric/public/components/metric_vis_component.test.tsx index 2bd423656b0f0..3969b28d75414 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_component.test.tsx +++ b/src/plugins/vis_type_metric/public/components/metric_vis_component.test.tsx @@ -21,7 +21,7 @@ import React from 'react'; import { shallow } from 'enzyme'; import { MetricVisComponent, MetricVisComponentProps } from './metric_vis_component'; -import { ExprVis } from '../../../../../plugins/visualizations/public'; +import { ExprVis } from '../../../visualizations/public'; jest.mock('../services', () => ({ getFormatService: () => ({ diff --git a/src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_component.tsx b/src/plugins/vis_type_metric/public/components/metric_vis_component.tsx similarity index 96% rename from src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_component.tsx rename to src/plugins/vis_type_metric/public/components/metric_vis_component.tsx index de2cc66a99c79..eb3986b6388fe 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_component.tsx +++ b/src/plugins/vis_type_metric/public/components/metric_vis_component.tsx @@ -22,12 +22,12 @@ import React, { Component } from 'react'; import { isColorDark } from '@elastic/eui'; import { MetricVisValue } from './metric_vis_value'; import { Input } from '../metric_vis_fn'; -import { FieldFormatsContentType, IFieldFormat } from '../../../../../plugins/data/public'; -import { KibanaDatatable } from '../../../../../plugins/expressions/public'; -import { getHeatmapColors } from '../../../../../plugins/charts/public'; +import { FieldFormatsContentType, IFieldFormat } from '../../../data/public'; +import { KibanaDatatable } from '../../../expressions/public'; +import { getHeatmapColors } from '../../../charts/public'; import { VisParams, MetricVisMetric } from '../types'; import { getFormatService } from '../services'; -import { SchemaConfig, ExprVis } from '../../../../../plugins/visualizations/public'; +import { SchemaConfig, ExprVis } from '../../../visualizations/public'; export interface MetricVisComponentProps { visParams: VisParams; diff --git a/src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_options.tsx b/src/plugins/vis_type_metric/public/components/metric_vis_options.tsx similarity index 99% rename from src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_options.tsx rename to src/plugins/vis_type_metric/public/components/metric_vis_options.tsx index 56af0ee91878f..009d63ded39b4 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_options.tsx +++ b/src/plugins/vis_type_metric/public/components/metric_vis_options.tsx @@ -38,7 +38,7 @@ import { RangeOption, SetColorSchemaOptionsValue, SetColorRangeValue, -} from '../../../../../plugins/charts/public'; +} from '../../../charts/public'; import { MetricVisParam, VisParams } from '../types'; function MetricVisOptions({ diff --git a/src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_value.test.tsx b/src/plugins/vis_type_metric/public/components/metric_vis_value.test.tsx similarity index 100% rename from src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_value.test.tsx rename to src/plugins/vis_type_metric/public/components/metric_vis_value.test.tsx diff --git a/src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_value.tsx b/src/plugins/vis_type_metric/public/components/metric_vis_value.tsx similarity index 100% rename from src/legacy/core_plugins/vis_type_metric/public/components/metric_vis_value.tsx rename to src/plugins/vis_type_metric/public/components/metric_vis_value.tsx diff --git a/src/legacy/core_plugins/vis_type_metric/public/index.scss b/src/plugins/vis_type_metric/public/index.scss similarity index 66% rename from src/legacy/core_plugins/vis_type_metric/public/index.scss rename to src/plugins/vis_type_metric/public/index.scss index e4116b69bf0f1..638f9ac1ef93a 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/index.scss +++ b/src/plugins/vis_type_metric/public/index.scss @@ -1,5 +1,3 @@ -@import 'src/legacy/ui/public/styles/styling_constants'; - // Prefix all styles with "mtr" to avoid conflicts. // Examples // mtrChart @@ -7,4 +5,4 @@ // mtrChart__legend--small // mtrChart__legend-isLoading -@import './metric_vis'; +@import 'metric_vis'; diff --git a/src/legacy/core_plugins/vis_type_metric/public/index.ts b/src/plugins/vis_type_metric/public/index.ts similarity index 92% rename from src/legacy/core_plugins/vis_type_metric/public/index.ts rename to src/plugins/vis_type_metric/public/index.ts index 7499babef58a7..3d3e1879a51d9 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/index.ts +++ b/src/plugins/vis_type_metric/public/index.ts @@ -16,8 +16,8 @@ * specific language governing permissions and limitations * under the License. */ - -import { PluginInitializerContext } from '../../../../core/public'; +import './index.scss'; +import { PluginInitializerContext } from 'kibana/public'; import { MetricVisPlugin as Plugin } from './plugin'; export function plugin(initializerContext: PluginInitializerContext) { diff --git a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts b/src/plugins/vis_type_metric/public/metric_vis_fn.test.ts similarity index 90% rename from src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts rename to src/plugins/vis_type_metric/public/metric_vis_fn.test.ts index 4094cd4eff060..3ed8f8f79a83f 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.test.ts +++ b/src/plugins/vis_type_metric/public/metric_vis_fn.test.ts @@ -18,10 +18,7 @@ */ import { createMetricVisFn } from './metric_vis_fn'; -// eslint-disable-next-line @kbn/eslint/no-restricted-paths -import { functionWrapper } from '../../../../plugins/expressions/common/expression_functions/specs/tests/utils'; - -jest.mock('ui/new_platform'); +import { functionWrapper } from '../../expressions/common/expression_functions/specs/tests/utils'; describe('interpreter/functions#metric', () => { const fn = functionWrapper(createMetricVisFn()); diff --git a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.ts b/src/plugins/vis_type_metric/public/metric_vis_fn.ts similarity index 98% rename from src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.ts rename to src/plugins/vis_type_metric/public/metric_vis_fn.ts index 52784da1bd73b..3d16fed0fa385 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_fn.ts +++ b/src/plugins/vis_type_metric/public/metric_vis_fn.ts @@ -25,9 +25,9 @@ import { Range, Render, Style, -} from '../../../../plugins/expressions/public'; +} from '../../expressions/public'; import { visType, DimensionsVisParam, VisParams } from './types'; -import { ColorSchemas, vislibColorMaps, ColorModes } from '../../../../plugins/charts/public'; +import { ColorSchemas, vislibColorMaps, ColorModes } from '../../charts/public'; export type Input = KibanaDatatable; diff --git a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts b/src/plugins/vis_type_metric/public/metric_vis_type.test.ts similarity index 97% rename from src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts rename to src/plugins/vis_type_metric/public/metric_vis_type.test.ts index 706693eff1007..636118c692aaa 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.test.ts +++ b/src/plugins/vis_type_metric/public/metric_vis_type.test.ts @@ -20,8 +20,6 @@ import { createMetricVisTypeDefinition } from './metric_vis_type'; import { MetricVisComponent } from './components/metric_vis_component'; -jest.mock('ui/new_platform'); - describe('metric_vis - createMetricVisTypeDefinition', () => { it('has metric vis component set', () => { const def = createMetricVisTypeDefinition(); diff --git a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts b/src/plugins/vis_type_metric/public/metric_vis_type.ts similarity index 93% rename from src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts rename to src/plugins/vis_type_metric/public/metric_vis_type.ts index ab31c56921412..b7e9213283bee 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/metric_vis_type.ts +++ b/src/plugins/vis_type_metric/public/metric_vis_type.ts @@ -21,9 +21,9 @@ import { i18n } from '@kbn/i18n'; import { MetricVisComponent } from './components/metric_vis_component'; import { MetricVisOptions } from './components/metric_vis_options'; -import { ColorSchemas, colorSchemas, ColorModes } from '../../../../plugins/charts/public'; -import { AggGroupNames } from '../../../../plugins/data/public'; -import { Schemas } from '../../../../plugins/vis_default_editor/public'; +import { ColorSchemas, colorSchemas, ColorModes } from '../../charts/public'; +import { AggGroupNames } from '../../data/public'; +import { Schemas } from '../../vis_default_editor/public'; export const createMetricVisTypeDefinition = () => ({ name: 'metric', diff --git a/src/legacy/core_plugins/vis_type_metric/public/plugin.ts b/src/plugins/vis_type_metric/public/plugin.ts similarity index 79% rename from src/legacy/core_plugins/vis_type_metric/public/plugin.ts rename to src/plugins/vis_type_metric/public/plugin.ts index cb65d5cafbdd2..a3951fa46c21c 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/plugin.ts +++ b/src/plugins/vis_type_metric/public/plugin.ts @@ -17,15 +17,16 @@ * 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 { PluginInitializerContext, CoreSetup, CoreStart, Plugin } from 'kibana/public'; +import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public'; +import { VisualizationsSetup } from '../../visualizations/public'; import { createMetricVisFn } from './metric_vis_fn'; import { createMetricVisTypeDefinition } from './metric_vis_type'; -import { ChartsPluginSetup } from '../../../../plugins/charts/public'; -import { DataPublicPluginStart } from '../../../../plugins/data/public'; +import { ChartsPluginSetup } from '../../charts/public'; +import { DataPublicPluginStart } from '../../data/public'; import { setFormatService } from './services'; +import { ConfigSchema } from '../config'; /** @internal */ export interface MetricVisPluginSetupDependencies { @@ -41,9 +42,9 @@ export interface MetricVisPluginStartDependencies { /** @internal */ export class MetricVisPlugin implements Plugin { - initializerContext: PluginInitializerContext; + initializerContext: PluginInitializerContext; - constructor(initializerContext: PluginInitializerContext) { + constructor(initializerContext: PluginInitializerContext) { this.initializerContext = initializerContext; } diff --git a/src/legacy/core_plugins/vis_type_metric/public/services.ts b/src/plugins/vis_type_metric/public/services.ts similarity index 86% rename from src/legacy/core_plugins/vis_type_metric/public/services.ts rename to src/plugins/vis_type_metric/public/services.ts index b303ccd5aeed2..681afbaf0b268 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/services.ts +++ b/src/plugins/vis_type_metric/public/services.ts @@ -17,8 +17,8 @@ * under the License. */ -import { createGetterSetter } from '../../../../plugins/kibana_utils/public'; -import { DataPublicPluginStart } from '../../../../plugins/data/public'; +import { createGetterSetter } from '../../kibana_utils/common'; +import { DataPublicPluginStart } from '../../data/public'; export const [getFormatService, setFormatService] = createGetterSetter< DataPublicPluginStart['fieldFormats'] diff --git a/src/legacy/core_plugins/vis_type_metric/public/types.ts b/src/plugins/vis_type_metric/public/types.ts similarity index 86% rename from src/legacy/core_plugins/vis_type_metric/public/types.ts rename to src/plugins/vis_type_metric/public/types.ts index cdf62cba934d7..e1f2c7721a426 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/types.ts +++ b/src/plugins/vis_type_metric/public/types.ts @@ -17,9 +17,9 @@ * under the License. */ -import { Range } from '../../../../plugins/expressions/public'; -import { SchemaConfig } from '../../../../plugins/visualizations/public'; -import { ColorModes, ColorSchemas, Labels, Style } from '../../../../plugins/charts/public'; +import { Range } from '../../expressions/public'; +import { SchemaConfig } from '../../visualizations/public'; +import { ColorModes, Labels, Style, ColorSchemas } from '../../charts/public'; export const visType = 'metric'; diff --git a/src/legacy/core_plugins/vis_type_metric/public/legacy.ts b/src/plugins/vis_type_metric/server/index.ts similarity index 57% rename from src/legacy/core_plugins/vis_type_metric/public/legacy.ts rename to src/plugins/vis_type_metric/server/index.ts index ba883601e5d65..ce550dc81dd85 100644 --- a/src/legacy/core_plugins/vis_type_metric/public/legacy.ts +++ b/src/plugins/vis_type_metric/server/index.ts @@ -17,18 +17,18 @@ * under the License. */ -import { PluginInitializerContext } from 'kibana/public'; -import { npSetup, npStart } from 'ui/new_platform'; -import { MetricVisPluginSetupDependencies } from './plugin'; -import { plugin } from '.'; +import { PluginConfigDescriptor } from 'kibana/server'; -const plugins: Readonly = { - expressions: npSetup.plugins.expressions, - visualizations: npSetup.plugins.visualizations, - charts: npSetup.plugins.charts, -}; +import { configSchema, ConfigSchema } from '../config'; -const pluginInstance = plugin({} as PluginInitializerContext); +export const config: PluginConfigDescriptor = { + schema: configSchema, + deprecations: ({ renameFromRoot }) => [ + renameFromRoot('metric_vis.enabled', 'vis_type_metric.enabled'), + ], +}; -export const setup = pluginInstance.setup(npSetup.core, plugins); -export const start = pluginInstance.start(npStart.core, { data: npStart.plugins.data }); +export const plugin = () => ({ + setup() {}, + start() {}, +});