Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed all agent tags should be visible when agent list is filtred #170850

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
}, [selectedStatus]);

// filters kuery
const kuery = useMemo(() => {
const filteredKuery = useMemo(() => {
return getKuery({
search,
selectedAgentPolicies,
Expand All @@ -178,6 +178,10 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
});
}, [search, selectedAgentPolicies, selectedStatus, selectedTags]);

const allTagsKuery = useMemo(() => {
return getKuery({});
}, []);

const [agentsOnCurrentPage, setAgentsOnCurrentPage] = useState<Agent[]>([]);
const [agentsStatus, setAgentsStatus] = useState<
{ [key in SimplifiedAgentStatus]: number } | undefined
Expand Down Expand Up @@ -244,12 +248,12 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
agentsResponse,
totalInactiveAgentsResponse,
managedAgentPoliciesResponse,
agentTagsResponse,
allAgentTagsResponse,
] = await Promise.all([
sendGetAgents({
page: pagination.currentPage,
perPage: pagination.pageSize,
kuery: kuery && kuery !== '' ? kuery : undefined,
kuery: filteredKuery && filteredKuery !== '' ? filteredKuery : undefined,
sortField: getSortFieldForAPI(sortField),
sortOrder,
showInactive,
Expand All @@ -266,7 +270,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
full: false,
}),
sendGetAgentTags({
kuery: kuery && kuery !== '' ? kuery : undefined,
kuery: allTagsKuery && allTagsKuery !== '' ? allTagsKuery : undefined,
showInactive,
}),
]);
Expand All @@ -287,10 +291,10 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
if (managedAgentPoliciesResponse.error) {
throw new Error(managedAgentPoliciesResponse.error.message);
}
if (agentTagsResponse.error) {
throw agentTagsResponse.error;
if (allAgentTagsResponse.error) {
throw allAgentTagsResponse.error;
}
if (!agentTagsResponse.data) {
if (!allAgentTagsResponse.data) {
throw new Error('Invalid GET /agent/tags response');
}

Expand All @@ -300,7 +304,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
}
setAgentsStatus(agentStatusesToSummary(statusSummary));

const newAllTags = agentTagsResponse.data.items;
const newAllTags = allAgentTagsResponse.data.items;
// We only want to update the list of available tags if
// - We haven't set any tags yet
// - We've received the "refreshTags" flag which will force a refresh of the tags list when an agent is unenrolled
Expand Down Expand Up @@ -357,7 +361,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
[
pagination.currentPage,
pagination.pageSize,
kuery,
filteredKuery,
sortField,
sortOrder,
showInactive,
Expand Down Expand Up @@ -607,7 +611,7 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
totalInactiveAgents={totalInactiveAgents}
totalManagedAgentIds={totalManagedAgentIds}
selectionMode={selectionMode}
currentQuery={kuery}
currentQuery={filteredKuery}
selectedAgents={selectedAgents}
refreshAgents={refreshAgents}
onClickAddAgent={() => setEnrollmentFlyoutState({ isOpen: true })}
Expand Down