* Move vis_type_metric to Kibana Platform * Adapt i18n * Cleanup tests * Modify CODEOWNERS * Cleanup SCSS
This commit is contained in:
parent
f218e965eb
commit
5ea06287e3
|
@ -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"],
|
||||
|
|
|
@ -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;
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"name": "metric_vis",
|
||||
"version": "kibana"
|
||||
}
|
26
src/plugins/vis_type_metric/config.ts
Normal file
26
src/plugins/vis_type_metric/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>;
|
8
src/plugins/vis_type_metric/kibana.json
Normal file
8
src/plugins/vis_type_metric/kibana.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"id": "visTypeMetric",
|
||||
"version": "8.0.0",
|
||||
"kibanaVersion": "kibana",
|
||||
"server": true,
|
||||
"ui": true,
|
||||
"requiredPlugins": ["data", "visualizations", "charts","expressions"]
|
||||
}
|
|
@ -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: () => ({
|
|
@ -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;
|
|
@ -38,7 +38,7 @@ import {
|
|||
RangeOption,
|
||||
SetColorSchemaOptionsValue,
|
||||
SetColorRangeValue,
|
||||
} from '../../../../../plugins/charts/public';
|
||||
} from '../../../charts/public';
|
||||
import { MetricVisParam, VisParams } from '../types';
|
||||
|
||||
function MetricVisOptions({
|
|
@ -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';
|
|
@ -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) {
|
|
@ -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());
|
|
@ -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;
|
||||
|
|
@ -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();
|
|
@ -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',
|
|
@ -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<void, void> {
|
||||
initializerContext: PluginInitializerContext;
|
||||
initializerContext: PluginInitializerContext<ConfigSchema>;
|
||||
|
||||
constructor(initializerContext: PluginInitializerContext) {
|
||||
constructor(initializerContext: PluginInitializerContext<ConfigSchema>) {
|
||||
this.initializerContext = initializerContext;
|
||||
}
|
||||
|
|
@ -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']
|
|
@ -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';
|
||||
|
|
@ -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';
|
||||
|
||||
export const config: PluginConfigDescriptor<ConfigSchema> = {
|
||||
schema: configSchema,
|
||||
deprecations: ({ renameFromRoot }) => [
|
||||
renameFromRoot('metric_vis.enabled', 'vis_type_metric.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() {},
|
||||
});
|
Loading…
Reference in a new issue