forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENDPOINT][INGEST]Task/endpoint ingest update (elastic#67234)
Custom endpoint Datasource configuration in ingest Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com> Co-authored-by: Jen Huang <its.jenetic@gmail.com>
- Loading branch information
1 parent
cd79116
commit d568da9
Showing
12 changed files
with
186 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...r/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* 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 { NewDatasource } from '../../../../types'; | ||
import { CreateDatasourceFrom } from '../types'; | ||
|
||
export interface CustomConfigureDatasourceProps { | ||
packageName: string; | ||
from: CreateDatasourceFrom; | ||
datasource: NewDatasource | (NewDatasource & { id: string }); | ||
} | ||
|
||
/** | ||
* Custom content type that external plugins can provide to Ingest's | ||
* Datasource configuration. | ||
*/ | ||
export type CustomConfigureDatasourceContent = React.FC<CustomConfigureDatasourceProps>; | ||
|
||
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 = () => ( | ||
<EuiEmptyPrompt | ||
iconType="checkInCircleFilled" | ||
iconColor="secondary" | ||
body={ | ||
<EuiText> | ||
<p> | ||
<FormattedMessage | ||
id="xpack.ingestManager.createDatasource.stepConfigure.noConfigOptionsMessage" | ||
defaultMessage="Nothing to configure" | ||
/> | ||
</p> | ||
</EuiText> | ||
} | ||
/> | ||
); | ||
|
||
export const CustomConfigureDatasource = (props: CustomConfigureDatasourceProps) => { | ||
const ConfigureDatasourceContent = | ||
ConfigureDatasourceMapping[props.packageName] || EmptyConfigureDatasource; | ||
return <ConfigureDatasourceContent {...props} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
...m/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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 { EuiEmptyPrompt, EuiText } from '@elastic/eui'; | ||
import { useKibana } from '../../../../../../../../../src/plugins/kibana_react/public'; | ||
import { LinkToApp } from '../../../../../common/components/endpoint/link_to_app'; | ||
import { | ||
CustomConfigureDatasourceContent, | ||
CustomConfigureDatasourceProps, | ||
NewDatasource, | ||
} from '../../../../../../../ingest_manager/public'; | ||
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<CustomConfigureDatasourceContent>( | ||
({ | ||
from, | ||
datasource, | ||
}: { | ||
from: string; | ||
datasource: CustomConfigureDatasourceProps['datasource']; | ||
}) => { | ||
const { services } = useKibana(); | ||
let policyUrl = ''; | ||
if (from === 'edit') { | ||
policyUrl = getManagementUrl({ | ||
name: 'policyDetails', | ||
policyId: (datasource as DatasourceWithId).id, | ||
}); | ||
} | ||
|
||
return ( | ||
<EuiEmptyPrompt | ||
body={ | ||
<EuiText> | ||
<p> | ||
{from === 'edit' ? ( | ||
<LinkToApp | ||
appId="siem" | ||
appPath={policyUrl} | ||
href={`${services.application.getUrlForApp('siem')}${policyUrl}`} | ||
> | ||
<FormattedMessage | ||
id="xpack.siem.endpoint.ingestManager.editDatasource.stepConfigure" | ||
defaultMessage="View and configure Security Policy" | ||
/> | ||
</LinkToApp> | ||
) : ( | ||
<FormattedMessage | ||
id="xpack.siem.endpoint.ingestManager.createDatasource.stepConfigure" | ||
defaultMessage="The recommended Security Policy has been associated with this data source. The Security Policy can be edited in the Security application once your data source has been saved." | ||
/> | ||
)} | ||
</p> | ||
</EuiText> | ||
} | ||
/> | ||
); | ||
} | ||
); | ||
|
||
ConfigureEndpointDatasource.displayName = 'ConfigureEndpointDatasource'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters