From e300f90ea706694fc7b9b52764d37ea90078790e Mon Sep 17 00:00:00 2001 From: Candace Park Date: Mon, 18 May 2020 16:38:25 -0400 Subject: [PATCH 01/18] endpoint advanced config. changed message --- .../step_configure_datasource.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx index 118c7e30f13f4..fef72f311c277 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx @@ -72,10 +72,17 @@ export const StepConfigureDatasource: React.FunctionComponent<{ body={

- + {datasource.package?.name === 'endpoint' ? ( + + ) : ( + + )}

} From 11c383718b25f6dd95953e944acd15275d0b3b37 Mon Sep 17 00:00:00 2001 From: Candace Park Date: Wed, 20 May 2020 15:29:04 -0400 Subject: [PATCH 02/18] add edit mode --- .../ingest_manager_endpoint_configuration.tsx | 12 ++++++++ .../step_configure_datasource.tsx | 28 +++++++++++-------- .../edit_datasource_page/index.tsx | 1 + 3 files changed, 29 insertions(+), 12 deletions(-) create mode 100644 x-pack/plugins/endpoint/public/ingest_manager_endpoint_configuration.tsx diff --git a/x-pack/plugins/endpoint/public/ingest_manager_endpoint_configuration.tsx b/x-pack/plugins/endpoint/public/ingest_manager_endpoint_configuration.tsx new file mode 100644 index 0000000000000..5f1943f4ccb4d --- /dev/null +++ b/x-pack/plugins/endpoint/public/ingest_manager_endpoint_configuration.tsx @@ -0,0 +1,12 @@ +/* + * 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, { memo } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; + +export const IngestManagerEndpointConfiguration = memo(() => { + return

hallo

; +}); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx index fef72f311c277..1c85e93dd0c99 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx @@ -19,6 +19,7 @@ import { PackageInfo, NewDatasource, DatasourceInput } from '../../../types'; import { Loading } from '../../../components'; import { DatasourceValidationResults, validationHasErrors } from './services'; import { DatasourceInputPanel } from './components'; +import { IngestManagerEndpointConfiguration } from '../../../../../../../endpoint/public/common/ingest_manager_endpoint_configuration'; export const StepConfigureDatasource: React.FunctionComponent<{ packageInfo: PackageInfo; @@ -26,7 +27,15 @@ export const StepConfigureDatasource: React.FunctionComponent<{ updateDatasource: (fields: Partial) => void; validationResults: DatasourceValidationResults; submitAttempted: boolean; -}> = ({ packageInfo, datasource, updateDatasource, validationResults, submitAttempted }) => { + editMode: boolean; +}> = ({ + packageInfo, + datasource, + updateDatasource, + validationResults, + submitAttempted, + editMode = false, +}) => { const hasErrors = validationResults ? validationHasErrors(validationResults) : false; // Configure inputs (and their streams) @@ -72,17 +81,11 @@ export const StepConfigureDatasource: React.FunctionComponent<{ body={

- {datasource.package?.name === 'endpoint' ? ( - - ) : ( - - )} + +

} @@ -106,6 +109,7 @@ export const StepConfigureDatasource: React.FunctionComponent<{ color="danger" >

+ { updateDatasource={updateDatasource} validationResults={validationResults!} submitAttempted={formState === 'INVALID'} + editMode={true} /> ), }, From 0cf3ae931ce735b9d6db6f3dfe4e4d0c66d0bfde Mon Sep 17 00:00:00 2001 From: Candace Park Date: Wed, 20 May 2020 23:05:17 -0400 Subject: [PATCH 03/18] no more endpoint --- .../components/endpoint_configuration.tsx} | 13 +++++++++---- .../step_configure_datasource.tsx | 16 +++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) rename x-pack/plugins/{endpoint/public/ingest_manager_endpoint_configuration.tsx => ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx} (51%) diff --git a/x-pack/plugins/endpoint/public/ingest_manager_endpoint_configuration.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx similarity index 51% rename from x-pack/plugins/endpoint/public/ingest_manager_endpoint_configuration.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx index 5f1943f4ccb4d..6772493d56657 100644 --- a/x-pack/plugins/endpoint/public/ingest_manager_endpoint_configuration.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx @@ -4,9 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { memo } from 'react'; +import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -export const IngestManagerEndpointConfiguration = memo(() => { - return

hallo

; -}); +export const EndpointConfiguration = () => { + return ( + + ); +}; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx index 1c85e93dd0c99..97ea5877739ca 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx @@ -19,7 +19,7 @@ import { PackageInfo, NewDatasource, DatasourceInput } from '../../../types'; import { Loading } from '../../../components'; import { DatasourceValidationResults, validationHasErrors } from './services'; import { DatasourceInputPanel } from './components'; -import { IngestManagerEndpointConfiguration } from '../../../../../../../endpoint/public/common/ingest_manager_endpoint_configuration'; +import { EndpointConfiguration } from './components/endpoint_configuration'; export const StepConfigureDatasource: React.FunctionComponent<{ packageInfo: PackageInfo; @@ -81,11 +81,14 @@ export const StepConfigureDatasource: React.FunctionComponent<{ body={

- - + {datasource.package?.name === 'endpoint' ? ( + + ) : ( + + )}

} @@ -109,7 +112,6 @@ export const StepConfigureDatasource: React.FunctionComponent<{ color="danger" >

- Date: Thu, 21 May 2020 18:17:19 -0400 Subject: [PATCH 04/18] wow it werks but after going down the wrong path --- .../components/endpoint_configuration.tsx | 31 ++++++++++++++----- .../step_configure_datasource.tsx | 2 +- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx index 6772493d56657..4c286a493b53d 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx @@ -4,14 +4,31 @@ * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; +import React, { memo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; +import { useLocation } from 'react-router-dom'; +import { EuiLink } from '@elastic/eui'; -export const EndpointConfiguration = () => { +export const EndpointConfiguration = memo<{ editMode: boolean }>(({ editMode }) => { + const pathname = useLocation().pathname.split('/'); + const policyId = pathname[pathname.length - 1]; + const linky = `/app/siem#/policy/${policyId}`; return ( - + <> + {editMode === true ? ( + <> + + Click me to configure + + ) : ( + + )} + ); -}; +}); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx index 97ea5877739ca..83bc77d11e348 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx @@ -82,7 +82,7 @@ export const StepConfigureDatasource: React.FunctionComponent<{

{datasource.package?.name === 'endpoint' ? ( - + ) : ( Date: Thu, 21 May 2020 18:26:55 -0400 Subject: [PATCH 05/18] fix type script error --- .../create_datasource_page/step_configure_datasource.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx index 83bc77d11e348..d3877d8d4fd0d 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx @@ -27,7 +27,7 @@ export const StepConfigureDatasource: React.FunctionComponent<{ updateDatasource: (fields: Partial) => void; validationResults: DatasourceValidationResults; submitAttempted: boolean; - editMode: boolean; + editMode?: boolean; }> = ({ packageInfo, datasource, From 4ccc118840820569a385b7fca8458916180db34c Mon Sep 17 00:00:00 2001 From: Candace Park Date: Tue, 26 May 2020 11:48:43 -0400 Subject: [PATCH 06/18] rename linky --- .../components/endpoint_configuration.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx index 4c286a493b53d..1ba23e615b1d4 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx @@ -12,7 +12,7 @@ import { EuiLink } from '@elastic/eui'; export const EndpointConfiguration = memo<{ editMode: boolean }>(({ editMode }) => { const pathname = useLocation().pathname.split('/'); const policyId = pathname[pathname.length - 1]; - const linky = `/app/siem#/policy/${policyId}`; + const linkToSiemApp = `/app/siem#/policy/${policyId}`; return ( <> {editMode === true ? ( @@ -21,7 +21,7 @@ export const EndpointConfiguration = memo<{ editMode: boolean }>(({ editMode }) id="xpack.ingestManager.editDatasource.stepConfigure.endpointConfiguration" defaultMessage="See security app policy tab for additional configuration options: " /> - Click me to configure + Click me to configure ) : ( Date: Tue, 26 May 2020 17:21:07 -0400 Subject: [PATCH 07/18] use navigatetoapp, no refresh --- .../components/endpoint_configuration.tsx | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx index 1ba23e615b1d4..abeb960406c78 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx @@ -8,11 +8,20 @@ import React, { memo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { useLocation } from 'react-router-dom'; import { EuiLink } from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import { useCore } from './../../../../hooks/use_core'; export const EndpointConfiguration = memo<{ editMode: boolean }>(({ editMode }) => { + const { application } = useCore(); const pathname = useLocation().pathname.split('/'); const policyId = pathname[pathname.length - 1]; - const linkToSiemApp = `/app/siem#/policy/${policyId}`; + const appId = 'siem'; + const appPath = `#/policy/${policyId}`; + const linkToSiemApp = (event: React.MouseEvent) => { + event.preventDefault(); + application.navigateToApp(appId, { path: appPath }); + }; + return ( <> {editMode === true ? ( @@ -21,7 +30,16 @@ export const EndpointConfiguration = memo<{ editMode: boolean }>(({ editMode }) id="xpack.ingestManager.editDatasource.stepConfigure.endpointConfiguration" defaultMessage="See security app policy tab for additional configuration options: " /> - Click me to configure + ) => + linkToSiemApp(ev) + } + > + {i18n.translate( + 'xpack.ingestManager.editDatasource.stepConfigure.endpointConfigurationLink', + { defaultMessage: 'Click me to configure' } + )} + ) : ( Date: Wed, 27 May 2020 13:45:06 -0400 Subject: [PATCH 08/18] fixed wording --- .../components/endpoint_configuration.tsx | 28 ++++++++----------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx index abeb960406c78..e35341c0743cc 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx @@ -25,26 +25,20 @@ export const EndpointConfiguration = memo<{ editMode: boolean }>(({ editMode }) return ( <> {editMode === true ? ( - <> - - ) => - linkToSiemApp(ev) - } - > - {i18n.translate( - 'xpack.ingestManager.editDatasource.stepConfigure.endpointConfigurationLink', - { defaultMessage: 'Click me to configure' } - )} - - + ) => + linkToSiemApp(ev) + } + > + {i18n.translate( + 'xpack.ingestManager.editDatasource.stepConfigure.endpointConfigurationLink', + { defaultMessage: 'View and configure Security Policy' } + )} + ) : ( )} From f9852afa2037ff0c1b3ef711ae076ca4bc9cdad4 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 27 May 2020 17:29:55 -0700 Subject: [PATCH 09/18] POC for custom configure data source panel from outside plugin --- .../custom_configure_datasource.tsx | 46 +++++++++++++++++++ .../components/index.ts | 1 + .../step_configure_datasource.tsx | 36 ++++----------- .../edit_datasource_page/index.tsx | 1 + x-pack/plugins/ingest_manager/public/index.ts | 2 + .../configure_datasource.tsx | 19 ++++++++ .../view/ingest_manager_integration/index.tsx | 7 +++ x-pack/plugins/siem/public/index.ts | 2 + 8 files changed, 87 insertions(+), 27 deletions(-) create mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx create mode 100644 x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/configure_datasource.tsx create mode 100644 x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/index.tsx diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx new file mode 100644 index 0000000000000..5a60b98d569f8 --- /dev/null +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx @@ -0,0 +1,46 @@ +/* + * 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 { FormattedMessage } from '@kbn/i18n/react'; +import { EuiEmptyPrompt, EuiText } from '@elastic/eui'; +import { ConfigureEndpointDatasource } from '../../../../../../../../siem/public'; +import { NewDatasource } from '../../../../types'; +import { CreateDatasourceFrom } from '../types'; + +export interface CustomConfigureDatasourceProps { + packageName: string; + from: CreateDatasourceFrom; + datasource: NewDatasource; +} + +export type CustomConfigureDatasourceContent = React.FC; + +const ConfigureDatasourceMapping: { [key: string]: CustomConfigureDatasourceContent } = { + endpoint: ConfigureEndpointDatasource, +}; + +const EmptyConfigureDatasource: CustomConfigureDatasourceContent = () => ( + +

+ +

+ + } + /> +); + +export const CustomConfigureDatasource = (props: CustomConfigureDatasourceProps) => { + const ConfigureDatasourceContent = + ConfigureDatasourceMapping[props.packageName] || EmptyConfigureDatasource; + return ; +}; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/index.ts index 3bfca75668911..42848cc0f5e41 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/index.ts @@ -6,3 +6,4 @@ export { CreateDatasourcePageLayout } from './layout'; export { DatasourceInputPanel } from './datasource_input_panel'; export { DatasourceInputVarField } from './datasource_input_var_field'; +export { CustomConfigureDatasource } from './custom_configure_datasource'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx index 6fe75c0e548be..c230ff1e9cc0a 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx @@ -5,23 +5,17 @@ */ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; -import { - EuiPanel, - EuiFlexGroup, - EuiFlexItem, - EuiSpacer, - EuiEmptyPrompt, - EuiText, - EuiCallOut, -} from '@elastic/eui'; +import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiCallOut } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { PackageInfo, NewDatasource, DatasourceInput } from '../../../types'; import { Loading } from '../../../components'; import { DatasourceValidationResults, validationHasErrors } from './services'; -import { DatasourceInputPanel } from './components'; import { EndpointConfiguration } from './components/endpoint_configuration'; +import { DatasourceInputPanel, CustomConfigureDatasource } from './components'; +import { CreateDatasourceFrom } from './types'; export const StepConfigureDatasource: React.FunctionComponent<{ + from: CreateDatasourceFrom; packageInfo: PackageInfo; datasource: NewDatasource; updateDatasource: (fields: Partial) => void; @@ -29,6 +23,7 @@ export const StepConfigureDatasource: React.FunctionComponent<{ submitAttempted: boolean; editMode?: boolean; }> = ({ + from, packageInfo, datasource, updateDatasource, @@ -77,23 +72,10 @@ export const StepConfigureDatasource: React.FunctionComponent<{ ) : ( - -

- {datasource.package?.name === 'endpoint' ? ( - - ) : ( - - )} -

- - } +
); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx index b4bdd1662c382..d83c70b225f52 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx @@ -299,6 +299,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { ), children: ( { return new IngestManagerPlugin(initializerContext); }; + +export { CustomConfigureDatasourceContent } from './applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource'; diff --git a/x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/configure_datasource.tsx b/x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/configure_datasource.tsx new file mode 100644 index 0000000000000..f1ff4bf35b011 --- /dev/null +++ b/x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/configure_datasource.tsx @@ -0,0 +1,19 @@ +/* + * 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 { CustomConfigureDatasourceContent } from '../../../../../ingest_manager/public'; + +export const ConfigureEndpointDatasource: CustomConfigureDatasourceContent = ({ + datasource, + from, +}) => { + return ( +
{`Custom endpoint rendering for ${datasource.name} ${ + from === 'edit' ? '(editing)' : '(creating)' + }`}
+ ); +}; diff --git a/x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/index.tsx b/x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/index.tsx new file mode 100644 index 0000000000000..0a048868d341f --- /dev/null +++ b/x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/index.tsx @@ -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 { ConfigureEndpointDatasource } from './configure_datasource'; diff --git a/x-pack/plugins/siem/public/index.ts b/x-pack/plugins/siem/public/index.ts index 36344a25e1568..c241f7077709a 100644 --- a/x-pack/plugins/siem/public/index.ts +++ b/x-pack/plugins/siem/public/index.ts @@ -11,3 +11,5 @@ import { PluginSetup, PluginStart } from './types'; export const plugin = (context: PluginInitializerContext): Plugin => new Plugin(context); export { Plugin, PluginSetup, PluginStart }; + +export { ConfigureEndpointDatasource } from './endpoint_policy/view/ingest_manager_integration'; From ad71c886420cf67d931662cfd53792765b6e8513 Mon Sep 17 00:00:00 2001 From: Candace Park Date: Fri, 29 May 2020 13:23:27 -0400 Subject: [PATCH 10/18] added security text --- .../step_configure_datasource.tsx | 14 +---- .../edit_datasource_page/index.tsx | 1 - .../configure_datasource.tsx | 53 +++++++++++++++---- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx index c230ff1e9cc0a..ea083c1f48542 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx @@ -10,27 +10,17 @@ import { i18n } from '@kbn/i18n'; import { PackageInfo, NewDatasource, DatasourceInput } from '../../../types'; import { Loading } from '../../../components'; import { DatasourceValidationResults, validationHasErrors } from './services'; -import { EndpointConfiguration } from './components/endpoint_configuration'; import { DatasourceInputPanel, CustomConfigureDatasource } from './components'; import { CreateDatasourceFrom } from './types'; export const StepConfigureDatasource: React.FunctionComponent<{ - from: CreateDatasourceFrom; + from?: CreateDatasourceFrom; packageInfo: PackageInfo; datasource: NewDatasource; updateDatasource: (fields: Partial) => void; validationResults: DatasourceValidationResults; submitAttempted: boolean; - editMode?: boolean; -}> = ({ - from, - packageInfo, - datasource, - updateDatasource, - validationResults, - submitAttempted, - editMode = false, -}) => { +}> = ({ from, packageInfo, datasource, updateDatasource, validationResults, submitAttempted }) => { const hasErrors = validationResults ? validationHasErrors(validationResults) : false; // Configure inputs (and their streams) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx index d83c70b225f52..06492ff0b251b 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx @@ -305,7 +305,6 @@ export const EditDatasourcePage: React.FunctionComponent = () => { updateDatasource={updateDatasource} validationResults={validationResults!} submitAttempted={formState === 'INVALID'} - editMode={true} /> ), }, diff --git a/x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/configure_datasource.tsx b/x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/configure_datasource.tsx index f1ff4bf35b011..d3da7540c90bb 100644 --- a/x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/configure_datasource.tsx +++ b/x-pack/plugins/siem/public/endpoint_policy/view/ingest_manager_integration/configure_datasource.tsx @@ -4,16 +4,47 @@ * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; +import React, { memo } from 'react'; +import { useLocation } from 'react-router-dom'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { EuiEmptyPrompt, EuiText } from '@elastic/eui'; import { CustomConfigureDatasourceContent } from '../../../../../ingest_manager/public'; +import { LinkToApp } from '../../../common/components/endpoint/link_to_app'; +import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; -export const ConfigureEndpointDatasource: CustomConfigureDatasourceContent = ({ - datasource, - from, -}) => { - return ( -
{`Custom endpoint rendering for ${datasource.name} ${ - from === 'edit' ? '(editing)' : '(creating)' - }`}
- ); -}; +export const ConfigureEndpointDatasource = memo( + ({ from }: { from: string }) => { + const pathname = useLocation().pathname.split('/'); + const policyId = pathname[pathname.length - 1]; + + return ( + +

+ {from === 'edit' ? ( + + + + ) : ( + + )} +

+ + } + /> + ); + } +); + +ConfigureEndpointDatasource.displayName = 'ConfigureEndpointDatasource'; From 8586e3b6dc292b6a4a9dace40d5726e41347a284 Mon Sep 17 00:00:00 2001 From: Candace Park Date: Fri, 29 May 2020 16:48:39 -0400 Subject: [PATCH 11/18] it werks --- .../ingest_manager/hooks/use_core.ts | 16 +++++++--------- .../public/applications/ingest_manager/index.tsx | 7 ++++--- .../step_configure_datasource.tsx | 9 ++++++++- x-pack/plugins/siem/public/index.ts | 2 +- .../configure_datasource.tsx | 13 ++++++++----- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_core.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_core.ts index f4e9a032b925a..9ce1e95aa91d5 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_core.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_core.ts @@ -4,15 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ -import React, { useContext } from 'react'; -import { CoreStart } from 'src/core/public'; +import { CoreStart } from 'kibana/public'; +import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; -export const CoreContext = React.createContext(null); - -export function useCore() { - const core = useContext(CoreContext); - if (core === null) { - throw new Error('CoreContext not initialized'); +export function useCore(): CoreStart { + const { services } = useKibana(); + if (services === null) { + throw new Error('KibanaContextProvider not initialized'); } - return core; + return services; } diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/index.tsx index f6a386314272f..ed5a75ce6c991 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/index.tsx @@ -22,11 +22,12 @@ import { PAGE_ROUTING_PATHS } from './constants'; import { DefaultLayout, WithoutHeaderLayout } from './layouts'; import { Loading, Error } from './components'; import { IngestManagerOverview, EPMApp, AgentConfigApp, FleetApp, DataStreamApp } from './sections'; -import { CoreContext, DepsContext, ConfigContext, setHttpClient, useConfig } from './hooks'; +import { DepsContext, ConfigContext, setHttpClient, useConfig } from './hooks'; import { PackageInstallProvider } from './sections/epm/hooks'; import { useCore, sendSetup, sendGetPermissionsCheck } from './hooks'; import { FleetStatusProvider } from './hooks/use_fleet_status'; import './index.scss'; +import { KibanaContextProvider } from '../../../../../../src/plugins/kibana_react/public'; export interface ProtectedRouteProps extends RouteProps { isAllowed?: boolean; @@ -229,7 +230,7 @@ const IngestManagerApp = ({ const isDarkMode = useObservable(coreStart.uiSettings.get$('theme:darkMode')); return ( - + @@ -237,7 +238,7 @@ const IngestManagerApp = ({ - + ); }; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx index ea083c1f48542..da069b3db46ff 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx @@ -20,7 +20,14 @@ export const StepConfigureDatasource: React.FunctionComponent<{ updateDatasource: (fields: Partial) => void; validationResults: DatasourceValidationResults; submitAttempted: boolean; -}> = ({ from, packageInfo, datasource, updateDatasource, validationResults, submitAttempted }) => { +}> = ({ + from = 'config', + packageInfo, + datasource, + updateDatasource, + validationResults, + submitAttempted, +}) => { const hasErrors = validationResults ? validationHasErrors(validationResults) : false; // Configure inputs (and their streams) diff --git a/x-pack/plugins/siem/public/index.ts b/x-pack/plugins/siem/public/index.ts index c241f7077709a..509076b239f36 100644 --- a/x-pack/plugins/siem/public/index.ts +++ b/x-pack/plugins/siem/public/index.ts @@ -12,4 +12,4 @@ export const plugin = (context: PluginInitializerContext): Plugin => new Plugin( export { Plugin, PluginSetup, PluginStart }; -export { ConfigureEndpointDatasource } from './endpoint_policy/view/ingest_manager_integration'; +export { ConfigureEndpointDatasource } from './management/pages/policy/view/ingest_manager_integration'; diff --git a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx index d3da7540c90bb..2c5bc4594e27d 100644 --- a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx +++ b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx @@ -8,14 +8,17 @@ import React, { memo } from 'react'; import { useLocation } from 'react-router-dom'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiEmptyPrompt, EuiText } from '@elastic/eui'; -import { CustomConfigureDatasourceContent } from '../../../../../ingest_manager/public'; -import { LinkToApp } from '../../../common/components/endpoint/link_to_app'; -import { useKibana } from '../../../../../../../src/plugins/kibana_react/public'; +import { useKibana } from '../../../../../../../../../src/plugins/kibana_react/public'; +import { LinkToApp } from '../../../../../common/components/endpoint/link_to_app'; +import { CustomConfigureDatasourceContent } from '../../../../../../../ingest_manager/public'; +import { getManagementUrl } from '../../../..'; export const ConfigureEndpointDatasource = memo( ({ from }: { from: string }) => { + const { services } = useKibana(); const pathname = useLocation().pathname.split('/'); const policyId = pathname[pathname.length - 1]; + const policyUrl = getManagementUrl({ name: 'policyDetails', policyId }); return ( Date: Mon, 1 Jun 2020 11:46:25 -0400 Subject: [PATCH 12/18] removed redundant import, type error --- .../public/applications/ingest_manager/hooks/index.ts | 2 +- x-pack/plugins/siem/public/index.ts | 2 +- .../pages/policy/view/ingest_manager_integration/index.tsx | 7 ------- 3 files changed, 2 insertions(+), 9 deletions(-) delete mode 100644 x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/index.tsx diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/index.ts index a752ad2a8912b..a8247d1d36ed9 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/index.ts @@ -5,7 +5,7 @@ */ export { useCapabilities } from './use_capabilities'; -export { useCore, CoreContext } from './use_core'; +export { useCore } from './use_core'; export { useConfig, ConfigContext } from './use_config'; export { useSetupDeps, useStartDeps, DepsContext } from './use_deps'; export { useBreadcrumbs } from './use_breadcrumbs'; diff --git a/x-pack/plugins/siem/public/index.ts b/x-pack/plugins/siem/public/index.ts index 509076b239f36..9e31ba8d771f7 100644 --- a/x-pack/plugins/siem/public/index.ts +++ b/x-pack/plugins/siem/public/index.ts @@ -12,4 +12,4 @@ export const plugin = (context: PluginInitializerContext): Plugin => new Plugin( export { Plugin, PluginSetup, PluginStart }; -export { ConfigureEndpointDatasource } from './management/pages/policy/view/ingest_manager_integration'; +export { ConfigureEndpointDatasource } from './management/pages/policy/view/ingest_manager_integration/configure_datasource'; diff --git a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/index.tsx b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/index.tsx deleted file mode 100644 index 0a048868d341f..0000000000000 --- a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/index.tsx +++ /dev/null @@ -1,7 +0,0 @@ -/* - * 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 { ConfigureEndpointDatasource } from './configure_datasource'; From 04dee90c599fe8c1cf190ccaf0117719cedca4ee Mon Sep 17 00:00:00 2001 From: Candace Park Date: Mon, 1 Jun 2020 13:33:40 -0400 Subject: [PATCH 13/18] i18n fix --- .../view/ingest_manager_integration/configure_datasource.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx index 2c5bc4594e27d..ac229a350c22c 100644 --- a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx +++ b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx @@ -32,13 +32,13 @@ export const ConfigureEndpointDatasource = memo ) : ( )} From 2208beb2b286a0110fb5957f0b99995d54d7ba21 Mon Sep 17 00:00:00 2001 From: Candace Park Date: Mon, 1 Jun 2020 14:06:40 -0400 Subject: [PATCH 14/18] remove unused file --- .../components/endpoint_configuration.tsx | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx deleted file mode 100644 index e35341c0743cc..0000000000000 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/endpoint_configuration.tsx +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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, { memo } from 'react'; -import { FormattedMessage } from '@kbn/i18n/react'; -import { useLocation } from 'react-router-dom'; -import { EuiLink } from '@elastic/eui'; -import { i18n } from '@kbn/i18n'; -import { useCore } from './../../../../hooks/use_core'; - -export const EndpointConfiguration = memo<{ editMode: boolean }>(({ editMode }) => { - const { application } = useCore(); - const pathname = useLocation().pathname.split('/'); - const policyId = pathname[pathname.length - 1]; - const appId = 'siem'; - const appPath = `#/policy/${policyId}`; - const linkToSiemApp = (event: React.MouseEvent) => { - event.preventDefault(); - application.navigateToApp(appId, { path: appPath }); - }; - - return ( - <> - {editMode === true ? ( - ) => - linkToSiemApp(ev) - } - > - {i18n.translate( - 'xpack.ingestManager.editDatasource.stepConfigure.endpointConfigurationLink', - { defaultMessage: 'View and configure Security Policy' } - )} - - ) : ( - - )} - - ); -}); From b43801ee5d8935fadfddd1f7e70c75e457aa39fb Mon Sep 17 00:00:00 2001 From: Candace Park Date: Tue, 2 Jun 2020 11:48:23 -0400 Subject: [PATCH 15/18] grab policyId from datasource --- .../custom_configure_datasource.tsx | 2 +- .../step_configure_datasource.tsx | 2 +- .../edit_datasource_page/index.tsx | 4 ++-- x-pack/plugins/ingest_manager/public/index.ts | 9 +++++++++ x-pack/plugins/siem/public/index.ts | 4 ++++ .../configure_datasource.tsx | 20 +++++++++++++------ 6 files changed, 31 insertions(+), 10 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx index 5a60b98d569f8..a029b67759a23 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx @@ -13,7 +13,7 @@ import { CreateDatasourceFrom } from '../types'; export interface CustomConfigureDatasourceProps { packageName: string; from: CreateDatasourceFrom; - datasource: NewDatasource; + datasource: NewDatasource | (NewDatasource & { id: string }); } export type CustomConfigureDatasourceContent = React.FC; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx index da069b3db46ff..d9cf0fbfb7987 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx @@ -16,7 +16,7 @@ import { CreateDatasourceFrom } from './types'; export const StepConfigureDatasource: React.FunctionComponent<{ from?: CreateDatasourceFrom; packageInfo: PackageInfo; - datasource: NewDatasource; + datasource: NewDatasource | (NewDatasource & { id: string }); updateDatasource: (fields: Partial) => void; validationResults: DatasourceValidationResults; submitAttempted: boolean; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx index 06492ff0b251b..4bb42faedf7f6 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx @@ -69,7 +69,8 @@ export const EditDatasourcePage: React.FunctionComponent = () => { const [loadingError, setLoadingError] = useState(); const [agentConfig, setAgentConfig] = useState(); const [packageInfo, setPackageInfo] = useState(); - const [datasource, setDatasource] = useState({ + const [datasource, setDatasource] = useState({ + id: '', name: '', description: '', config_id: '', @@ -93,7 +94,6 @@ export const EditDatasourcePage: React.FunctionComponent = () => { } if (datasourceData?.item) { const { - id, revision, inputs, created_by, diff --git a/x-pack/plugins/ingest_manager/public/index.ts b/x-pack/plugins/ingest_manager/public/index.ts index c3be2ed09ce14..4b7461366d4a6 100644 --- a/x-pack/plugins/ingest_manager/public/index.ts +++ b/x-pack/plugins/ingest_manager/public/index.ts @@ -12,4 +12,13 @@ export const plugin = (initializerContext: PluginInitializerContext) => { return new IngestManagerPlugin(initializerContext); }; +/** + * Allows external plugins to create custom content for the Ingest + * Datasource configuration. + */ export { CustomConfigureDatasourceContent } from './applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource'; + +/** + * Type of `datasource` prop in CustomConfigureDatasourceContent + */ +export { NewDatasource } from './applications/ingest_manager/types'; diff --git a/x-pack/plugins/siem/public/index.ts b/x-pack/plugins/siem/public/index.ts index 9e31ba8d771f7..718791938b5ee 100644 --- a/x-pack/plugins/siem/public/index.ts +++ b/x-pack/plugins/siem/public/index.ts @@ -12,4 +12,8 @@ export const plugin = (context: PluginInitializerContext): Plugin => new Plugin( export { Plugin, PluginSetup, PluginStart }; +/** + * Exports Endpoint-specific datasource configuration instructions + * for use in the Ingest app create / edit datasource config + */ export { ConfigureEndpointDatasource } from './management/pages/policy/view/ingest_manager_integration/configure_datasource'; diff --git a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx index ac229a350c22c..64f491ff69627 100644 --- a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx +++ b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx @@ -5,20 +5,28 @@ */ import React, { memo } from 'react'; -import { useLocation } from 'react-router-dom'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiEmptyPrompt, EuiText } from '@elastic/eui'; import { useKibana } from '../../../../../../../../../src/plugins/kibana_react/public'; import { LinkToApp } from '../../../../../common/components/endpoint/link_to_app'; -import { CustomConfigureDatasourceContent } from '../../../../../../../ingest_manager/public'; +import { + CustomConfigureDatasourceContent, + NewDatasource, +} from '../../../../../../../ingest_manager/public'; import { getManagementUrl } from '../../../..'; +type DatasourceWithId = NewDatasource & { id: string }; + export const ConfigureEndpointDatasource = memo( - ({ from }: { from: string }) => { + ({ from, datasource }: { from: string; datasource: NewDatasource | DatasourceWithId }) => { const { services } = useKibana(); - const pathname = useLocation().pathname.split('/'); - const policyId = pathname[pathname.length - 1]; - const policyUrl = getManagementUrl({ name: 'policyDetails', policyId }); + let policyUrl = ''; + if (from === 'edit') { + policyUrl = getManagementUrl({ + name: 'policyDetails', + policyId: (datasource as DatasourceWithId).id, + }); + } return ( Date: Tue, 2 Jun 2020 12:34:46 -0400 Subject: [PATCH 16/18] update doc comments --- .../ingest_manager/common/types/models/datasource.ts | 3 +++ .../components/custom_configure_datasource.tsx | 4 ++++ x-pack/plugins/ingest_manager/public/index.ts | 7 ------- .../ingest_manager_integration/configure_datasource.tsx | 4 ++++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/ingest_manager/common/types/models/datasource.ts b/x-pack/plugins/ingest_manager/common/types/models/datasource.ts index 42ce69a5707cb..fb2e6ec6dfe0b 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/datasource.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/datasource.ts @@ -43,6 +43,9 @@ export interface DatasourceInput extends Omit { streams: DatasourceInputStream[]; } +/** + * Type of `datasource` prop in CustomConfigureDatasourceContent + */ export interface NewDatasource { name: string; description?: string; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx index a029b67759a23..0c350b407e803 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx @@ -16,6 +16,10 @@ export interface CustomConfigureDatasourceProps { datasource: NewDatasource | (NewDatasource & { id: string }); } +/** + * Allows external plugins to create custom content for the Ingest + * Datasource configuration. + */ export type CustomConfigureDatasourceContent = React.FC; const ConfigureDatasourceMapping: { [key: string]: CustomConfigureDatasourceContent } = { diff --git a/x-pack/plugins/ingest_manager/public/index.ts b/x-pack/plugins/ingest_manager/public/index.ts index 4b7461366d4a6..10a7eff30fae4 100644 --- a/x-pack/plugins/ingest_manager/public/index.ts +++ b/x-pack/plugins/ingest_manager/public/index.ts @@ -12,13 +12,6 @@ export const plugin = (initializerContext: PluginInitializerContext) => { return new IngestManagerPlugin(initializerContext); }; -/** - * Allows external plugins to create custom content for the Ingest - * Datasource configuration. - */ export { CustomConfigureDatasourceContent } from './applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource'; -/** - * Type of `datasource` prop in CustomConfigureDatasourceContent - */ export { NewDatasource } from './applications/ingest_manager/types'; diff --git a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx index 64f491ff69627..293ee112a42b4 100644 --- a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx +++ b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx @@ -17,6 +17,10 @@ import { getManagementUrl } from '../../../..'; type DatasourceWithId = NewDatasource & { id: string }; +/** + * Exports Endpoint-specific datasource configuration instructions + * for use in the Ingest app create / edit datasource config + */ export const ConfigureEndpointDatasource = memo( ({ from, datasource }: { from: string; datasource: NewDatasource | DatasourceWithId }) => { const { services } = useKibana(); From 635d035a04d27e0495198cbc4dce5f0134e71ec8 Mon Sep 17 00:00:00 2001 From: Candace Park Date: Tue, 2 Jun 2020 17:09:45 -0400 Subject: [PATCH 17/18] pauls comments --- .../ingest_manager/common/types/models/datasource.ts | 3 --- x-pack/plugins/ingest_manager/public/index.ts | 5 ++++- x-pack/plugins/siem/public/index.ts | 4 ---- .../ingest_manager_integration/configure_datasource.tsx | 9 ++++++++- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/ingest_manager/common/types/models/datasource.ts b/x-pack/plugins/ingest_manager/common/types/models/datasource.ts index fb2e6ec6dfe0b..42ce69a5707cb 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/datasource.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/datasource.ts @@ -43,9 +43,6 @@ export interface DatasourceInput extends Omit { streams: DatasourceInputStream[]; } -/** - * Type of `datasource` prop in CustomConfigureDatasourceContent - */ export interface NewDatasource { name: string; description?: string; diff --git a/x-pack/plugins/ingest_manager/public/index.ts b/x-pack/plugins/ingest_manager/public/index.ts index 10a7eff30fae4..ff923bc9043c9 100644 --- a/x-pack/plugins/ingest_manager/public/index.ts +++ b/x-pack/plugins/ingest_manager/public/index.ts @@ -12,6 +12,9 @@ export const plugin = (initializerContext: PluginInitializerContext) => { return new IngestManagerPlugin(initializerContext); }; -export { CustomConfigureDatasourceContent } from './applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource'; +export { + CustomConfigureDatasourceContent, + CustomConfigureDatasourceProps, +} from './applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource'; export { NewDatasource } from './applications/ingest_manager/types'; diff --git a/x-pack/plugins/siem/public/index.ts b/x-pack/plugins/siem/public/index.ts index 718791938b5ee..9e31ba8d771f7 100644 --- a/x-pack/plugins/siem/public/index.ts +++ b/x-pack/plugins/siem/public/index.ts @@ -12,8 +12,4 @@ export const plugin = (context: PluginInitializerContext): Plugin => new Plugin( export { Plugin, PluginSetup, PluginStart }; -/** - * Exports Endpoint-specific datasource configuration instructions - * for use in the Ingest app create / edit datasource config - */ export { ConfigureEndpointDatasource } from './management/pages/policy/view/ingest_manager_integration/configure_datasource'; diff --git a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx index 293ee112a42b4..bbdeb21254536 100644 --- a/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx +++ b/x-pack/plugins/siem/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx @@ -11,6 +11,7 @@ import { useKibana } from '../../../../../../../../../src/plugins/kibana_react/p import { LinkToApp } from '../../../../../common/components/endpoint/link_to_app'; import { CustomConfigureDatasourceContent, + CustomConfigureDatasourceProps, NewDatasource, } from '../../../../../../../ingest_manager/public'; import { getManagementUrl } from '../../../..'; @@ -22,7 +23,13 @@ type DatasourceWithId = NewDatasource & { id: string }; * for use in the Ingest app create / edit datasource config */ export const ConfigureEndpointDatasource = memo( - ({ from, datasource }: { from: string; datasource: NewDatasource | DatasourceWithId }) => { + ({ + from, + datasource, + }: { + from: string; + datasource: CustomConfigureDatasourceProps['datasource']; + }) => { const { services } = useKibana(); let policyUrl = ''; if (from === 'edit') { From ac2441d9c75f9b6b4b82de3e0940bc082555f995 Mon Sep 17 00:00:00 2001 From: Candace Park Date: Wed, 3 Jun 2020 15:50:37 -0400 Subject: [PATCH 18/18] registerDatasource from plugin lifecycle --- .../custom_configure_datasource.tsx | 21 ++++++++++++++----- x-pack/plugins/ingest_manager/public/index.ts | 1 + .../plugins/ingest_manager/public/plugin.ts | 10 +++++++-- .../mock/endpoint/dependencies_start_mock.ts | 4 ++-- x-pack/plugins/siem/public/index.ts | 2 -- x-pack/plugins/siem/public/plugin.tsx | 2 ++ 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx index 0c350b407e803..aff764cb8ba3e 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx @@ -6,7 +6,6 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiEmptyPrompt, EuiText } from '@elastic/eui'; -import { ConfigureEndpointDatasource } from '../../../../../../../../siem/public'; import { NewDatasource } from '../../../../types'; import { CreateDatasourceFrom } from '../types'; @@ -17,14 +16,26 @@ export interface CustomConfigureDatasourceProps { } /** - * Allows external plugins to create custom content for the Ingest + * Custom content type that external plugins can provide to Ingest's * Datasource configuration. */ export type CustomConfigureDatasourceContent = React.FC; -const ConfigureDatasourceMapping: { [key: string]: CustomConfigureDatasourceContent } = { - endpoint: ConfigureEndpointDatasource, -}; +type AllowedDatasourceKey = 'endpoint'; +const ConfigureDatasourceMapping: { + [key: string]: CustomConfigureDatasourceContent; +} = {}; + +/** + * Plugins can call this function from the start lifecycle to + * register a custom component in the Ingest Datasource configuration. + */ +export function registerDatasource( + key: AllowedDatasourceKey, + value: CustomConfigureDatasourceContent +) { + ConfigureDatasourceMapping[key] = value; +} const EmptyConfigureDatasource: CustomConfigureDatasourceContent = () => ( { export { CustomConfigureDatasourceContent, CustomConfigureDatasourceProps, + registerDatasource, } from './applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource'; export { NewDatasource } from './applications/ingest_manager/types'; diff --git a/x-pack/plugins/ingest_manager/public/plugin.ts b/x-pack/plugins/ingest_manager/public/plugin.ts index fd4e08f619495..3eb2fad339b7d 100644 --- a/x-pack/plugins/ingest_manager/public/plugin.ts +++ b/x-pack/plugins/ingest_manager/public/plugin.ts @@ -18,6 +18,7 @@ import { PLUGIN_ID } from '../common/constants'; import { IngestManagerConfigType } from '../common/types'; import { setupRouteService, appRoutesService } from '../common'; +import { registerDatasource } from './applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource'; export { IngestManagerConfigType } from '../common/types'; @@ -26,6 +27,7 @@ export type IngestManagerSetup = void; * Describes public IngestManager plugin contract returned at the `start` stage. */ export interface IngestManagerStart { + registerDatasource: typeof registerDatasource; success: boolean; error?: { message: string; @@ -80,12 +82,16 @@ export class IngestManagerPlugin const permissionsResponse = await core.http.get(appRoutesService.getCheckPermissionsPath()); if (permissionsResponse.success) { const { isInitialized: success } = await core.http.post(setupRouteService.getSetupPath()); - return { success }; + return { success, registerDatasource }; } else { throw new Error(permissionsResponse.error); } } catch (error) { - return { success: false, error: { message: error.body?.message || 'Unknown error' } }; + return { + success: false, + error: { message: error.body?.message || 'Unknown error' }, + registerDatasource, + }; } } diff --git a/x-pack/plugins/siem/public/common/mock/endpoint/dependencies_start_mock.ts b/x-pack/plugins/siem/public/common/mock/endpoint/dependencies_start_mock.ts index d3fc653f4c9ba..759ec45c7e54b 100644 --- a/x-pack/plugins/siem/public/common/mock/endpoint/dependencies_start_mock.ts +++ b/x-pack/plugins/siem/public/common/mock/endpoint/dependencies_start_mock.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IngestManagerStart } from '../../../../../ingest_manager/public'; +import { IngestManagerStart, registerDatasource } from '../../../../../ingest_manager/public'; import { dataPluginMock, Start as DataPublicStartMock, @@ -56,6 +56,6 @@ export const depsStartMock: () => DepsStartMock = () => { return { data: dataMock, - ingestManager: { success: true }, + ingestManager: { success: true, registerDatasource }, }; }; diff --git a/x-pack/plugins/siem/public/index.ts b/x-pack/plugins/siem/public/index.ts index 9e31ba8d771f7..36344a25e1568 100644 --- a/x-pack/plugins/siem/public/index.ts +++ b/x-pack/plugins/siem/public/index.ts @@ -11,5 +11,3 @@ import { PluginSetup, PluginStart } from './types'; export const plugin = (context: PluginInitializerContext): Plugin => new Plugin(context); export { Plugin, PluginSetup, PluginStart }; - -export { ConfigureEndpointDatasource } from './management/pages/policy/view/ingest_manager_integration/configure_datasource'; diff --git a/x-pack/plugins/siem/public/plugin.tsx b/x-pack/plugins/siem/public/plugin.tsx index 4b8fc078fc016..b4e0de4ff316d 100644 --- a/x-pack/plugins/siem/public/plugin.tsx +++ b/x-pack/plugins/siem/public/plugin.tsx @@ -20,6 +20,7 @@ import { KibanaServices } from './common/lib/kibana/services'; import { serviceNowActionType, jiraActionType } from './common/lib/connectors'; import { PluginSetup, PluginStart, SetupPlugins, StartPlugins, StartServices } from './types'; import { APP_ID, APP_NAME, APP_ICON, APP_PATH } from '../common/constants'; +import { ConfigureEndpointDatasource } from './management/pages/policy/view/ingest_manager_integration/configure_datasource'; export class Plugin implements IPlugin { private kibanaVersion: string; @@ -131,6 +132,7 @@ export class Plugin implements IPlugin