diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/agents_selection_status.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/agents_selection_status.tsx
index 682aaa91af6b6..618a7a6b8e112 100644
--- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/agents_selection_status.tsx
+++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/agents_selection_status.tsx
@@ -7,7 +7,7 @@
import React from 'react';
import styled from 'styled-components';
-import { EuiFlexGroup, EuiFlexItem, EuiText, EuiButtonEmpty } from '@elastic/eui';
+import { EuiFlexGroup, EuiFlexItem, EuiText, EuiButtonEmpty, EuiIconTip } from '@elastic/eui';
import { FormattedMessage, FormattedNumber } from '@kbn/i18n-react';
import { SO_SEARCH_LIMIT } from '../../../../constants';
@@ -33,6 +33,7 @@ const Button = styled(EuiButtonEmpty)`
export const AgentsSelectionStatus: React.FunctionComponent<{
totalAgents: number;
+ totalManagedAgents: number;
selectableAgents: number;
managedAgentsOnCurrentPage: number;
selectionMode: SelectionMode;
@@ -41,6 +42,7 @@ export const AgentsSelectionStatus: React.FunctionComponent<{
setSelectedAgents: (agents: Agent[]) => void;
}> = ({
totalAgents,
+ totalManagedAgents,
selectableAgents,
managedAgentsOnCurrentPage,
selectionMode,
@@ -71,11 +73,28 @@ export const AgentsSelectionStatus: React.FunctionComponent<{
}}
/>
) : (
-
+ <>
+ {' '}
+
+ }
+ />
+ >
)}
@@ -96,7 +115,24 @@ export const AgentsSelectionStatus: React.FunctionComponent<{
selectionMode,
count: selectedAgents.length,
}}
- />
+ />{' '}
+ {selectionMode === 'query' && (
+
+ }
+ />
+ )}
{showSelectEverything ? (
diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/bulk_actions.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/bulk_actions.tsx
index e0235fab01446..c5fd1c2caec81 100644
--- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/bulk_actions.tsx
+++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/bulk_actions.tsx
@@ -77,7 +77,7 @@ export const AgentBulkActions: React.FunctionComponent = ({
const [isRequestDiagnosticsModalOpen, setIsRequestDiagnosticsModalOpen] =
useState(false);
- // update the query removing the "managed" agents
+ // update the query removing the "managed" agents in any state (unenrolled, offline, etc)
const selectionQuery = useMemo(() => {
if (totalManagedAgentIds.length) {
const excludedKuery = `${AGENTS_PREFIX}.agent.id : (${totalManagedAgentIds
diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/table_header.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/table_header.tsx
index bcac45801be05..48757ecebdd80 100644
--- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/table_header.tsx
+++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/table_header.tsx
@@ -21,6 +21,7 @@ export const AgentTableHeader: React.FunctionComponent<{
agentStatus?: { [k in SimplifiedAgentStatus]: number };
totalAgents: number;
selectableAgents: number;
+ totalManagedAgents: number;
managedAgentsOnCurrentPage: number;
selectionMode: SelectionMode;
setSelectionMode: (mode: SelectionMode) => void;
@@ -31,6 +32,7 @@ export const AgentTableHeader: React.FunctionComponent<{
}> = ({
agentStatus,
totalAgents,
+ totalManagedAgents,
selectableAgents,
managedAgentsOnCurrentPage,
selectionMode,
@@ -47,6 +49,7 @@ export const AgentTableHeader: React.FunctionComponent<{
`policy_id:"${policy.id}"`)
- .join(' or ');
+ // Find all the agents that have managed policies
+ // to the correct ids we need to build the kuery applying the same filters as the global ones
+ const managedPoliciesKuery = getKuery({
+ search,
+ selectedAgentPolicies: managedAgentPolicies.map((policy) => policy.id),
+ selectedTags,
+ selectedStatus,
+ });
const response = await sendGetAgents({
- kuery: `NOT (status:unenrolled) and ${policiesKuery}`,
+ kuery: `${managedPoliciesKuery}`,
perPage: SO_SEARCH_LIMIT,
- showInactive: true,
+ showInactive,
});
if (response.error) {
throw new Error(response.error.message);
@@ -350,7 +354,6 @@ export function useFetchAgentsData() {
fetchDataAsync();
},
[
- fullAgentPolicyFecher,
pagination.currentPage,
pagination.pageSize,
kuery,
@@ -359,8 +362,12 @@ export function useFetchAgentsData() {
showInactive,
showUpgradeable,
displayAgentMetrics,
+ fullAgentPolicyFecher,
allTags,
latestAgentActionErrors,
+ search,
+ selectedTags,
+ selectedStatus,
notifications.toasts,
]
);
diff --git a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx
index 51f3fe68a9d95..a4171a8d5197a 100644
--- a/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx
+++ b/x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/index.tsx
@@ -434,6 +434,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
{/* Agent total, bulk actions and status bar */}