Skip to content

Commit

Permalink
Setup consumer (to be reverted)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebelga committed Nov 3, 2020
1 parent 67ce18b commit f2779f4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 4 deletions.
3 changes: 2 additions & 1 deletion x-pack/plugins/index_management/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"home",
"licensing",
"management",
"features"
"features",
"runtimeFields"
],
"optionalPlugins": [
"security",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -24,6 +25,7 @@ export interface AppDependencies {
};
plugins: {
usageCollection: UsageCollectionSetup;
runtimeFields: RuntimeFieldsSetup;
ingestManager?: IngestManagerSetup;
};
services: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -32,6 +33,7 @@ export async function mountManagementSection(
usageCollection: UsageCollectionSetup,
services: InternalServices,
params: ManagementAppMountParams,
runtimeFields: RuntimeFieldsSetup,
ingestManager?: IngestManagerSetup
) {
const { element, setBreadcrumbs, history } = params;
Expand All @@ -57,6 +59,7 @@ export async function mountManagementSection(
plugins: {
usageCollection,
ingestManager,
runtimeFields,
},
services,
history,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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',
Expand All @@ -43,6 +46,8 @@ interface MatchParams {
section: Section;
}

const defaultRuntimeField: RuntimeField = { name: 'myField', type: 'date', script: 'test=123' };

export const IndexManagementHome: React.FunctionComponent<RouteComponentProps<MatchParams>> = ({
match: {
params: { section },
Expand Down Expand Up @@ -87,6 +92,19 @@ export const IndexManagementHome: React.FunctionComponent<RouteComponentProps<Ma
history.push(`/${newSection}`);
};

const {
plugins: { runtimeFields },
} = useAppContext();

const onSaveRuntimeField = useCallback((field: RuntimeField) => {
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');
}, []);
Expand Down Expand Up @@ -117,6 +135,11 @@ export const IndexManagementHome: React.FunctionComponent<RouteComponentProps<Ma
/>
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButton onClick={openRuntimeFieldEditor} fill>
Create field
</EuiButton>
</EuiFlexItem>
</EuiFlexGroup>
</EuiTitle>

Expand Down
13 changes: 11 additions & 2 deletions x-pack/plugins/index_management/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -30,6 +31,7 @@ interface PluginsDependencies {
ingestManager?: IngestManagerSetup;
usageCollection: UsageCollectionSetup;
management: ManagementSetup;
runtimeFields: RuntimeFieldsSetup;
}

export class IndexMgmtUIPlugin {
Expand All @@ -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);
Expand All @@ -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
);
},
});

Expand Down

0 comments on commit f2779f4

Please sign in to comment.