Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve node activities and add first draft for global activities #5747

Merged
merged 37 commits into from
Feb 19, 2025

Conversation

pa-lem
Copy link
Contributor

@pa-lem pa-lem commented Feb 13, 2025

  • Add limit and link on the node activities view
  • Update details cards UI to not grow
  • Add starting point for the global activities list view + menu link to this view
  • Handle group member events in both details and list views
  • Add global activities pagination and search
Capture d’écran 2025-02-14 à 15 17 23 image

@github-actions github-actions bot added group/backend Issue related to the backend (API Server, Git Agent) group/frontend Issue related to the frontend (React) labels Feb 13, 2025
@pa-lem pa-lem marked this pull request as ready for review February 14, 2025 14:20
@pa-lem pa-lem requested review from a team as code owners February 14, 2025 14:20
Copy link

codspeed-hq bot commented Feb 14, 2025

CodSpeed Performance Report

Merging #5747 will not alter performance

Comparing ple-global-activities (2505db1) with develop (c61ac59)

Summary

✅ 11 untouched benchmarks

Copy link
Contributor

@ajtmccarty ajtmccarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the backend change looks good

offset,
limit,
search,
}: { ids?: Array<string | undefined>; offset?: number; limit?: number; search?: string }) {
const currentBranchName = getCurrentBranchName();
const timeMachineDate = store.get(datetimeAtom);

return queryOptions({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally, it should be an infiniteQueryOptions

}
}
}
`;

export function getEventsFromApi({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file name should be get-events-from-api.ts

return graphqlClient.query({
query: gql(getEventsQuery({ ids })),
query: gql(EVENTS_QUERY),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gql should be part of EVENTS_QUERY

Comment on lines +60 to +62
{"attributes" in props && <NodeEvent {...props} />}

{"attributes" in props && <EventAttributes attributes={props.attributes} />}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same condition

const { event, branch } = props;

return (
<>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fragment is useless no?

@@ -22,11 +25,39 @@ export const GlobalEvents = () => {
return edge.node;
});

const count = data?.data?.[INFRAHUB_EVENT]?.count;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this kind of destructuring are better to be done in useEvents directly. The goal is to have data read to use instantly when calling useEvents

const { event, account_id, primary_node } = props;

return (
<>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fragment useless no?

import { EventNodeInterface } from "@/shared/api/graphql/generated/graphql";
import { ReactElement } from "react";

export const GROUP_EVENTS_MAPPING: Record<string, (node: string, group: string) => ReactElement> = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReactNode instead of ReactElement is "more correct"

@@ -32,6 +40,14 @@ export const NodeEvents = () => {
{activities?.map((activity) => (
<Event key={activity.id} {...activity} />
))}

{data?.data?.[INFRAHUB_EVENT]?.count > MAX_EVENTS && (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same things, it's better to put destructuration inside of useEvents

return [searchFilter ?? "", setSearch];
};

export default useSearch;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to avoid default export to enforce function name


const MAX_EVENTS = 5;

export const NodeEvents = () => {
const { objectid } = useParams();

const { isLoading, data, error } = useEvents({ ids: [objectid], limit: MAX_EVENTS });
const { isLoading, data, count, error } = useEvents({ ids: [objectid], limit: MAX_EVENTS });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you check isPending + error, data is guarantee to be available after

@pa-lem pa-lem merged commit 7e4ae78 into develop Feb 19, 2025
35 checks passed
@pa-lem pa-lem deleted the ple-global-activities branch February 19, 2025 14:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent) group/frontend Issue related to the frontend (React)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants