mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[ResponseOps][Alerting] ESQL alerting rule type ( pointed at main) (#165480)
Resolves https://github.com/elastic/kibana/issues/153448 ## Summary The same as this [pr](https://github.com/elastic/kibana/pull/164073), but just points at main --------- Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co> Co-authored-by: Alexey Antonov <alexwizp@gmail.com> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co> Co-authored-by: gchaps <33642766+gchaps@users.noreply.github.com> Co-authored-by: Peter Pisljar <peter.pisljar@elastic.co> Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
This commit is contained in:
parent
756599f7c2
commit
5f00ae97dd
45 changed files with 2241 additions and 129 deletions
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
export type { TextBasedLanguagesEditorProps } from './src/text_based_languages_editor';
|
||||
export { fetchFieldsFromESQL } from './src/fetch_fields_from_esql';
|
||||
import { TextBasedLanguagesEditor } from './src/text_based_languages_editor';
|
||||
|
||||
// React.lazy support
|
||||
|
|
|
@ -155,6 +155,7 @@ interface EditorFooterProps {
|
|||
detectTimestamp: boolean;
|
||||
onErrorClick: (error: MonacoError) => void;
|
||||
refreshErrors: () => void;
|
||||
hideRunQueryText?: boolean;
|
||||
}
|
||||
|
||||
export const EditorFooter = memo(function EditorFooter({
|
||||
|
@ -165,6 +166,7 @@ export const EditorFooter = memo(function EditorFooter({
|
|||
detectTimestamp,
|
||||
onErrorClick,
|
||||
refreshErrors,
|
||||
hideRunQueryText,
|
||||
}: EditorFooterProps) {
|
||||
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
|
||||
return (
|
||||
|
@ -235,27 +237,29 @@ export const EditorFooter = memo(function EditorFooter({
|
|||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiFlexGroup gutterSize="xs" responsive={false} alignItems="center">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiText size="xs" color="subdued">
|
||||
<p>
|
||||
{i18n.translate('textBasedEditor.query.textBasedLanguagesEditor.runQuery', {
|
||||
defaultMessage: 'Run query',
|
||||
})}
|
||||
</p>
|
||||
</EuiText>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiCode
|
||||
transparentBackground
|
||||
css={css`
|
||||
font-size: 12px;
|
||||
`}
|
||||
>{`${COMMAND_KEY} + Enter`}</EuiCode>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiFlexItem>
|
||||
{!hideRunQueryText && (
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiFlexGroup gutterSize="xs" responsive={false} alignItems="center">
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiText size="xs" color="subdued" data-test-subj="TextBasedLangEditor-run-query">
|
||||
<p>
|
||||
{i18n.translate('textBasedEditor.query.textBasedLanguagesEditor.runQuery', {
|
||||
defaultMessage: 'Run query',
|
||||
})}
|
||||
</p>
|
||||
</EuiText>
|
||||
</EuiFlexItem>
|
||||
<EuiFlexItem grow={false}>
|
||||
<EuiCode
|
||||
transparentBackground
|
||||
css={css`
|
||||
font-size: 12px;
|
||||
`}
|
||||
>{`${COMMAND_KEY} + Enter`}</EuiCode>
|
||||
</EuiFlexItem>
|
||||
</EuiFlexGroup>
|
||||
</EuiFlexItem>
|
||||
)}
|
||||
</EuiFlexGroup>
|
||||
);
|
||||
});
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import { pluck } from 'rxjs/operators';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { Query, AggregateQuery } from '@kbn/es-query';
|
||||
import { Query, AggregateQuery, TimeRange } from '@kbn/es-query';
|
||||
import type { ExpressionsStart } from '@kbn/expressions-plugin/public';
|
||||
import type { Datatable } from '@kbn/expressions-plugin/public';
|
||||
import { textBasedQueryStateToAstWithValidation } from '@kbn/data-plugin/common';
|
||||
|
@ -20,9 +20,14 @@ interface TextBasedLanguagesErrorResponse {
|
|||
type: 'error';
|
||||
}
|
||||
|
||||
export function fetchFieldsFromESQL(query: Query | AggregateQuery, expressions: ExpressionsStart) {
|
||||
export function fetchFieldsFromESQL(
|
||||
query: Query | AggregateQuery,
|
||||
expressions: ExpressionsStart,
|
||||
time?: TimeRange
|
||||
) {
|
||||
return textBasedQueryStateToAstWithValidation({
|
||||
query,
|
||||
time,
|
||||
})
|
||||
.then((ast) => {
|
||||
if (ast) {
|
||||
|
|
|
@ -242,4 +242,27 @@ describe('TextBasedLanguagesEditor', () => {
|
|||
).toBe('1 line');
|
||||
});
|
||||
});
|
||||
|
||||
it('should render the run query text', async () => {
|
||||
const newProps = {
|
||||
...props,
|
||||
isCodeEditorExpanded: true,
|
||||
};
|
||||
await act(async () => {
|
||||
const component = mount(renderTextBasedLanguagesEditorComponent({ ...newProps }));
|
||||
expect(component.find('[data-test-subj="TextBasedLangEditor-run-query"]').length).not.toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not render the run query text if the hideRunQueryText prop is set to true', async () => {
|
||||
const newProps = {
|
||||
...props,
|
||||
isCodeEditorExpanded: true,
|
||||
hideRunQueryText: true,
|
||||
};
|
||||
await act(async () => {
|
||||
const component = mount(renderTextBasedLanguagesEditorComponent({ ...newProps }));
|
||||
expect(component.find('[data-test-subj="TextBasedLangEditor-run-query"]').length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -75,6 +75,7 @@ export interface TextBasedLanguagesEditorProps {
|
|||
isDarkMode?: boolean;
|
||||
dataTestSubj?: string;
|
||||
hideMinimizeButton?: boolean;
|
||||
hideRunQueryText?: boolean;
|
||||
}
|
||||
|
||||
interface TextBasedEditorDeps {
|
||||
|
@ -120,6 +121,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
|
|||
isDisabled,
|
||||
isDarkMode,
|
||||
hideMinimizeButton,
|
||||
hideRunQueryText,
|
||||
dataTestSubj,
|
||||
}: TextBasedLanguagesEditorProps) {
|
||||
const { euiTheme } = useEuiTheme();
|
||||
|
@ -781,6 +783,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
|
|||
onErrorClick={onErrorClick}
|
||||
refreshErrors={onTextLangQuerySubmit}
|
||||
detectTimestamp={detectTimestamp}
|
||||
hideRunQueryText={hideRunQueryText}
|
||||
/>
|
||||
)}
|
||||
{isCodeEditorExpanded && (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue