mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 10:40: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[];
|
||||
selectedTags: string[];
|
||||
button: HTMLElement;
|
||||
onTagsUpdated: () => void;
|
||||
onTagsUpdated: (tagsToAdd: string[]) => void;
|
||||
onClosePopover: () => void;
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ export const TagsAddRemove: React.FC<Props> = ({
|
|||
isRenameOrDelete = false
|
||||
) => {
|
||||
if (hasCompleted) {
|
||||
return onTagsUpdated();
|
||||
return onTagsUpdated(tagsToAdd);
|
||||
}
|
||||
const selected = labels.filter((tag) => tag.checked === 'on').map((tag) => tag.label);
|
||||
const newSelectedTags = difference(selected, tagsToRemove).concat(tagsToAdd);
|
||||
|
@ -115,7 +115,7 @@ export const TagsAddRemove: React.FC<Props> = ({
|
|||
updateTagsHook.updateTags(
|
||||
agentId,
|
||||
newSelectedTags,
|
||||
() => onTagsUpdated(),
|
||||
() => onTagsUpdated(tagsToAdd),
|
||||
successMessage,
|
||||
errorMessage
|
||||
);
|
||||
|
|
|
@ -412,8 +412,15 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
|
|||
allTags={allTags ?? []}
|
||||
selectedTags={agentToAddRemoveTags?.tags ?? []}
|
||||
button={tagsPopoverButton!}
|
||||
onTagsUpdated={() => {
|
||||
refreshAgents();
|
||||
onTagsUpdated={(tagsToAdd: string[]) => {
|
||||
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={() => {
|
||||
setShowTagsAddRemove(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue