Skip to content

Commit e8614bf

Browse files
authored
fix display label in other branches (#5952)
1 parent 62fed46 commit e8614bf

File tree

6 files changed

+47
-44
lines changed

6 files changed

+47
-44
lines changed

frontend/app/src/entities/events/ui/branch-events/branch-event-title.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ export const BRANCH_EVENTS_MAPPING: Record<string, (props: EventNodeInterface) =
3333
};
3434

3535
export const BranchEventTitle = (props: EventNodeInterface) => {
36-
const { event, account_id } = props;
36+
const { event, account_id, branch } = props;
3737

3838
return (
3939
<div className="flex items-center flex-wrap gap-2 text-sm">
40-
<NodeLabel id={account_id} />
40+
<NodeLabel id={account_id} kind="CoreAccount" branch={branch} />
4141

4242
{BRANCH_EVENTS_MAPPING[event] && BRANCH_EVENTS_MAPPING[event](props)}
4343
</div>

frontend/app/src/entities/events/ui/group-events/group-event-title.tsx

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,51 +5,67 @@ import { Link } from "@/shared/components/ui/link";
55
import { ReactElement } from "react";
66

77
export const GROUP_EVENTS_MAPPING: Record<string, (props: EventNodeInterface) => ReactElement> = {
8-
"infrahub.group.member_added": ({ related_nodes, primary_node }) => {
8+
"infrahub.group.member_added": (props) => {
99
return (
1010
<div className="flex flex-wrap items-center gap-1 whitespace-nowrap">
1111
added{" "}
1212
<div className="flex items-center gap-1 text-black">
13-
{related_nodes.slice(0, 5).map(({ id, kind }) => {
13+
{props.related_nodes.slice(0, 5).map(({ id, kind }) => {
1414
return (
1515
<Link key={id} to={constructPath(`/objects/${kind}/${id}`)}>
16-
<NodeLabel key={id} id={id} />
16+
<NodeLabel key={id} id={id} branch={props.branch} />
1717
</Link>
1818
);
1919
})}
20-
{related_nodes.slice(6).length > 0 && (
21-
<span className="italic text-gray-500">(+{related_nodes.slice(6).length})</span>
20+
{props.related_nodes.slice(6).length > 0 && (
21+
<span className="italic text-gray-500">(+{props.related_nodes.slice(6).length})</span>
2222
)}
2323
</div>{" "}
2424
in group{" "}
2525
<span className="text-black font-semibold">
26-
<Link key={primary_node?.id} to={constructPath(`/objects/CoreGroup/${primary_node?.id}`)}>
27-
<NodeLabel key={primary_node?.id} id={primary_node?.id} kind={primary_node?.kind} />
26+
<Link
27+
key={props.primary_node?.id}
28+
to={constructPath(`/objects/CoreGroup/${props.primary_node?.id}`)}
29+
>
30+
<NodeLabel
31+
key={props.primary_node?.id}
32+
id={props.primary_node?.id}
33+
kind={props.primary_node?.kind}
34+
branch={props.branch}
35+
/>
2836
</Link>
2937
</span>
3038
</div>
3139
);
3240
},
33-
"infrahub.group.member_removed": ({ related_nodes, primary_node }) => {
41+
"infrahub.group.member_removed": (props) => {
3442
return (
3543
<div className="flex flex-wrap items-center gap-1 whitespace-nowrap">
3644
removed{" "}
3745
<div className="flex items-center gap-1 text-black">
38-
{related_nodes.slice(0, 5).map(({ id, kind }) => {
46+
{props.related_nodes.slice(0, 5).map(({ id, kind }) => {
3947
return (
4048
<Link key={id} to={constructPath(`/objects/${kind}/${id}`)}>
41-
<NodeLabel key={id} id={id} />
49+
<NodeLabel key={id} id={id} branch={props.branch} />
4250
</Link>
4351
);
4452
})}
45-
{related_nodes.slice(6).length > 0 && (
46-
<span className="italic text-gray-500">(+{related_nodes.slice(6).length})</span>
53+
{props.related_nodes.slice(6).length > 0 && (
54+
<span className="italic text-gray-500">(+{props.related_nodes.slice(6).length})</span>
4755
)}
4856
</div>{" "}
4957
from group{" "}
5058
<span className="text-black">
51-
<Link key={primary_node?.id} to={constructPath(`/objects/CoreGroup/${primary_node?.id}`)}>
52-
<NodeLabel key={primary_node?.id} id={primary_node?.id} kind={primary_node?.kind} />
59+
<Link
60+
key={props.primary_node?.id}
61+
to={constructPath(`/objects/CoreGroup/${props.primary_node?.id}`)}
62+
>
63+
<NodeLabel
64+
key={props.primary_node?.id}
65+
id={props.primary_node?.id}
66+
kind={props.primary_node?.kind}
67+
branch={props.branch}
68+
/>
5369
</Link>
5470
</span>
5571
</div>
@@ -62,7 +78,7 @@ export const GroupEventTitle = (props: EventNodeInterface) => {
6278

6379
return (
6480
<div className="flex items-center flex-wrap gap-1 text-sm">
65-
<NodeLabel id={account_id} />
81+
<NodeLabel id={account_id} kind="CoreAccount" branch={props.branch} />
6682

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

frontend/app/src/entities/events/ui/node-events/node-event-title.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const NodeEventTitle = ({
4141

4242
return (
4343
<div className="flex flex-wrap items-center gap-1 text-sm">
44-
<NodeLabel id={account_id} />
44+
<NodeLabel id={account_id} kind="CoreAccount" branch={branch} />
4545
<span className="text-gray-600 whitespace-nowrap">{NODE_EVENTS_MAPPING[event] ?? event}</span>
4646
<div className="text-gray-600 whitespace-nowrap">
4747
{schemaLabels[payload.data.node_kind] ?? "-"}
@@ -50,6 +50,7 @@ export const NodeEventTitle = ({
5050
<NodeLabel
5151
id={primary_node.id}
5252
kind={primary_node?.kind}
53+
branch={branch}
5354
className="overflow-hidden text-ellipsis whitespace-nowrap"
5455
/>
5556
) : (
@@ -64,6 +65,7 @@ export const NodeEventTitle = ({
6465
<NodeLabel
6566
id={primary_node.id}
6667
kind={primary_node?.kind}
68+
branch={branch}
6769
className="overflow-hidden text-ellipsis whitespace-nowrap"
6870
/>
6971
</Link>

frontend/app/src/entities/events/ui/standard-events/standard-event-title.tsx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,6 @@ export const STANDARD_EVENTS_MAPPING: Record<string, (props: EventNodeInterface)
1010
"infrahub.schema.update": () => {
1111
return <div className="flex flex-wrap items-center gap-2">updated the schema</div>;
1212
},
13-
"infrahub.branch.create": (props) => {
14-
return (
15-
<div className="flex flex-wrap items-center gap-2">
16-
merged the branch
17-
<Link to={`/branches/${props.payload?.context?.branch?.name}`} className="text-black">
18-
{props.payload?.context?.branch?.name}
19-
</Link>
20-
</div>
21-
);
22-
},
23-
"infrahub.branch.merged": (props) => {
24-
return (
25-
<div className="flex flex-wrap items-center gap-2">
26-
merged the branch
27-
<Link to={`/branches/${props.payload?.context?.branch?.name}`} className="text-black">
28-
{props.payload?.context?.branch?.name}
29-
</Link>
30-
</div>
31-
);
32-
},
3313
"infrahub.repository.update_commit": (props) => {
3414
return (
3515
<div className="flex flex-wrap items-center gap-2">
@@ -50,11 +30,11 @@ export const STANDARD_EVENTS_MAPPING: Record<string, (props: EventNodeInterface)
5030
};
5131

5232
export const StandardEventTitle = (props: EventNodeInterface) => {
53-
const { event, account_id } = props;
33+
const { event, account_id, branch } = props;
5434

5535
return (
5636
<div className="flex items-center flex-wrap gap-1 text-sm">
57-
<NodeLabel id={account_id} />
37+
<NodeLabel id={account_id} kind="CoreAccount" branch={branch} />
5838

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

frontend/app/src/entities/nodes/object/api/get-display-label.query.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import { queryOptions, useQuery } from "@tanstack/react-query";
55
import { useAtomValue } from "jotai";
66
import { getNodeLabelFromApi } from "./get-display-label";
77

8-
type NodeLabelProps = { objectid?: string; kind: string; enabled?: boolean; branch?: string };
8+
type NodeLabelProps = {
9+
objectid?: string;
10+
kind: string;
11+
enabled?: boolean;
12+
branch?: string | null;
13+
};
914

1015
export function getNodeLabelQueryOptions({
1116
objectid,

frontend/app/src/entities/nodes/object/ui/node-label.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { useNodeLabel } from "../api/get-display-label.query";
66
type NodeLabelProps = {
77
id?: string;
88
kind?: string;
9-
branch?: string;
9+
branch?: string | null;
1010
className?: string;
1111
};
1212

1313
export const NodeLabel = ({ id, kind = NODE_OBJECT, branch, className }: NodeLabelProps) => {
14-
const { isLoading, error, data } = useNodeLabel({ objectid: id, kind, enabled: !!id, branch });
14+
const { isPending, error, data } = useNodeLabel({ objectid: id, kind, enabled: !!id, branch });
1515

16-
if (isLoading) {
16+
if (isPending) {
1717
return <Skeleton className="h-3 w-14" />;
1818
}
1919

0 commit comments

Comments
 (0)