mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[Fleet] fix UI error when no tags filter is selected (#225413)
## Summary Closes https://github.com/elastic/kibana/issues/224055 To verify: - filter on `No Tags` or `not tags:*` in Agent list - add tag to an agent - expect that the agent disappears from view and there is no UI error https://github.com/user-attachments/assets/77982bc9-13a8-4141-b0a0-e9198706691f
This commit is contained in:
parent
731ab84487
commit
6cea1b0b6a
2 changed files with 12 additions and 5 deletions
|
@ -40,7 +40,7 @@ interface Props {
|
||||||
allTags: string[];
|
allTags: string[];
|
||||||
selectedTags: string[];
|
selectedTags: string[];
|
||||||
button: HTMLElement;
|
button: HTMLElement;
|
||||||
onTagsUpdated: () => void;
|
onTagsUpdated: (tagsToAdd: string[]) => void;
|
||||||
onClosePopover: () => void;
|
onClosePopover: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ export const TagsAddRemove: React.FC<Props> = ({
|
||||||
isRenameOrDelete = false
|
isRenameOrDelete = false
|
||||||
) => {
|
) => {
|
||||||
if (hasCompleted) {
|
if (hasCompleted) {
|
||||||
return onTagsUpdated();
|
return onTagsUpdated(tagsToAdd);
|
||||||
}
|
}
|
||||||
const selected = labels.filter((tag) => tag.checked === 'on').map((tag) => tag.label);
|
const selected = labels.filter((tag) => tag.checked === 'on').map((tag) => tag.label);
|
||||||
const newSelectedTags = difference(selected, tagsToRemove).concat(tagsToAdd);
|
const newSelectedTags = difference(selected, tagsToRemove).concat(tagsToAdd);
|
||||||
|
@ -115,7 +115,7 @@ export const TagsAddRemove: React.FC<Props> = ({
|
||||||
updateTagsHook.updateTags(
|
updateTagsHook.updateTags(
|
||||||
agentId,
|
agentId,
|
||||||
newSelectedTags,
|
newSelectedTags,
|
||||||
() => onTagsUpdated(),
|
() => onTagsUpdated(tagsToAdd),
|
||||||
successMessage,
|
successMessage,
|
||||||
errorMessage
|
errorMessage
|
||||||
);
|
);
|
||||||
|
|
|
@ -412,8 +412,15 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
|
||||||
allTags={allTags ?? []}
|
allTags={allTags ?? []}
|
||||||
selectedTags={agentToAddRemoveTags?.tags ?? []}
|
selectedTags={agentToAddRemoveTags?.tags ?? []}
|
||||||
button={tagsPopoverButton!}
|
button={tagsPopoverButton!}
|
||||||
onTagsUpdated={() => {
|
onTagsUpdated={(tagsToAdd: string[]) => {
|
||||||
refreshAgents();
|
refreshAgents({ refreshTags: true });
|
||||||
|
// close popover if agent is going to disappear from view to prevent UI error
|
||||||
|
if (
|
||||||
|
tagsToAdd.length > 0 &&
|
||||||
|
(selectedTags[0] === 'No Tags' || kuery.includes('not tags:*'))
|
||||||
|
) {
|
||||||
|
setShowTagsAddRemove(false);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
onClosePopover={() => {
|
onClosePopover={() => {
|
||||||
setShowTagsAddRemove(false);
|
setShowTagsAddRemove(false);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue