Skip to content

Commit

Permalink
[Fleet] Fix inactive popover tour not resetting (elastic#176929)
Browse files Browse the repository at this point in the history
Fixes elastic#176124

## Summary
The [inactive popover](elastic#149226)
that appears the first time after agents become inactive was broken
(probably because of a EUi upgrade) and wasn't dismissable anymore.

I'm adding a footer with button that makes it easily dismissable.

![Screenshot 2024-02-14 at 16 15
36](https://github.com/elastic/kibana/assets/16084106/b4029aa2-e0f7-42d4-afe1-e810b7e88d23)

### Testing
- In dev tools console, run the following. This removes from the local
storage the key that signals that the tour was already ran once.
```
  localStorage.removeItem("fleet.inactiveAgentsCalloutHasBeenDismissed")
```
- Enroll some agents and wait that at least one becomes inactive
- The popover should be visible and it should be possible to dismiss it
by clicking "got it".

Co-authored-by: Kibana Machine <[email protected]>
(cherry picked from commit 851657c)

# Conflicts:
#	x-pack/plugins/fleet/public/applications/fleet/sections/agents/agent_list_page/components/agent_status_filter.tsx
  • Loading branch information
criamico committed Feb 19, 2024
1 parent f5bd489 commit 6bce8d8
Showing 1 changed file with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
EuiText,
EuiTourStep,
useEuiTheme,
EuiLink,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
Expand Down Expand Up @@ -64,17 +65,11 @@ const LeftpaddedNotificationBadge = styled(EuiNotificationBadge)`
margin-left: 10px;
`;

const TourStepNoHeaderFooter = styled(EuiTourStep)`
.euiTourFooter {
display: none;
}
.euiTourHeader {
display: none;
}
`;

const InactiveAgentsTourStep: React.FC<{ isOpen: boolean }> = ({ children, isOpen }) => (
<TourStepNoHeaderFooter
const InactiveAgentsTourStep: React.FC<{
isOpen: boolean;
setInactiveAgentsCalloutHasBeenDismissed: (val: boolean) => void;
}> = ({ children, isOpen, setInactiveAgentsCalloutHasBeenDismissed }) => (
<EuiTourStep
content={
<EuiText size="s">
<FormattedMessage
Expand All @@ -91,9 +86,21 @@ const InactiveAgentsTourStep: React.FC<{ isOpen: boolean }> = ({ children, isOpe
onFinish={() => {}}
anchorPosition="upCenter"
maxWidth={280}
footerAction={
<EuiLink
onClick={() => {
setInactiveAgentsCalloutHasBeenDismissed(true);
}}
>
<FormattedMessage
id="xpack.fleet.addAgentHelpPopover.footActionButton"
defaultMessage="Got it"
/>
</EuiLink>
}
>
{children as React.ReactElement}
</TourStepNoHeaderFooter>
</EuiTourStep>
);

export const AgentStatusFilter: React.FC<{
Expand Down Expand Up @@ -160,6 +167,7 @@ export const AgentStatusFilter: React.FC<{
return (
<InactiveAgentsTourStep
isOpen={newlyInactiveAgentsCount > 0 && !inactiveAgentsCalloutHasBeenDismissed}
setInactiveAgentsCalloutHasBeenDismissed={setInactiveAgentsCalloutHasBeenDismissed}
>
<EuiPopover
ownFocus
Expand Down

0 comments on commit 6bce8d8

Please sign in to comment.