Skip to content

Commit 9be0e6c

Browse files
committed
implement content for node of audit file view
1 parent 71ee53b commit 9be0e6c

18 files changed

+359
-296
lines changed
File renamed without changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Badge, BadgeProps } from "@radix-ui/themes";
2+
import { useEffect, useState } from "react";
3+
4+
export default function InstanceTypeBadge(props: { type: string }) {
5+
const [color, setColor] = useState<BadgeProps["color"]>("gray");
6+
7+
useEffect(() => {
8+
switch (props.type.toLowerCase()) {
9+
case "class":
10+
setColor("green");
11+
break;
12+
case "function":
13+
setColor("blue");
14+
break;
15+
case "assignement":
16+
setColor("gray");
17+
break;
18+
default:
19+
setColor("gray");
20+
break;
21+
}
22+
}, [props.type]);
23+
24+
return (
25+
<Badge color={color} variant="solid" radius="full" size="1">
26+
{props.type}
27+
</Badge>
28+
);
29+
}
File renamed without changes.

packages/app/src/components/ReactFlow/AuditTree/AuditFileNode.tsx

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Button, Tooltip } from "@radix-ui/themes";
22
import { Handle, Node, NodeProps, Position } from "@xyflow/react";
33
import { Link } from "react-router";
44
import { AuditFile } from "../../../service/api/types";
5+
import { defaultMaxPathLength, getDisplayedPath } from "../../../helpers";
56

67
export default function AuditFileNode(
78
props: NodeProps<
@@ -13,16 +14,6 @@ export default function AuditFileNode(
1314
>
1415
>,
1516
) {
16-
const maxPathLength = 25;
17-
18-
function getDisplayedPath(path: string) {
19-
if (path.length > maxPathLength) {
20-
return `...${path.slice(-maxPathLength)}`;
21-
}
22-
23-
return path;
24-
}
25-
2617
function getWarnings() {
2718
const warnings: string[] = [];
2819

@@ -173,9 +164,9 @@ export default function AuditFileNode(
173164
to={encodeURIComponent(props.data.path)}
174165
className="text-center p-5"
175166
>
176-
{props.data.path.length > maxPathLength ? (
167+
{props.data.path.length > defaultMaxPathLength ? (
177168
<Tooltip content={props.data.path}>
178-
<div>{getDisplayedPath(props.data.path)}</div>
169+
<div>{getDisplayedPath(props.data.path, defaultMaxPathLength)}</div>
179170
</Tooltip>
180171
) : (
181172
props.data.path
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { Handle, Node, NodeProps, Position } from "@xyflow/react";
2+
3+
export default function ContainerFileNode(
4+
props: NodeProps<
5+
Node<
6+
{ fileName: string; isBeingDragged: boolean } & Record<string, unknown>
7+
>
8+
>,
9+
) {
10+
const className = [
11+
"bg-transparent",
12+
"rounded-xl border border-background-light dark:border-background-dark",
13+
`${props.data.isBeingDragged && "bg-blue-100 dark:bg-blue-900 shadow-lg"}`,
14+
].join(" ");
15+
16+
return (
17+
<div
18+
className={className}
19+
style={{
20+
width: props.width,
21+
height: props.height,
22+
zIndex: props.zIndex,
23+
}}
24+
>
25+
<Handle
26+
type="target"
27+
position={props.targetPosition || Position.Top}
28+
isConnectable={props.isConnectable}
29+
className="border-0 bg-transparent"
30+
/>
31+
32+
<Handle
33+
type="source"
34+
position={props.sourcePosition || Position.Bottom}
35+
isConnectable={props.isConnectable}
36+
className="border-0 bg-transparent"
37+
/>
38+
</div>
39+
);
40+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Handle, Node, NodeProps, Position } from "@xyflow/react";
2+
3+
export default function ContainerReferencesNode(
4+
props: NodeProps<
5+
Node<
6+
{
7+
containerType: "dependents" | "dependencies";
8+
isBeingDragged: boolean;
9+
} & Record<string, unknown>
10+
>
11+
>,
12+
) {
13+
const className = [
14+
`${props.data.containerType === "dependencies" ? "bg-primary-light/10 dark:bg-primary-dark/30" : "bg-secondary-light/10 dark:bg-secondary-dark/30"}`,
15+
"rounded-xl border border-border-light dark:border-border-dark",
16+
`${props.data.isBeingDragged && "bg-blue-100 dark:bg-blue-900 shadow-lg"}`,
17+
].join(" ");
18+
19+
return (
20+
<div
21+
className={className}
22+
style={{
23+
width: props.width,
24+
height: props.height,
25+
zIndex: props.zIndex,
26+
}}
27+
>
28+
<Handle
29+
type="target"
30+
position={props.targetPosition || Position.Top}
31+
isConnectable={props.isConnectable}
32+
className="border-0 bg-transparent"
33+
/>
34+
35+
<Handle
36+
type="source"
37+
position={props.sourcePosition || Position.Bottom}
38+
isConnectable={props.isConnectable}
39+
className="border-0 bg-transparent"
40+
/>
41+
</div>
42+
);
43+
}

packages/app/src/components/ReactFlow/AuditTree/CurrentFileGroupNode.tsx

Lines changed: 0 additions & 42 deletions
This file was deleted.

packages/app/src/components/ReactFlow/AuditTree/CurrentInstanceNode.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

packages/app/src/components/ReactFlow/AuditTree/DependencyFileGroupNode.tsx

Lines changed: 0 additions & 42 deletions
This file was deleted.

packages/app/src/components/ReactFlow/AuditTree/DependencyInstanceNode.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)