Skip to content

Commit

Permalink
Migrate vis_type_metric to kibana/new platform (elastic#63096)
Browse files Browse the repository at this point in the history
* Move vis_type_metric to Kibana Platform

* Adapt i18n

* Cleanup tests

* Modify CODEOWNERS

* Cleanup SCSS
  • Loading branch information
kertal committed Apr 16, 2020
1 parent 5a1cedc commit ad5026f
Show file tree
Hide file tree
Showing 23 changed files with 75 additions and 95 deletions.
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
44 changes: 0 additions & 44 deletions src/legacy/core_plugins/vis_type_metric/index.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/legacy/core_plugins/vis_type_metric/package.json

This file was deleted.

26 changes: 26 additions & 0 deletions src/plugins/vis_type_metric/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>;
8 changes: 8 additions & 0 deletions src/plugins/vis_type_metric/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "visTypeMetric",
"version": "8.0.0",
"kibanaVersion": "kibana",
"server": true,
"ui": true,
"requiredPlugins": ["data", "visualizations", "charts","expressions"]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
RangeOption,
SetColorSchemaOptionsValue,
SetColorRangeValue,
} from '../../../../../plugins/charts/public';
} from '../../../charts/public';
import { MetricVisParam, VisParams } from '../types';

function MetricVisOptions({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
@import 'src/legacy/ui/public/styles/styling_constants';

// Prefix all styles with "mtr" to avoid conflicts.
// Examples
// mtrChart
// mtrChart__legend
// mtrChart__legend--small
// mtrChart__legend-isLoading

@import './metric_vis';
@import 'metric_vis';
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -41,9 +42,9 @@ export interface MetricVisPluginStartDependencies {

/** @internal */
export class MetricVisPlugin implements Plugin<void, void> {
initializerContext: PluginInitializerContext;
initializerContext: PluginInitializerContext<ConfigSchema>;

constructor(initializerContext: PluginInitializerContext) {
constructor(initializerContext: PluginInitializerContext<ConfigSchema>) {
this.initializerContext = initializerContext;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<MetricVisPluginSetupDependencies> = {
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<ConfigSchema> = {
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() {},
});

0 comments on commit ad5026f

Please sign in to comment.