fixed add remove tags stuck (#137074)

This commit is contained in:
Julia Bardi 2022-07-25 16:47:23 +02:00 committed by GitHub
parent 2880c66823
commit 857821f22c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 4 deletions

View file

@ -224,6 +224,9 @@ export const AgentBulkActions: React.FunctionComponent<Props> = ({
onTagsUpdated={() => {
refreshAgents({ refreshTags: true });
}}
onClosePopover={() => {
setIsTagAddVisible(false);
}}
/>
)}
<EuiFlexGroup gutterSize="m" alignItems="center">

View file

@ -21,7 +21,6 @@ export const TableRowActions: React.FunctionComponent<{
onUnenrollClick: () => void;
onUpgradeClick: () => void;
onAddRemoveTagsClick: (button: HTMLElement) => void;
allTags: string[];
}> = ({
agent,
agentPolicy,
@ -29,7 +28,6 @@ export const TableRowActions: React.FunctionComponent<{
onUnenrollClick,
onUpgradeClick,
onAddRemoveTagsClick,
allTags,
}) => {
const { getHref } = useLink();
const hasFleetAllPrivileges = useAuthz().fleet.all;

View file

@ -26,6 +26,7 @@ describe('TagsAddRemove', () => {
const onTagsUpdated = jest.fn();
const mockUpdateTags = useUpdateTags().updateTags as jest.Mock;
const mockBulkUpdateTags = useUpdateTags().bulkUpdateTags as jest.Mock;
const onClosePopover = jest.fn();
beforeEach(() => {
onTagsUpdated.mockReset();
@ -44,6 +45,7 @@ describe('TagsAddRemove', () => {
selectedTags={selectedTags}
button={button}
onTagsUpdated={onTagsUpdated}
onClosePopover={onClosePopover}
/>
);
};

View file

@ -41,6 +41,7 @@ interface Props {
selectedTags: string[];
button: HTMLElement;
onTagsUpdated: () => void;
onClosePopover: () => void;
}
export const TagsAddRemove: React.FC<Props> = ({
@ -50,6 +51,7 @@ export const TagsAddRemove: React.FC<Props> = ({
selectedTags,
button,
onTagsUpdated,
onClosePopover,
}: Props) => {
const labelsFromTags = useCallback(
(tags: string[]) =>
@ -65,7 +67,10 @@ export const TagsAddRemove: React.FC<Props> = ({
const [searchValue, setSearchValue] = useState<string | undefined>(undefined);
const [isPopoverOpen, setIsPopoverOpen] = useState(true);
const [isTagHovered, setIsTagHovered] = useState<{ [tagName: string]: boolean }>({});
const closePopover = () => setIsPopoverOpen(false);
const closePopover = () => {
setIsPopoverOpen(false);
onClosePopover();
};
const updateTagsHook = useUpdateTags();

View file

@ -531,7 +531,6 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
setAgentToAddRemoveTags(agent);
setShowTagsAddRemove(!showTagsAddRemove);
}}
allTags={allTags ?? []}
/>
);
},
@ -602,6 +601,9 @@ export const AgentListPage: React.FunctionComponent<{}> = () => {
onTagsUpdated={() => {
fetchData();
}}
onClosePopover={() => {
setShowTagsAddRemove(false);
}}
/>
)}
{isFleetServerUnhealthy && (