Skip to content

Commit

Permalink
initial plugin setup
Browse files Browse the repository at this point in the history
  • Loading branch information
alisonelizabeth committed Apr 3, 2020
1 parent 71ff45a commit c19382d
Show file tree
Hide file tree
Showing 34 changed files with 772 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@
/x-pack/plugins/snapshot_restore/ @elastic/es-ui
/x-pack/plugins/upgrade_assistant/ @elastic/es-ui
/x-pack/plugins/watcher/ @elastic/es-ui
/x-pack/plugins/ingest_pipelines/ @elastic/es-ui

# Endpoint
/x-pack/plugins/endpoint/ @elastic/endpoint-app-team
Expand Down
1 change: 1 addition & 0 deletions x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"xpack.indexLifecycleMgmt": "legacy/plugins/index_lifecycle_management",
"xpack.infra": "plugins/infra",
"xpack.ingestManager": "plugins/ingest_manager",
"xpack.ingestPipelines": "plugins/ingest_pipelines",
"xpack.lens": "legacy/plugins/lens",
"xpack.licenseMgmt": "plugins/license_management",
"xpack.licensing": "plugins/licensing",
Expand Down
9 changes: 9 additions & 0 deletions x-pack/plugins/ingest_pipelines/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# ingest_pipelines

> Ingest node pipelines UI
---

## Development

