Skip to content

Commit f2779f4

Browse files
committed
Setup consumer (to be reverted)
1 parent 67ce18b commit f2779f4

5 files changed

Lines changed: 42 additions & 4 deletions

File tree

x-pack/plugins/index_management/kibana.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"home",
88
"licensing",
99
"management",
10-
"features"
10+
"features",
11+
"runtimeFields"
1112
],
1213
"optionalPlugins": [
1314
"security",

x-pack/plugins/index_management/public/application/app_context.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
1111
import { CoreSetup, CoreStart } from '../../../../../src/core/public';
1212

1313
import { IngestManagerSetup } from '../../../ingest_manager/public';
14+
import { RuntimeFieldsSetup } from '../../../runtime_fields/public';
1415
import { IndexMgmtMetricsType } from '../types';
1516
import { UiMetricService, NotificationService, HttpService } from './services';
1617
import { ExtensionsService } from '../services';
@@ -24,6 +25,7 @@ export interface AppDependencies {
2425
};
2526
plugins: {
2627
usageCollection: UsageCollectionSetup;
28+
runtimeFields: RuntimeFieldsSetup;
2729
ingestManager?: IngestManagerSetup;
2830
};
2931
services: {

x-pack/plugins/index_management/public/application/mount_management_section.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { ManagementAppMountParams } from 'src/plugins/management/public/';
1010
import { UsageCollectionSetup } from 'src/plugins/usage_collection/public';
1111

1212
import { IngestManagerSetup } from '../../../ingest_manager/public';
13+
import { RuntimeFieldsSetup } from '../../../runtime_fields/public';
1314
import { PLUGIN } from '../../common/constants';
1415
import { ExtensionsService } from '../services';
1516
import { IndexMgmtMetricsType } from '../types';
@@ -32,6 +33,7 @@ export async function mountManagementSection(
3233
usageCollection: UsageCollectionSetup,
3334
services: InternalServices,
3435
params: ManagementAppMountParams,
36+
runtimeFields: RuntimeFieldsSetup,
3537
ingestManager?: IngestManagerSetup
3638
) {
3739
const { element, setBreadcrumbs, history } = params;
@@ -57,6 +59,7 @@ export async function mountManagementSection(
5759
plugins: {
5860
usageCollection,
5961
ingestManager,
62+
runtimeFields,
6063
},
6164
services,
6265
history,

x-pack/plugins/index_management/public/application/sections/home/home.tsx

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import React, { useEffect } from 'react';
7+
import React, { useEffect, useCallback } from 'react';
88
import { Route, RouteComponentProps, Switch } from 'react-router-dom';
99
import { FormattedMessage } from '@kbn/i18n/react';
1010
import {
@@ -17,13 +17,16 @@ import {
1717
EuiTab,
1818
EuiTabs,
1919
EuiTitle,
20+
EuiButton,
2021
} from '@elastic/eui';
22+
import { RuntimeField } from '../../../../../runtime_fields/public';
2123
import { documentationService } from '../../services/documentation';
2224
import { DataStreamList } from './data_stream_list';
2325
import { IndexList } from './index_list';
2426
import { TemplateList } from './template_list';
2527
import { ComponentTemplateList } from '../../components/component_templates';
2628
import { breadcrumbService } from '../../services/breadcrumbs';
29+
import { useAppContext } from '../../app_context';
2730

2831
export enum Section {
2932
Indices = 'indices',
@@ -43,6 +46,8 @@ interface MatchParams {
4346
section: Section;
4447
}
4548

49+
const defaultRuntimeField: RuntimeField = { name: 'myField', type: 'date', script: 'test=123' };
50+
4651
export const IndexManagementHome: React.FunctionComponent<RouteComponentProps<MatchParams>> = ({
4752
match: {
4853
params: { section },
@@ -87,6 +92,19 @@ export const IndexManagementHome: React.FunctionComponent<RouteComponentProps<Ma
8792
history.push(`/${newSection}`);
8893
};
8994

95+
const {
96+
plugins: { runtimeFields },
97+
} = useAppContext();
98+
99+
const onSaveRuntimeField = useCallback((field: RuntimeField) => {
100+
console.log('Updated field', field);
101+
}, []);
102+
103+
const openRuntimeFieldEditor = useCallback(async () => {
104+
const { openEditor } = await runtimeFields.loadEditor();
105+
openEditor({ onSave: onSaveRuntimeField, defaultValue: defaultRuntimeField });
106+
}, [onSaveRuntimeField, runtimeFields]);
107+
90108
useEffect(() => {
91109
breadcrumbService.setBreadcrumbs('home');
92110
}, []);
@@ -117,6 +135,11 @@ export const IndexManagementHome: React.FunctionComponent<RouteComponentProps<Ma
117135
/>
118136
</EuiButtonEmpty>
119137
</EuiFlexItem>
138+
<EuiFlexItem grow={false}>
139+
<EuiButton onClick={openRuntimeFieldEditor} fill>
140+
Create field
141+
</EuiButton>
142+
</EuiFlexItem>
120143
</EuiFlexGroup>
121144
</EuiTitle>
122145

x-pack/plugins/index_management/public/plugin.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { UsageCollectionSetup } from '../../../../src/plugins/usage_collection/p
1010
import { ManagementSetup } from '../../../../src/plugins/management/public';
1111

1212
import { IngestManagerSetup } from '../../ingest_manager/public';
13+
import { RuntimeFieldsSetup } from '../../runtime_fields/public';
1314
import { UIM_APP_NAME, PLUGIN } from '../common/constants';
1415

1516
import { httpService } from './application/services/http';
@@ -30,6 +31,7 @@ interface PluginsDependencies {
3031
ingestManager?: IngestManagerSetup;
3132
usageCollection: UsageCollectionSetup;
3233
management: ManagementSetup;
34+
runtimeFields: RuntimeFieldsSetup;
3335
}
3436

3537
export class IndexMgmtUIPlugin {
@@ -45,7 +47,7 @@ export class IndexMgmtUIPlugin {
4547

4648
public setup(coreSetup: CoreSetup, plugins: PluginsDependencies): IndexManagementPluginSetup {
4749
const { http, notifications } = coreSetup;
48-
const { ingestManager, usageCollection, management } = plugins;
50+
const { ingestManager, usageCollection, management, runtimeFields } = plugins;
4951

5052
httpService.setup(http);
5153
notificationService.setup(notifications);
@@ -63,7 +65,14 @@ export class IndexMgmtUIPlugin {
6365
uiMetricService: this.uiMetricService,
6466
extensionsService: this.extensionsService,
6567
};
66-
return mountManagementSection(coreSetup, usageCollection, services, params, ingestManager);
68+
return mountManagementSection(
69+
coreSetup,
70+
usageCollection,
71+
services,
72+
params,
73+
runtimeFields,
74+
ingestManager
75+
);
6776
},
6877
});
6978

0 commit comments

Comments
 (0)