[bug fix] Fleet UI: Activity readable without public IP (#19443)

This commit is contained in:
RachelElysia 2024-06-10 14:14:50 -04:00 committed by GitHub
parent dd89ab6998
commit df44151309
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 1 deletions

View file

@ -0,0 +1 @@
- Fix activity without public IP to be human readable

View file

@ -245,6 +245,15 @@ describe("Activity Feed", () => {
screen.getByText("successfully logged in from public IP 192.168.0.1.")
).toBeInTheDocument();
});
it("renders a user_logged_in type activity without public IP", () => {
const activity = createMockActivity({
type: ActivityType.UserLoggedIn,
details: {},
});
render(<ActivityItem activity={activity} isPremiumTier />);
expect(screen.getByText("successfully logged in.")).toBeInTheDocument();
});
it("renders a user_failed_login type activity globally", () => {
const activity = createMockActivity({

View file

@ -182,7 +182,14 @@ const TAGGED_TEMPLATES = {
return "was added to Fleet by SSO.";
},
userLoggedIn: (activity: IActivity) => {
return `successfully logged in from public IP ${activity.details?.public_ip}.`;
return (
<>
successfully logged in
{activity.details?.public_ip &&
` from public IP ${activity.details?.public_ip}`}
.
</>
);
},
userFailedLogin: (activity: IActivity) => {
return (