[8.9] Fix infinite loading of APM alert table (#161134) (#161160)

# Backport

This will backport the following commits from `main` to `8.9`:
- [Fix infinite loading of APM alert table
(#161134)](https://github.com/elastic/kibana/pull/161134)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Maryam
Saeidi","email":"maryam.saeidi@elastic.co"},"sourceCommit":{"committedDate":"2023-07-04T09:54:02Z","message":"Fix
infinite loading of APM alert table (#161134)\n\nFixes #161095\r\n\r\n##
Summary\r\n\r\nThis PR fixes triggering and immediately canceling
/bsearch
requests\r\ninfinitely.","sha":"023b23f2a6a16612e48300494e66836d2c49c785","branchLabelMapping":{"^v8.10.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:APM","backport:prev-minor","v8.10.0","v8.8.3"],"number":161134,"url":"https://github.com/elastic/kibana/pull/161134","mergeCommit":{"message":"Fix
infinite loading of APM alert table (#161134)\n\nFixes #161095\r\n\r\n##
Summary\r\n\r\nThis PR fixes triggering and immediately canceling
/bsearch
requests\r\ninfinitely.","sha":"023b23f2a6a16612e48300494e66836d2c49c785"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"main","label":"v8.10.0","labelRegex":"^v8.10.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/161134","number":161134,"mergeCommit":{"message":"Fix
infinite loading of APM alert table (#161134)\n\nFixes #161095\r\n\r\n##
Summary\r\n\r\nThis PR fixes triggering and immediately canceling
/bsearch
requests\r\ninfinitely.","sha":"023b23f2a6a16612e48300494e66836d2c49c785"}},{"branch":"8.8","label":"v8.8.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Maryam Saeidi <maryam.saeidi@elastic.co>
This commit is contained in:
Kibana Machine 2023-07-04 07:13:47 -04:00 committed by GitHub
parent b37a07bc98
commit 2c55fd5198
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 4 deletions

View file

@ -5,7 +5,7 @@
* 2.0.
*/
import React, { useState, useMemo, useEffect } from 'react';
import React, { useState, useMemo, useEffect, useCallback } from 'react';
import { useHistory } from 'react-router-dom';
import { ObservabilityAlertSearchBar } from '@kbn/observability-plugin/public';
import { AlertStatus } from '@kbn/observability-plugin/common/typings';
@ -72,6 +72,11 @@ export function AlertsOverview() {
];
}, [serviceName, environment]);
const onKueryChange = useCallback(
(value) => push(history, { query: { kuery: value } }),
[history]
);
return (
<EuiPanel borderRadius="none" hasShadow={false}>
<EuiFlexGroup direction="column" gutterSize="s">
@ -86,9 +91,7 @@ export function AlertsOverview() {
onRangeToChange={(value) =>
push(history, { query: { rangeTo: value } })
}
onKueryChange={(value) =>
push(history, { query: { kuery: value } })
}
onKueryChange={onKueryChange}
defaultSearchQueries={apmQueries}
onStatusChange={setAlertStatusFilter}
onEsQueryChange={setEsQuery}

View file

@ -401,5 +401,6 @@ function useTabs({ selectedTab }: { selectedTab: Tab['key'] }) {
prepend,
append,
isSelected: key === selectedTab,
'data-test-subj': `${key}Tab`,
}));
}

View file

@ -222,5 +222,6 @@ function useTabs({ selectedTabKey }: { selectedTabKey: Tab['key'] }) {
label,
append,
isSelected: key === selectedTabKey,
'data-test-subj': `${key}Tab`,
}));
}

View file

@ -16,6 +16,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'error', 'timePicker', 'security']);
const testSubjects = getService('testSubjects');
const appsMenu = getService('appsMenu');
const observability = getService('observability');
const testData = {
correlationsTab: 'Failed transaction correlations',
@ -150,6 +151,18 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
);
});
});
it('navigates to the alerts tab', async function () {
await find.clickByCssSelector(`[data-test-subj="alertsTab"]`);
await PageObjects.timePicker.timePickerExists();
await PageObjects.timePicker.setCommonlyUsedTime('Last_15 minutes');
// Should show no data message
await retry.try(async () => {
await observability.overview.common.getAlertsTableNoDataOrFail();
});
});
});
});
}