From 20316f0643ad51f48976a465f74ea8cc8e448088 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Fri, 13 Dec 2019 16:19:45 +0100 Subject: [PATCH] Restore text_object model and mappings --- src/legacy/core_plugins/console/index.ts | 4 +++ src/legacy/core_plugins/console/mappings.json | 18 ++++++++++++ .../core_plugins/console/public/legacy.ts | 2 -- .../application/models/text_object.ts | 28 +++++++++++++++++++ .../console/public/np_ready/plugin.ts | 8 +++--- 5 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 src/legacy/core_plugins/console/mappings.json create mode 100644 src/legacy/core_plugins/console/public/np_ready/application/models/text_object.ts diff --git a/src/legacy/core_plugins/console/index.ts b/src/legacy/core_plugins/console/index.ts index cec6d0a4219ae1..6f36a33f3ecbc4 100644 --- a/src/legacy/core_plugins/console/index.ts +++ b/src/legacy/core_plugins/console/index.ts @@ -23,6 +23,9 @@ import { resolve, join } from 'path'; import url from 'url'; import { has, isEmpty, head, pick } from 'lodash'; +// @ts-ignore +import mappings from './mappings.json'; + // @ts-ignore import { addProcessorDefinition } from './server/api_server/es_6_0/ingest'; // @ts-ignore @@ -182,6 +185,7 @@ export default function(kibana: any) { styleSheetPaths: resolve(npSrc, 'application/styles/index.scss'), injectDefaultVars: () => defaultVars, noParse: [join(npSrc, 'application/models/legacy_core_editor/mode/worker/worker.js')], + mappings, }, } as any); } diff --git a/src/legacy/core_plugins/console/mappings.json b/src/legacy/core_plugins/console/mappings.json new file mode 100644 index 00000000000000..8a432e744e96f0 --- /dev/null +++ b/src/legacy/core_plugins/console/mappings.json @@ -0,0 +1,18 @@ +{ + "text-object": { + "properties": { + "createdAt": { + "type": "long" + }, + "updateAt": { + "type": "long" + }, + "text": { + "type": "keyword" + }, + "userId": { + "type": "keyword" + } + } + } +} diff --git a/src/legacy/core_plugins/console/public/legacy.ts b/src/legacy/core_plugins/console/public/legacy.ts index b7a113b800d6d0..7dc388bb373729 100644 --- a/src/legacy/core_plugins/console/public/legacy.ts +++ b/src/legacy/core_plugins/console/public/legacy.ts @@ -28,7 +28,6 @@ export interface XPluginSet { dev_tools: DevToolsSetup; home: HomePublicPluginSetup; __LEGACY: { - savedObjects: SavedObjectsClientContract; I18nContext: any; elasticsearchUrl: string; category: FeatureCatalogueCategory; @@ -45,7 +44,6 @@ const pluginInstance = plugin({} as any); await pluginInstance.setup(npSetup.core, { ...npSetup.plugins, __LEGACY: { - savedObjects: npStart.core.savedObjects.client, elasticsearchUrl: chrome.getInjected('elasticsearchUrl'), category: FeatureCatalogueCategory.ADMIN, I18nContext, diff --git a/src/legacy/core_plugins/console/public/np_ready/application/models/text_object.ts b/src/legacy/core_plugins/console/public/np_ready/application/models/text_object.ts new file mode 100644 index 00000000000000..d383f7b7ee693c --- /dev/null +++ b/src/legacy/core_plugins/console/public/np_ready/application/models/text_object.ts @@ -0,0 +1,28 @@ +/* + * 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 { SavedObjectAttributes } from 'src/core/public'; +export const type = 'text-object'; + +export interface TextObject extends SavedObjectAttributes { + createdAt: number; + updateAt: number; + text: string; + userId: string; + id: string; +} diff --git a/src/legacy/core_plugins/console/public/np_ready/plugin.ts b/src/legacy/core_plugins/console/public/np_ready/plugin.ts index 918c6f559e555d..c9b68ea2cac932 100644 --- a/src/legacy/core_plugins/console/public/np_ready/plugin.ts +++ b/src/legacy/core_plugins/console/public/np_ready/plugin.ts @@ -29,7 +29,7 @@ export class ConsoleUIPlugin implements Plugin { async setup({ notifications }: CoreSetup, pluginSet: XPluginSet) { const { - __LEGACY: { I18nContext, savedObjects, elasticsearchUrl, category }, + __LEGACY: { I18nContext, elasticsearchUrl, category }, dev_tools, home, } = pluginSet; @@ -55,15 +55,15 @@ export class ConsoleUIPlugin implements Plugin { defaultMessage: 'Console', }), enableRouting: false, - async mount(ctx, { element }) { + async mount({ core: { docLinks, savedObjects } }, { element }) { const { boot } = await import('./application'); render( boot({ - docLinkVersion: ctx.core.docLinks.DOC_LINK_VERSION, + docLinkVersion: docLinks.DOC_LINK_VERSION, I18nContext, notifications, elasticsearchUrl, - savedObjects, + savedObjects: savedObjects.client, }), element );