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

Update activities links and add more events in the UI #5918

Merged
merged 34 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
4816576
set current branch in filter
pa-lem Feb 26, 2025
e07a68c
set current branch in filter + update event type filter
pa-lem Feb 26, 2025
be89dd0
add event type
pa-lem Feb 26, 2025
420eec8
fix param
pa-lem Feb 26, 2025
4fea82f
update ui
pa-lem Feb 27, 2025
9ea30d3
Merge branch 'release-1.2' of github.com:opsmill/infrahub into ple-ac…
pa-lem Feb 28, 2025
a5d07ef
add kind filter form for filter
pa-lem Feb 28, 2025
d7aa86f
add new group event properties
pa-lem Feb 28, 2025
9392368
ui + lint
pa-lem Feb 28, 2025
cc7d6ad
temporary fix for global events
pa-lem Feb 28, 2025
bf040f4
udpate labels
pa-lem Feb 28, 2025
a64e052
update ui for column display
pa-lem Feb 28, 2025
ec057db
Merge branch 'release-1.2' into ple-activities-updates
pa-lem Feb 28, 2025
dd6d1c9
fix combobox list
pa-lem Mar 3, 2025
bd8c65a
Merge branch 'release-1.2' of github.com:opsmill/infrahub into ple-ac…
pa-lem Mar 3, 2025
b3d4246
Merge branch 'ple-activities-updates' of github.com:opsmill/infrahub …
pa-lem Mar 3, 2025
e23ec1a
lint
pa-lem Mar 3, 2025
edf2104
update label map
pa-lem Mar 3, 2025
f481cff
Merge branch 'release-1.2' of github.com:opsmill/infrahub into ple-ac…
pa-lem Mar 3, 2025
65e7c22
add default case
pa-lem Mar 3, 2025
e9aa0c3
add group event and ensure default display
pa-lem Mar 3, 2025
8b8098c
fix global event
pa-lem Mar 3, 2025
8c4513a
fix branch event with new properties
pa-lem Mar 3, 2025
876104d
update branch events
pa-lem Mar 3, 2025
a92dbd8
always display link
pa-lem Mar 3, 2025
1fb40e0
fix links from events
pa-lem Mar 3, 2025
97744c5
udpate date in tooltip
pa-lem Mar 3, 2025
86cc753
fix typo
pa-lem Mar 3, 2025
06cc189
handle commit events
pa-lem Mar 3, 2025
0175350
display branch
pa-lem Mar 3, 2025
b2814a1
Merge branch 'release-1.2' of github.com:opsmill/infrahub into ple-ac…
pa-lem Mar 4, 2025
ce9a1fd
fix test
pa-lem Mar 4, 2025
d0f7e78
fix node label ffrom different branch
pa-lem Mar 4, 2025
1092fea
Merge branch 'release-1.2' into ple-activities-updates
pa-lem Mar 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions frontend/app/src/entities/events/api/get-events-from-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,33 @@ const EVENTS_QUERY = gql`
}
payload
}
... on BranchCreatedEvent {
... on StandardEvent {
payload
}
... on StandardEvent {
... on BranchCreatedEvent {
payload
created_branch
}
... on BranchDeletedEvent {
payload
deleted_branch
}
... on BranchRebasedEvent {
payload
rebased_branch
}
... on BranchMergedEvent {
source_branch
}
... on GroupEvent {
ancestors {
id
kind
}
members {
id
kind
}
}
... on GroupEvent {
ancestors {
Expand Down
20 changes: 17 additions & 3 deletions frontend/app/src/entities/events/ui/branch-event.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,35 @@
import { NodeLabel } from "@/entities/nodes/object/ui/node-label";
import { EventNodeInterface } from "@/shared/api/graphql/generated/graphql";
import { Link } from "@/shared/components/ui/link";
import { ReactNode } from "react";

export const BRANCH_EVENTS_MAPPING: Record<string, (props: EventNodeInterface) => ReactNode> = {
"infrahub.branch.created": (props) => (
<div>
created the branch <span className="text-black font-semibold">{props.branch}</span>{" "}
created the branch{" "}
<Link to={`/branches/${props.created_branch}`} className="text-black font-semibold">
{props.created_branch ?? "-"}
</Link>
</div>
),
"infrahub.branch.rebased": (props) => (
<div>
rebased the branch <span className="text-black font-semibold">{props.branch}</span>{" "}
rebased the branch{" "}
<Link to={`/branches/${props.rebased_branch}`} className="text-black font-semibold">
{props.rebased_branch ?? "-"}
</Link>
</div>
),
"infrahub.branch.merged": (props) => (
<div>
merged the branch{" "}
<span className="text-black font-semibold">{props.source_branch ?? "-"}</span>
</div>
),
"infrahub.branch.deleted": (props) => (
<div>
deleted the branch <span className="text-black font-semibold">{props.branch}</span>{" "}
deleted the branch{" "}
<span className="text-black font-semibold">{props.deleted_branch ?? "-"}</span>
</div>
),
};
Expand Down
2 changes: 2 additions & 0 deletions frontend/app/src/entities/events/ui/event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type EventType = BranchEventType | NodeEventType | GroupEvent;
export const EventDetails = ({
id,
event,
branch,
occurred_at,
account_id,
primary_node,
Expand All @@ -61,6 +62,7 @@ export const EventDetails = ({
}
/>
<PropertyRow title="Event" value={event} />
<PropertyRow title="Branch" value={branch} />
<PropertyRow title="Occured at" value={<DateDisplay date={occurred_at} />} />
{account_id && (
<PropertyRow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const BranchEvent = (props: EventNodeInterface) => {
<NodeLabel id={account_id} />
</div>

{BRANCH_EVENTS_MAPPING[event] && BRANCH_EVENTS_MAPPING[event](props)}
{(BRANCH_EVENTS_MAPPING[event] && BRANCH_EVENTS_MAPPING[event](props)) ?? event}
</div>
</div>
);
Expand Down
41 changes: 31 additions & 10 deletions frontend/app/src/entities/events/ui/global-event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,34 @@ import { Tooltip } from "@/shared/components/ui/tooltip";
import { classNames } from "@/shared/utils/common";
import { Icon } from "@iconify-icon/react";
import { format } from "date-fns";
import { BRANCH_EVENTS, STANDARD_EVENTS } from "../utils/constants";
import { BRANCH_EVENTS, GROUP_EVENTS, STANDARD_EVENTS } from "../utils/constants";
import { EventType } from "./event";
import { BranchEvent } from "./global-branch-event";
import { GroupEvent } from "./global-group-event";
import { NodeEvent } from "./global-node-event";
import { StandardEvent } from "./global-standard-event";

export const Event = ({ __typename, ...props }: EventType) => {
const GlobalEventDisplay = ({ __typename, ...props }: EventType) => {
if ("attributes" in props) {
return <NodeEvent {...props} />;
}

if (BRANCH_EVENTS.includes(__typename)) {
return <BranchEvent {...props} />;
}

if (STANDARD_EVENTS.includes(__typename)) {
return <StandardEvent {...props} />;
}

if (GROUP_EVENTS.includes(__typename)) {
return <GroupEvent {...props} />;
}

return <span className="flex items-center text-sm text-gray-500 ">{props.event}</span>;
};

export const Event = (props: EventType) => {
return (
<div
className={classNames(
Expand All @@ -18,23 +39,23 @@ export const Event = ({ __typename, ...props }: EventType) => {
)}
>
<div className="flex items-center text-xs font-medium text-gray-500 whitespace-nowrap">
<Tooltip enabled content={props.occurred_at}>
<Tooltip enabled content={format(new Date(props.occurred_at), "yyyy-MM-dd HH:mm:ss (O)")}>
<span>{format(new Date(props.occurred_at), "MMM dd, HH:mm:ss")}</span>
</Tooltip>
</div>

<div className="col-span-5 flex item-center gap-4 overflow-hidden">
{"attributes" in props && <NodeEvent {...props} />}

{BRANCH_EVENTS.includes(__typename) && <BranchEvent {...props} />}

{STANDARD_EVENTS.includes(__typename) && <StandardEvent {...props} />}
<GlobalEventDisplay {...props} />
</div>

<div className="text-xs font-medium text-gray-500 flex items-center gap-1">
<Icon icon={"mdi:source-branch"} />
{props.branch && (
<>
<Icon icon={"mdi:source-branch"} />

{props.branch}
{props.branch}
</>
)}
</div>

<div className="relative">
Expand Down
24 changes: 24 additions & 0 deletions frontend/app/src/entities/events/ui/global-group-event.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { NodeLabel } from "@/entities/nodes/object/ui/node-label";
import { EventNodeInterface } from "@/shared/api/graphql/generated/graphql";
import { Icon } from "@iconify-icon/react";
import { GROUP_EVENTS_MAPPING } from "./group-event";

export const GroupEvent = (props: EventNodeInterface) => {
const { event, account_id } = props;

return (
<>
<div className="flex items-center justify-between">
<div className="flex items-center gap-2 text-sm text-gray-500">
<Icon icon="mdi:group" className="text-gray-400" />

<div className="text-black font-semibold">
<NodeLabel id={account_id} kind="CoreAccount" branch={props.branch} />
</div>

{(GROUP_EVENTS_MAPPING[event] && GROUP_EVENTS_MAPPING[event](props)) ?? event}
</div>
</div>
</>
);
};
38 changes: 21 additions & 17 deletions frontend/app/src/entities/events/ui/global-node-event.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { QSP } from "@/config/qsp";
import { NodeLabel } from "@/entities/nodes/object/ui/node-label";
import { schemaKindLabelState } from "@/entities/schema/stores/schemaKindLabel.atom";
import { useSchema } from "@/entities/schema/ui/hooks/useSchema";
import { NodeMutatedEvent } from "@/shared/api/graphql/generated/graphql";
import { constructPath } from "@/shared/api/rest/fetch";
import { Link } from "@/shared/components/ui/link";
import { Icon } from "@iconify-icon/react";
import { useAtomValue } from "jotai";
import { NODE_EVENTS_MAPPING } from "./node-event";
import { NODE_EVENTS_MAPPING, getLink } from "./node-event";

export const EventAttributes = ({ attributes }: Pick<NodeMutatedEvent, "attributes">) => {
return (
Expand Down Expand Up @@ -45,30 +43,36 @@ export const NodeEvent = (props: NodeMutatedEvent) => {
className="overflow-hidden text-ellipsis whitespace-nowrap font-semibold"
/>

<div className="text-gray-500">{NODE_EVENTS_MAPPING[event] ?? "-"}</div>
<div className="text-gray-500">{NODE_EVENTS_MAPPING[event] ?? event}</div>

<div className="font-semibold whitespace-nowrap">
{schemaLabels[props.payload.data.node_kind] ?? "-"}
</div>

<Link
to={constructPath(
`/objects/${props.payload.data.node_kind}/${props.payload.data.node_id}`,
[
{
name: QSP.BRANCH,
value: props.branch,
},
]
)}
className="overflow-hidden text-ellipsis"
>
{event.includes("deleted") ? (
<NodeLabel
id={props.primary_node.id}
kind={props.primary_node?.kind}
branch={props.branch}
className="overflow-hidden text-ellipsis whitespace-nowrap"
/>
</Link>
) : (
<Link
to={getLink({
kind: props.primary_node?.kind,
id: props.primary_node.id,
branch: props.branch,
})}
className="overflow-hidden text-ellipsis"
>
<NodeLabel
id={props.primary_node.id}
kind={props.primary_node?.kind}
branch={props.branch}
className="overflow-hidden text-ellipsis whitespace-nowrap"
/>
</Link>
)}
</div>
);
};
18 changes: 8 additions & 10 deletions frontend/app/src/entities/events/ui/global-standard-event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { Icon } from "@iconify-icon/react";
import { STANDARD_EVENTS_MAPPING } from "./standard-event";

const getStandardEventIcon = (event: string) => {
if (event.includes("group")) {
return <Icon icon="mdi:group" className="text-gray-400" />;
}

if (event.includes("schema")) {
return <Icon icon="mdi:code-json" className="text-gray-400" />;
}
Expand All @@ -24,13 +20,15 @@ export const StandardEvent = (props: EventNodeInterface) => {
<div className="flex items-center gap-2 text-sm text-gray-500">
{getStandardEventIcon(event)}

<div className="text-black font-semibold">
<NodeLabel id={account_id} kind="CoreAccount" />
</div>

{STANDARD_EVENTS_MAPPING[event] && STANDARD_EVENTS_MAPPING[event](props)}
{account_id ? (
<div className="text-black font-semibold">
<NodeLabel id={account_id} kind="CoreAccount" />
</div>
) : (
"-"
)}

{!STANDARD_EVENTS_MAPPING[event] && event}
{(STANDARD_EVENTS_MAPPING[event] && STANDARD_EVENTS_MAPPING[event](props)) ?? event}
</div>
</div>
</>
Expand Down
80 changes: 80 additions & 0 deletions frontend/app/src/entities/events/ui/group-event.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { NodeLabel } from "@/entities/nodes/object/ui/node-label";
import { EventNodeInterface } from "@/shared/api/graphql/generated/graphql";
import { constructPath } from "@/shared/api/rest/fetch";
import { Link } from "@/shared/components/ui/link";
import { ReactElement } from "react";

export const GROUP_EVENTS_MAPPING: Record<string, (props: EventNodeInterface) => ReactElement> = {
"infrahub.group.member_added": ({ related_nodes, primary_node }) => {
return (
<div className="flex items-center gap-2">
added{" "}
<div className="flex items-center gap-1 text-black">
{related_nodes.slice(0, 5).map(({ id, kind }) => {
return (
<Link key={id} to={constructPath(`/objects/${kind}/${id}`)}>
<NodeLabel key={id} id={id} />
</Link>
);
})}
{related_nodes.slice(6).length > 0 && (
<span className="italic text-gray-500">(+{related_nodes.slice(6).length})</span>
)}
</div>{" "}
in group{" "}
<span className="text-black font-semibold">
<Link key={primary_node?.id} to={constructPath(`/objects/CoreGroup/${primary_node?.id}`)}>
<NodeLabel key={primary_node?.id} id={primary_node?.id} kind={primary_node?.kind} />
</Link>
</span>
</div>
);
},
"infrahub.group.member_removed": ({ related_nodes, primary_node }) => {
return (
<div className="flex items-center gap-2">
removed{" "}
<div className="flex items-center gap-1 text-black">
{related_nodes.slice(0, 5).map(({ id, kind }) => {
return (
<Link key={id} to={constructPath(`/objects/${kind}/${id}`)}>
<NodeLabel key={id} id={id} />
</Link>
);
})}
{related_nodes.slice(6).length > 0 && (
<span className="italic text-gray-500">(+{related_nodes.slice(6).length})</span>
)}
</div>{" "}
from group{" "}
<span className="text-black">
<Link key={primary_node?.id} to={constructPath(`/objects/CoreGroup/${primary_node?.id}`)}>
<NodeLabel key={primary_node?.id} id={primary_node?.id} kind={primary_node?.kind} />
</Link>
</span>
</div>
);
},
};

export const GroupEvent = (props: EventNodeInterface) => {
const { event, account_id } = props;

return (
<>
<div className="flex items-center justify-between">
<div className="flex items-center gap-2 text-sm">
<div className="font-semibold">
<NodeLabel id={account_id} />
</div>

<div className="text-gray-500">
{GROUP_EVENTS_MAPPING[event] && GROUP_EVENTS_MAPPING[event](props)}

{!GROUP_EVENTS_MAPPING[event] && event}
</div>
</div>
</div>
</>
);
};
Loading