From f2779f40cf63c02a8df3839b271ac64208bda168 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81bastien=20Loix?= Date: Tue, 3 Nov 2020 17:50:58 +0100 Subject: [PATCH] Setup consumer (to be reverted) --- x-pack/plugins/index_management/kibana.json | 3 ++- .../public/application/app_context.tsx | 2 ++ .../application/mount_management_section.ts | 3 +++ .../public/application/sections/home/home.tsx | 25 ++++++++++++++++++- .../plugins/index_management/public/plugin.ts | 13 ++++++++-- 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/index_management/kibana.json b/x-pack/plugins/index_management/kibana.json index 097ac03aabd22..b8ff62fdf6532 100644 --- a/x-pack/plugins/index_management/kibana.json +++ b/x-pack/plugins/index_management/kibana.json @@ -7,7 +7,8 @@ "home", "licensing", "management", - "features" + "features", + "runtimeFields" ], "optionalPlugins": [ "security", diff --git a/x-pack/plugins/index_management/public/application/app_context.tsx b/x-pack/plugins/index_management/public/application/app_context.tsx index 22e6f09907d75..e32bf7367ab06 100644 --- a/x-pack/plugins/index_management/public/application/app_context.tsx +++ b/x-pack/plugins/index_management/public/application/app_context.tsx @@ -11,6 +11,7 @@ import { UsageCollectionSetup } from 'src/plugins/usage_collection/public'; import { CoreSetup, CoreStart } from '../../../../../src/core/public'; import { IngestManagerSetup } from '../../../ingest_manager/public'; +import { RuntimeFieldsSetup } from '../../../runtime_fields/public'; import { IndexMgmtMetricsType } from '../types'; import { UiMetricService, NotificationService, HttpService } from './services'; import { ExtensionsService } from '../services'; @@ -24,6 +25,7 @@ export interface AppDependencies { }; plugins: { usageCollection: UsageCollectionSetup; + runtimeFields: RuntimeFieldsSetup; ingestManager?: IngestManagerSetup; }; services: { diff --git a/x-pack/plugins/index_management/public/application/mount_management_section.ts b/x-pack/plugins/index_management/public/application/mount_management_section.ts index f7b728c875762..dfda6a78f9e7c 100644 --- a/x-pack/plugins/index_management/public/application/mount_management_section.ts +++ b/x-pack/plugins/index_management/public/application/mount_management_section.ts @@ -10,6 +10,7 @@ import { ManagementAppMountParams } from 'src/plugins/management/public/'; import { UsageCollectionSetup } from 'src/plugins/usage_collection/public'; import { IngestManagerSetup } from '../../../ingest_manager/public'; +import { RuntimeFieldsSetup } from '../../../runtime_fields/public'; import { PLUGIN } from '../../common/constants'; import { ExtensionsService } from '../services'; import { IndexMgmtMetricsType } from '../types'; @@ -32,6 +33,7 @@ export async function mountManagementSection( usageCollection: UsageCollectionSetup, services: InternalServices, params: ManagementAppMountParams, + runtimeFields: RuntimeFieldsSetup, ingestManager?: IngestManagerSetup ) { const { element, setBreadcrumbs, history } = params; @@ -57,6 +59,7 @@ export async function mountManagementSection( plugins: { usageCollection, ingestManager, + runtimeFields, }, services, history, diff --git a/x-pack/plugins/index_management/public/application/sections/home/home.tsx b/x-pack/plugins/index_management/public/application/sections/home/home.tsx index ee8970a3c4509..8b9a524c31314 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/home.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/home.tsx @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useEffect } from 'react'; +import React, { useEffect, useCallback } from 'react'; import { Route, RouteComponentProps, Switch } from 'react-router-dom'; import { FormattedMessage } from '@kbn/i18n/react'; import { @@ -17,13 +17,16 @@ import { EuiTab, EuiTabs, EuiTitle, + EuiButton, } from '@elastic/eui'; +import { RuntimeField } from '../../../../../runtime_fields/public'; import { documentationService } from '../../services/documentation'; import { DataStreamList } from './data_stream_list'; import { IndexList } from './index_list'; import { TemplateList } from './template_list'; import { ComponentTemplateList } from '../../components/component_templates'; import { breadcrumbService } from '../../services/breadcrumbs'; +import { useAppContext } from '../../app_context'; export enum Section { Indices = 'indices', @@ -43,6 +46,8 @@ interface MatchParams { section: Section; } +const defaultRuntimeField: RuntimeField = { name: 'myField', type: 'date', script: 'test=123' }; + export const IndexManagementHome: React.FunctionComponent> = ({ match: { params: { section }, @@ -87,6 +92,19 @@ export const IndexManagementHome: React.FunctionComponent { + console.log('Updated field', field); + }, []); + + const openRuntimeFieldEditor = useCallback(async () => { + const { openEditor } = await runtimeFields.loadEditor(); + openEditor({ onSave: onSaveRuntimeField, defaultValue: defaultRuntimeField }); + }, [onSaveRuntimeField, runtimeFields]); + useEffect(() => { breadcrumbService.setBreadcrumbs('home'); }, []); @@ -117,6 +135,11 @@ export const IndexManagementHome: React.FunctionComponent + + + Create field + + diff --git a/x-pack/plugins/index_management/public/plugin.ts b/x-pack/plugins/index_management/public/plugin.ts index 6139ed5d2e6ad..241c1e99a5f10 100644 --- a/x-pack/plugins/index_management/public/plugin.ts +++ b/x-pack/plugins/index_management/public/plugin.ts @@ -10,6 +10,7 @@ import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/p import { ManagementSetup } from '../../../../src/plugins/management/public'; import { IngestManagerSetup } from '../../ingest_manager/public'; +import { RuntimeFieldsSetup } from '../../runtime_fields/public'; import { UIM_APP_NAME, PLUGIN } from '../common/constants'; import { httpService } from './application/services/http'; @@ -30,6 +31,7 @@ interface PluginsDependencies { ingestManager?: IngestManagerSetup; usageCollection: UsageCollectionSetup; management: ManagementSetup; + runtimeFields: RuntimeFieldsSetup; } export class IndexMgmtUIPlugin { @@ -45,7 +47,7 @@ export class IndexMgmtUIPlugin { public setup(coreSetup: CoreSetup, plugins: PluginsDependencies): IndexManagementPluginSetup { const { http, notifications } = coreSetup; - const { ingestManager, usageCollection, management } = plugins; + const { ingestManager, usageCollection, management, runtimeFields } = plugins; httpService.setup(http); notificationService.setup(notifications); @@ -63,7 +65,14 @@ export class IndexMgmtUIPlugin { uiMetricService: this.uiMetricService, extensionsService: this.extensionsService, }; - return mountManagementSection(coreSetup, usageCollection, services, params, ingestManager); + return mountManagementSection( + coreSetup, + usageCollection, + services, + params, + runtimeFields, + ingestManager + ); }, });