Skip to content

Commit

Permalink
[NP] Migrate Markdown to NP (#62940)
Browse files Browse the repository at this point in the history
* Migrate Markdown to NP

* Refactoring

* Add ConfigSchema, server, rename markdown_vis to visTypeMarkdown

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
maryia-lapata and elasticmachine authored Apr 16, 2020
1 parent ebcb502 commit bae2bda
Show file tree
Hide file tree
Showing 20 changed files with 61 additions and 74 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
/src/plugins/discover/ @elastic/kibana-app
/src/plugins/vis_type_timeseries/ @elastic/kibana-app
/src/plugins/vis_type_metric/ @elastic/kibana-app
/src/plugins/vis_type_markdown/ @elastic/kibana-app

# Core UI
# Exclude tutorials folder for now because they are not owned by Kibana app and most will move out soon
Expand Down
2 changes: 1 addition & 1 deletion .i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"timelion": ["src/legacy/core_plugins/timelion", "src/legacy/core_plugins/vis_type_timelion", "src/plugins/timelion"],
"uiActions": "src/plugins/ui_actions",
"visDefaultEditor": "src/plugins/vis_default_editor",
"visTypeMarkdown": "src/legacy/core_plugins/vis_type_markdown",
"visTypeMarkdown": "src/plugins/vis_type_markdown",
"visTypeMetric": "src/plugins/vis_type_metric",
"visTypeTable": "src/legacy/core_plugins/vis_type_table",
"visTypeTagCloud": "src/legacy/core_plugins/vis_type_tagcloud",
Expand Down
44 changes: 0 additions & 44 deletions src/legacy/core_plugins/vis_type_markdown/index.ts

This file was deleted.

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

This file was deleted.

26 changes: 26 additions & 0 deletions src/plugins/vis_type_markdown/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>;
7 changes: 7 additions & 0 deletions src/plugins/vis_type_markdown/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "visTypeMarkdown",
"version": "kibana",
"ui": true,
"server": true,
"requiredPlugins": ["expressions", "visualizations"]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import 'src/legacy/ui/public/styles/styling_constants';

// Prefix all styles with "mkd" to avoid conflicts.
// Examples
// mkdChart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

import { PluginInitializerContext } from '../../../../core/public';
import { PluginInitializerContext } from '../../../core/public';
import { MarkdownPlugin as Plugin } from './plugin';

export function plugin(initializerContext: PluginInitializerContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
* under the License.
*/

// 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';
import { createMarkdownVisFn } from './markdown_fn';

describe('interpreter/functions#markdown', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { i18n } from '@kbn/i18n';
import { ExpressionFunctionDefinition, Render } from '../../../../plugins/expressions/public';
import { ExpressionFunctionDefinition, Render } from '../../expressions/public';
import { Arguments, MarkdownVisParams } from './types';

interface RenderValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { i18n } from '@kbn/i18n';
import { MarkdownVisWrapper } from './markdown_vis_controller';
import { MarkdownOptions } from './markdown_options';
import { SettingsOptions } from './settings_options';
import { DefaultEditorSize } from '../../../../plugins/vis_default_editor/public';
import { DefaultEditorSize } from '../../vis_default_editor/public';

export const markdownVisDefinition = {
name: 'markdown',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import React from 'react';
import { Markdown } from '../../../../plugins/kibana_react/public';
import { Markdown } from '../../kibana_react/public';
import { MarkdownVisParams } from './types';

interface MarkdownVisComponentProps extends MarkdownVisParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@
* 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 '../../../core/public';
import { Plugin as ExpressionsPublicPlugin } from '../../expressions/public';
import { VisualizationsSetup } from '../../visualizations/public';

import { markdownVisDefinition } from './markdown_vis';
import { createMarkdownVisFn } from './markdown_fn';
import { ConfigSchema } from '../config';

import './index.scss';

/** @internal */
export interface MarkdownPluginSetupDependencies {
Expand All @@ -32,9 +35,9 @@ export interface MarkdownPluginSetupDependencies {

/** @internal */
export class MarkdownPlugin 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 @@ -22,7 +22,7 @@ import { EuiPanel } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { VisOptionsProps } from 'src/plugins/vis_default_editor/public';
import { RangeOption, SwitchOption } from '../../../../plugins/charts/public';
import { RangeOption, SwitchOption } from '../../charts/public';
import { MarkdownVisParams } from './types';

function SettingsOptions({ stateParams, setValue }: VisOptionsProps<MarkdownVisParams>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
* under the License.
*/

import { PluginInitializerContext } from 'kibana/public';
import { npSetup, npStart } from 'ui/new_platform';
import { MarkdownPluginSetupDependencies } from './plugin';
import { plugin } from '.';
import { PluginConfigDescriptor } from 'kibana/server';

const plugins: Readonly<MarkdownPluginSetupDependencies> = {
expressions: npSetup.plugins.expressions,
visualizations: npSetup.plugins.visualizations,
};
import { configSchema, ConfigSchema } from '../config';

const pluginInstance = plugin({} as PluginInitializerContext);
export const config: PluginConfigDescriptor<ConfigSchema> = {
schema: configSchema,
deprecations: ({ renameFromRoot }) => [
renameFromRoot('markdown_vis.enabled', 'vis_type_markdown.enabled'),
],
};

export const setup = pluginInstance.setup(npSetup.core, plugins);
export const start = pluginInstance.start(npStart.core);
export const plugin = () => ({
setup() {},
start() {},
});

0 comments on commit bae2bda

Please sign in to comment.