See the [kibana contributing guide](https://github.com/elastic/kibana/blob/master/CONTRIBUTING.md) for instructions setting up your development environment.
16 changes: 16 additions & 0 deletions x-pack/plugins/ingest_pipelines/common/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { LicenseType } from '../../licensing/common/types';

const basicLicense: LicenseType = 'basic';

export const PLUGIN_ID = 'ingest_pipelines';

export const PLUGIN_MIN_LICENSE_TYPE = basicLicense;

export const BASE_PATH = '/management/elasticsearch/ingest_pipelines';

export const API_BASE_PATH = '/api/ingest_pipelines';
7 changes: 7 additions & 0 deletions x-pack/plugins/ingest_pipelines/common/lib/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { deserializePipelines } from './pipeline_serialization';
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { deserializePipelines } from './pipeline_serialization';

describe('pipeline_serialization', () => {
describe('deserializePipelines()', () => {
it('should deserialize pipelines', () => {
expect(
deserializePipelines({
pipeline1: {
description: 'pipeline 1 description',
version: 1,
processors: [
{
script: {
source: 'ctx._type = null',
},
},
],
},
pipeline2: {
description: 'pipeline2 description',
version: 1,
processors: [],
},
})
).toEqual([
{
name: 'pipeline1',
description: 'pipeline 1 description',
version: 1,
processors: [
{
script: {
source: 'ctx._type = null',
},
},
],
},
{
name: 'pipeline2',
description: 'pipeline2 description',
version: 1,
processors: [],
},
]);
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { PipelinesByName, Pipeline } from '../types';

export function deserializePipelines(pipelinesByName: PipelinesByName): Pipeline[] {
const pipelineNames: string[] = Object.keys(pipelinesByName);

const deserializedTemplates = pipelineNames.map((name: string) => {
const { description, version, processors } = pipelinesByName[name];

return {
name,
description,
version,
processors,
};
});

return deserializedTemplates;
}
22 changes: 22 additions & 0 deletions x-pack/plugins/ingest_pipelines/common/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

interface Processor {
[key: string]: {
[key: string]: unknown;
};
}

export interface Pipeline {
name: string;
description: string;
version?: number;
processors: Processor[];
}

export interface PipelinesByName {
[key: string]: Omit<Pipeline, 'name'>;
}
17 changes: 17 additions & 0 deletions x-pack/plugins/ingest_pipelines/kibana.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"id": "ingestPipelines",
"version": "8.0.0",
"server": true,
"ui": true,
"requiredPlugins": [
"licensing",
"management"
],
"optionalPlugins": [
"usageCollection"
],
"configPath": [
"xpack",
"ingest_pipelines"
]
}
24 changes: 24 additions & 0 deletions x-pack/plugins/ingest_pipelines/public/application/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { HashRouter, Switch, Route } from 'react-router-dom';
import { BASE_PATH } from '../../common';
import { PipelinesList } from './sections';

export const App = () => {
return (
<HashRouter>
<AppWithoutRouter />
</HashRouter>
);
};

export const AppWithoutRouter = () => (
<Switch>
<Route exact path={BASE_PATH} component={PipelinesList} />
</Switch>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

// UI metric constants
export const UIM_APP_NAME = 'ingest_pipelines';
export const UIM_PIPELINES_LIST_LOAD = 'pipelines_list_load';
39 changes: 39 additions & 0 deletions x-pack/plugins/ingest_pipelines/public/application/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React, { ReactNode } from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { ChromeBreadcrumb } from 'src/core/public';
import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public';

import { App } from './app';
import { DocumentationService, UiMetricService, ApiService } from './services';

export interface AppServices {
setBreadcrumbs: (crumbs: ChromeBreadcrumb[]) => void;
metric: UiMetricService;
documentation: DocumentationService;
api: ApiService;
}

export const renderApp = (
element: HTMLElement,
I18nContext: ({ children }: { children: ReactNode }) => JSX.Element,
services: AppServices
) => {
render(
<I18nContext>
<KibanaContextProvider services={services}>
<App />
</KibanaContextProvider>
</I18nContext>,
element
);

return () => {
unmountComponentAtNode(element);
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { PipelinesList } from './pipelines_list';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { PipelinesList } from './pipelines_list';
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React, { useEffect } from 'react';

import {
EuiPageBody,
EuiPageContent,
EuiTitle,
EuiFlexGroup,
EuiFlexItem,
EuiButtonEmpty,
} from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiSpacer, EuiText } from '@elastic/eui';

import { useKibana } from '../../../../../../../src/plugins/kibana_react/public';

import { UIM_PIPELINES_LIST_LOAD } from '../../constants';

export const PipelinesList: React.FunctionComponent = () => {
const { services } = useKibana();

// Track component loaded
useEffect(() => {
services.metric.trackUiMetric(UIM_PIPELINES_LIST_LOAD);
}, [services.metric]);

return (
<EuiPageBody>
<EuiPageContent>
<EuiTitle size="l">
<EuiFlexGroup alignItems="center">
<EuiFlexItem>
<h1>
<FormattedMessage
id="xpack.ingestPipelines.pipelinesListTitle"
defaultMessage="Ingest Pipelines"
/>
</h1>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
href={services.documentation.getIngestNodeUrl()}
target="_blank"
iconType="help"
>
<FormattedMessage
id="xpack.ingestPipelines.pipelinesListDocsLinkText"
defaultMessage="Ingest Pipelines docs"
/>
</EuiButtonEmpty>
</EuiFlexItem>
</EuiFlexGroup>
</EuiTitle>

<EuiSpacer size="s" />

<EuiTitle size="s">
<EuiText color="subdued">
<FormattedMessage
id="xpack.ingestPipelines.pipelinesListDescription"
defaultMessage="Use ingest node pipelines to pre-process documents before indexing."
/>
</EuiText>
</EuiTitle>
</EuiPageContent>
</EuiPageBody>
);
};
37 changes: 37 additions & 0 deletions x-pack/plugins/ingest_pipelines/public/application/services/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { HttpSetup } from 'src/core/public';

import { API_BASE_PATH } from '../../../common/constants';
import {
UseRequestConfig,
sendRequest as _sendRequest,
useRequest as _useRequest,
} from '../../shared_imports';

export class ApiService {
private client: HttpSetup | undefined;

private useRequest(config: UseRequestConfig) {
if (!this.client) {
throw new Error('Api service has not be initialized.');
}
return _useRequest(this.client, config);
}

public setup(httpClient: HttpSetup): void {
this.client = httpClient;
}

public useLoadPipelines() {
return this.useRequest({
path: API_BASE_PATH,
method: 'get',
});
}
}

export const apiService = new ApiService();
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { DocLinksStart } from 'src/core/public';

export class DocumentationService {
private esDocBasePath: string = '';

public setup(docLinks: DocLinksStart): void {
const { DOC_LINK_VERSION, ELASTIC_WEBSITE_URL } = docLinks;
const docsBase = `${ELASTIC_WEBSITE_URL}guide/en`;

this.esDocBasePath = `${docsBase}/elasticsearch/reference/${DOC_LINK_VERSION}`;
}

public getIngestNodeUrl() {
return `${this.esDocBasePath}/ingest.html`;
}
}

export const documentationService = new DocumentationService();
Loading

0 comments on commit c19382d

Please sign in to comment.