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.
[Rules migration] Improvements & fixes (elastic#206285)
## Summary [Internal link](elastic/security-team#10820) to the feature details This PR includes next improvements and fixes ### Improvements 1. Update copies across SIEM migrations feature 2. Add technical preview icon 3. Rename "Dismiss" to "Close" button within the flyout 4. Add simplified version of the ES|QL editor ### Fixes 1. Disable Overview tab for untranslated rules 2. Use "code block" instead of "markdown" to display queries 3. Show "Install and enable" button for translations that matched elastic prebuilt rules only 4. Allow user to open installed rule details in a separate tab > [!NOTE] > This feature needs `siemMigrationsEnabled` experimental flag enabled to work. --------- Co-authored-by: kibanamachine <[email protected]>
- Loading branch information
1 parent
c964c58
commit 3a95bec
Showing
28 changed files
with
338 additions
and
146 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
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
35 changes: 35 additions & 0 deletions
35
...rations/rules/components/rule_details_flyout/tabs/translation/esql_editor/esql_editor.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,35 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useMemo } from 'react'; | ||
import type { FieldValueQueryBar } from '../../../../../../../detection_engine/rule_creation_ui/components/query_bar_field'; | ||
import { UseField } from '../../../../../../../shared_imports'; | ||
import { EsqlEditorField } from './esql_editor_field'; | ||
import type { RuleTranslationSchema } from '../types'; | ||
|
||
interface EsqlEditorFieldProps { | ||
path: string; | ||
} | ||
|
||
export const EsqlEditor: React.FC<EsqlEditorFieldProps> = React.memo(({ path }) => { | ||
const componentProps = useMemo( | ||
() => ({ | ||
idAria: 'ruleEsqlQueryBar', | ||
dataTestSubj: 'ruleEsqlQueryBar', | ||
}), | ||
[] | ||
); | ||
|
||
return ( | ||
<UseField<FieldValueQueryBar, RuleTranslationSchema> | ||
path={path} | ||
component={EsqlEditorField} | ||
componentProps={componentProps} | ||
/> | ||
); | ||
}); | ||
EsqlEditor.displayName = 'EsqlEditor'; |
67 changes: 67 additions & 0 deletions
67
...s/rules/components/rule_details_flyout/tabs/translation/esql_editor/esql_editor_field.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,67 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useCallback } from 'react'; | ||
import deepEqual from 'fast-deep-equal'; | ||
import { EuiFormRow } from '@elastic/eui'; | ||
import { ESQLLangEditor } from '@kbn/esql/public'; | ||
import type { AggregateQuery } from '@kbn/es-query'; | ||
import { convertToQueryType } from '../../../../../../../common/components/query_bar/convert_to_query_type'; | ||
import type { FieldValueQueryBar } from '../../../../../../../detection_engine/rule_creation_ui/components/query_bar_field'; | ||
import type { FieldHook } from '../../../../../../../shared_imports'; | ||
|
||
interface EsqlEditorFieldProps { | ||
field: FieldHook<FieldValueQueryBar>; | ||
idAria?: string; | ||
dataTestSubj: string; | ||
} | ||
|
||
export const EsqlEditorField: React.FC<EsqlEditorFieldProps> = React.memo( | ||
({ field, idAria, dataTestSubj }) => { | ||
const { value: fieldValue, setValue: setFieldValue } = field; | ||
|
||
const onQueryChange = useCallback( | ||
(newQuery: AggregateQuery) => { | ||
const { query } = fieldValue; | ||
if (!deepEqual(query, newQuery)) { | ||
const esqlQuery = convertToQueryType(newQuery); | ||
setFieldValue({ ...fieldValue, query: esqlQuery }); | ||
} | ||
}, | ||
[fieldValue, setFieldValue] | ||
); | ||
|
||
const onQuerySubmit = useCallback( | ||
async (newQuery?: AggregateQuery) => { | ||
if (newQuery) { | ||
onQueryChange(newQuery); | ||
} | ||
}, | ||
[onQueryChange] | ||
); | ||
|
||
return ( | ||
<EuiFormRow | ||
fullWidth | ||
data-test-subj={dataTestSubj} | ||
describedByIds={idAria ? [idAria] : undefined} | ||
> | ||
<ESQLLangEditor | ||
query={{ esql: fieldValue.query.query as string }} | ||
onTextLangQueryChange={onQueryChange} | ||
onTextLangQuerySubmit={onQuerySubmit} | ||
hideRunQueryText={true} | ||
disableSubmitAction={true} | ||
hideTimeFilterInfo={true} | ||
hideQueryHistory={true} | ||
hasOutline={true} | ||
/> | ||
</EuiFormRow> | ||
); | ||
} | ||
); | ||
EsqlEditorField.displayName = 'EsqlEditorField'; |
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
Oops, something went wrong.