Skip to content

Commit

Permalink
Merge branch 'main' into eui-v93.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz authored Feb 8, 2024
2 parents c8ce7a2 + ee34012 commit 41709b2
Show file tree
Hide file tree
Showing 73 changed files with 3,814 additions and 517 deletions.
2 changes: 1 addition & 1 deletion fleet_packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,6 @@
},
{
"name": "security_detection_engine",
"version": "8.12.3"
"version": "8.12.4"
}
]
4 changes: 2 additions & 2 deletions packages/kbn-search-connectors/types/native_connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1793,7 +1793,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
type: FieldType.INTEGER,
ui_restrictions: [],
validations: [],
value: 9090,
value: 1433,
},
username: {
default_value: '',
Expand Down Expand Up @@ -2681,7 +2681,7 @@ export const NATIVE_CONNECTOR_DEFINITIONS: Record<string, NativeConnector | unde
type: FieldType.INTEGER,
ui_restrictions: [],
validations: [],
value: 9090,
value: 5432,
},
username: {
default_value: '',
Expand Down
16 changes: 11 additions & 5 deletions packages/kbn-text-based-editor/src/editor_footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ interface EditorFooterProps {
editorIsInline?: boolean;
isSpaceReduced?: boolean;
isLoading?: boolean;
allowQueryCancellation?: boolean;
}

export const EditorFooter = memo(function EditorFooter({
Expand All @@ -216,6 +217,7 @@ export const EditorFooter = memo(function EditorFooter({
editorIsInline,
isSpaceReduced,
isLoading,
allowQueryCancellation,
}: EditorFooterProps) {
const { euiTheme } = useEuiTheme();
const [isErrorPopoverOpen, setIsErrorPopoverOpen] = useState(false);
Expand Down Expand Up @@ -333,8 +335,8 @@ export const EditorFooter = memo(function EditorFooter({
size="s"
fill
onClick={runQuery}
isLoading={isLoading}
isDisabled={Boolean(disableSubmitAction)}
isLoading={isLoading && !allowQueryCancellation}
isDisabled={Boolean(disableSubmitAction && !allowQueryCancellation)}
data-test-subj="TextBasedLangEditor-run-query-button"
minWidth={isSpaceReduced ? false : undefined}
>
Expand All @@ -345,7 +347,11 @@ export const EditorFooter = memo(function EditorFooter({
justifyContent="spaceBetween"
>
<EuiFlexItem grow={false}>
{isSpaceReduced
{allowQueryCancellation && isLoading
? i18n.translate('textBasedEditor.query.textBasedLanguagesEditor.cancel', {
defaultMessage: 'Cancel',
})
: isSpaceReduced
? i18n.translate('textBasedEditor.query.textBasedLanguagesEditor.run', {
defaultMessage: 'Run',
})
Expand All @@ -361,7 +367,7 @@ export const EditorFooter = memo(function EditorFooter({
size="xs"
css={css`
border: 1px solid
${Boolean(disableSubmitAction)
${Boolean(disableSubmitAction && !allowQueryCancellation)
? euiTheme.colors.disabled
: euiTheme.colors.emptyShade};
padding: 0 ${euiTheme.size.xs};
Expand All @@ -370,7 +376,7 @@ export const EditorFooter = memo(function EditorFooter({
border-radius: ${euiTheme.size.xs};
`}
>
{COMMAND_KEY}
{allowQueryCancellation && isLoading ? 'X' : `${COMMAND_KEY}`}
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
11 changes: 10 additions & 1 deletion packages/kbn-text-based-editor/src/fetch_fields_from_esql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export function fetchFieldsFromESQL(
query: Query | AggregateQuery,
expressions: ExpressionsStart,
time?: TimeRange,
abortController?: AbortController,
dataView?: DataView
) {
return textBasedQueryStateToAstWithValidation({
Expand All @@ -33,7 +34,15 @@ export function fetchFieldsFromESQL(
})
.then((ast) => {
if (ast) {
const execution = expressions.run(ast, null);
const executionContract = expressions.execute(ast, null);

if (abortController) {
abortController.signal.onabort = () => {
executionContract.cancel();
};
}

const execution = executionContract.getData();
let finalData: Datatable;
let error: string | undefined;
execution.pipe(pluck('result')).subscribe((resp) => {
Expand Down
11 changes: 11 additions & 0 deletions packages/kbn-text-based-editor/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ export const parseErrors = (errors: Error[], code: string): MonacoMessage[] => {
endLineNumber: Number(lineNumber),
severity: monaco.MarkerSeverity.Error,
};
} else if (error.message.includes('expression was aborted')) {
return {
message: i18n.translate('textBasedEditor.query.textBasedLanguagesEditor.aborted', {
defaultMessage: 'Request was aborted',
}),
startColumn: 1,
startLineNumber: 1,
endColumn: 10,
endLineNumber: 1,
severity: monaco.MarkerSeverity.Warning,
};
} else {
// unknown error message
return {
Expand Down
64 changes: 51 additions & 13 deletions packages/kbn-text-based-editor/src/text_based_languages_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ export interface TextBasedLanguagesEditorProps {
/** Callback running everytime the query changes */
onTextLangQueryChange: (query: AggregateQuery) => void;
/** Callback running when the user submits the query */
onTextLangQuerySubmit: (query?: AggregateQuery) => void;
onTextLangQuerySubmit: (
query?: AggregateQuery,
abortController?: AbortController
) => Promise<void>;
/** Can be used to expand/minimize the editor */
expandCodeEditor: (status: boolean) => void;
/** If it is true, the editor initializes with height EDITOR_INITIAL_HEIGHT_EXPANDED */
Expand Down Expand Up @@ -105,6 +108,9 @@ export interface TextBasedLanguagesEditorProps {
editorIsInline?: boolean;
/** Disables the submit query action*/
disableSubmitAction?: boolean;

/** when set to true enables query cancellation **/
allowQueryCancellation?: boolean;
}

interface TextBasedEditorDeps {
Expand Down Expand Up @@ -158,6 +164,7 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
editorIsInline,
disableSubmitAction,
dataTestSubj,
allowQueryCancellation,
}: TextBasedLanguagesEditorProps) {
const { euiTheme } = useEuiTheme();
const language = getAggregateQueryMode(query);
Expand All @@ -176,7 +183,8 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
const [showLineNumbers, setShowLineNumbers] = useState(isCodeEditorExpanded);
const [isCompactFocused, setIsCompactFocused] = useState(isCodeEditorExpanded);
const [isCodeEditorExpandedFocused, setIsCodeEditorExpandedFocused] = useState(false);

const [isQueryLoading, setIsQueryLoading] = useState(true);
const [abortController, setAbortController] = useState(new AbortController());
const [editorMessages, setEditorMessages] = useState<{
errors: MonacoMessage[];
warnings: MonacoMessage[];
Expand All @@ -186,12 +194,25 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
});

const onQuerySubmit = useCallback(() => {
const currentValue = editor1.current?.getValue();
if (currentValue != null) {
setCodeStateOnSubmission(currentValue);
if (isQueryLoading && allowQueryCancellation) {
abortController?.abort();
setIsQueryLoading(false);
} else {
setIsQueryLoading(true);
const abc = new AbortController();
setAbortController(abc);

const currentValue = editor1.current?.getValue();
if (currentValue != null) {
setCodeStateOnSubmission(currentValue);
}
onTextLangQuerySubmit({ [language]: currentValue } as AggregateQuery, abc);
}
onTextLangQuerySubmit({ [language]: currentValue } as AggregateQuery);
}, [language, onTextLangQuerySubmit]);
}, [language, onTextLangQuerySubmit, abortController, isQueryLoading, allowQueryCancellation]);

useEffect(() => {
if (!isLoading) setIsQueryLoading(false);
}, [isLoading]);

const [documentationSections, setDocumentationSections] =
useState<LanguageDocumentationSections>();
Expand Down Expand Up @@ -311,12 +332,13 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
const { cache: esqlFieldsCache, memoizedFieldsFromESQL } = useMemo(() => {
// need to store the timing of the first request so we can atomically clear the cache per query
const fn = memoize(
(...args: [{ esql: string }, ExpressionsStart]) => ({
(...args: [{ esql: string }, ExpressionsStart, undefined, AbortController?]) => ({
timestamp: Date.now(),
result: fetchFieldsFromESQL(...args),
}),
({ esql }) => esql
);

return { cache: fn.cache, memoizedFieldsFromESQL: fn };
}, []);

Expand All @@ -334,7 +356,12 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
// Check if there's a stale entry and clear it
clearCacheWhenOld(esqlFieldsCache, esqlQuery.esql);
try {
const table = await memoizedFieldsFromESQL(esqlQuery, expressions).result;
const table = await memoizedFieldsFromESQL(
esqlQuery,
expressions,
undefined,
abortController
).result;
return table?.columns.map((c) => ({ name: c.name, type: c.meta.type })) || [];
} catch (e) {
// no action yet
Expand All @@ -352,7 +379,14 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
return policies.map(({ type, query: policyQuery, ...rest }) => rest);
},
}),
[dataViews, expressions, indexManagementApiService, esqlFieldsCache, memoizedFieldsFromESQL]
[
dataViews,
expressions,
indexManagementApiService,
esqlFieldsCache,
memoizedFieldsFromESQL,
abortController,
]
);

const queryValidation = useCallback(
Expand Down Expand Up @@ -867,7 +901,8 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
disableSubmitAction={disableSubmitAction}
hideRunQueryText={hideRunQueryText}
isSpaceReduced={isSpaceReduced}
isLoading={isLoading}
isLoading={isQueryLoading}
allowQueryCancellation={allowQueryCancellation}
/>
)}
</div>
Expand Down Expand Up @@ -954,13 +989,16 @@ export const TextBasedLanguagesEditor = memo(function TextBasedLanguagesEditor({
lines={lines}
containerCSS={styles.bottomContainer}
onErrorClick={onErrorClick}
runQuery={onQuerySubmit}
runQuery={() => {
onQuerySubmit();
}}
detectTimestamp={detectTimestamp}
hideRunQueryText={hideRunQueryText}
editorIsInline={editorIsInline}
disableSubmitAction={disableSubmitAction}
isSpaceReduced={isSpaceReduced}
isLoading={isLoading}
isLoading={isQueryLoading}
allowQueryCancellation={allowQueryCancellation}
{...editorMessages}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,7 @@ export const QueryBarTopRow = React.memo(
errors={props.textBasedLanguageModeErrors}
warning={props.textBasedLanguageModeWarning}
detectTimestamp={detectTimestamp}
onTextLangQuerySubmit={() =>
onTextLangQuerySubmit={async () =>
onSubmit({
query: queryRef.current,
dateRange: dateRangeRef.current,
Expand Down
4 changes: 4 additions & 0 deletions x-pack/packages/ml/anomaly_utils/anomaly_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export interface MlEntityField {
* Optional entity field operation
*/
operation?: MlEntityFieldOperation;
/**
* Optional cardinality of field
*/
cardinality?: number;
}

// List of function descriptions for which actual values from record level results should be displayed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ describe('Service inventory', () => {
});
});

describe('Table search', () => {
// Skipping this until we enable the table search on the Service inventory view
describe.skip('Table search', () => {
beforeEach(() => {
cy.updateAdvancedSettings({
'observability:apmEnableTableSearchBar': true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ export function ServiceList({

const tableSearchBar: TableSearchBar<ServiceListItem> = useMemo(() => {
return {
isEnabled: false,
fieldsToSearch: ['serviceName'],
maxCountExceeded,
onChangeSearchQuery,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function UnoptimizedManagedTable<T extends object>(props: {
const { core } = useApmPluginContext();
const isTableSearchBarEnabled = core.uiSettings.get<boolean>(
apmEnableTableSearchBar,
false
true
);

const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import { screen, waitFor } from '@testing-library/react';
import { waitForEuiPopoverOpen } from '@elastic/eui/lib/test/rtl';
import { SeverityFilter } from './severity_filter';

describe('Severity form field', () => {
// FLAKY: https://github.com/elastic/kibana/issues/176336
// FLAKY: https://github.com/elastic/kibana/issues/176337
describe.skip('Severity form field', () => {
const onChange = jest.fn();
let appMockRender: AppMockRenderer;
const props = {
Expand Down
11 changes: 8 additions & 3 deletions x-pack/plugins/cases/public/components/app/routes.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ describe('Cases routes', () => {
});
});

describe('Case view', () => {
// FLAKY: https://github.com/elastic/kibana/issues/163263
describe.skip('Case view', () => {
it.each(getCaseViewPaths())(
'navigates to the cases view page for path: %s',
async (path: string) => {
Expand All @@ -84,7 +85,9 @@ describe('Cases routes', () => {
);
});

describe('Create case', () => {
// FLAKY: https://github.com/elastic/kibana/issues/175229
// FLAKY: https://github.com/elastic/kibana/issues/175230
describe.skip('Create case', () => {
it('navigates to the create case page', () => {
renderWithRouter(['/cases/create']);
expect(screen.getByText('Create case')).toBeInTheDocument();
Expand All @@ -96,7 +99,9 @@ describe('Cases routes', () => {
});
});

describe('Cases settings', () => {
// FLAKY: https://github.com/elastic/kibana/issues/175231
// FLAKY: https://github.com/elastic/kibana/issues/175232
describe.skip('Cases settings', () => {
it('navigates to the cases settings page', () => {
renderWithRouter(['/cases/configure']);
expect(screen.getByText('Settings')).toBeInTheDocument();
Expand Down
Loading

0 comments on commit 41709b2

Please sign in to comment.