Skip to content

Commit 4f1da94

Browse files
committed
Cleanup PipelineDetails
1 parent 9667e4b commit 4f1da94

File tree

7 files changed

+292
-286
lines changed

7 files changed

+292
-286
lines changed
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
import { useEffect, useState } from "react";
2+
3+
import { useValidationIssueNavigation } from "@/components/Editor/hooks/useValidationIssueNavigation";
4+
import { ContentBlock } from "@/components/shared/ContextPanel/Blocks/ContentBlock";
5+
import { ListBlock } from "@/components/shared/ContextPanel/Blocks/ListBlock";
6+
import { TextBlock } from "@/components/shared/ContextPanel/Blocks/TextBlock";
7+
import { CopyText } from "@/components/shared/CopyText/CopyText";
8+
import { TaskImplementation } from "@/components/shared/TaskDetails";
9+
import { BlockStack, InlineStack } from "@/components/ui/layout";
10+
import { useComponentSpec } from "@/providers/ComponentSpecProvider";
11+
import { getComponentFileFromList } from "@/utils/componentStore";
12+
import { USER_PIPELINES_LIST_NAME } from "@/utils/constants";
13+
14+
import PipelineIO from "../../shared/ArtifactsList/PipelineIO";
15+
import { PipelineValidationList } from "./PipelineValidationList";
16+
import RenamePipeline from "./RenamePipeline";
17+
18+
const PipelineDetails = () => {
19+
const {
20+
componentSpec,
21+
digest,
22+
isComponentTreeValid,
23+
globalValidationIssues,
24+
} = useComponentSpec();
25+
26+
const { handleIssueClick, groupedIssues } = useValidationIssueNavigation(
27+
globalValidationIssues,
28+
);
29+
30+
// State for file metadata
31+
const [fileMeta, setFileMeta] = useState<{
32+
creationTime?: Date;
33+
modificationTime?: Date;
34+
createdBy?: string;
35+
}>({});
36+
37+
// Fetch file metadata on mount or when componentSpec.name changes
38+
useEffect(() => {
39+
const fetchMeta = async () => {
40+
if (!componentSpec.name) return;
41+
const file = await getComponentFileFromList(
42+
USER_PIPELINES_LIST_NAME,
43+
componentSpec.name,
44+
);
45+
if (file) {
46+
setFileMeta({
47+
creationTime: file.creationTime,
48+
modificationTime: file.modificationTime,
49+
createdBy: file.componentRef.spec.metadata?.annotations?.author,
50+
});
51+
}
52+
};
53+
fetchMeta();
54+
}, [componentSpec.name]);
55+
56+
const metadata = [
57+
{
58+
label: "Created by",
59+
value: fileMeta.createdBy,
60+
},
61+
{
62+
label: "Created at",
63+
value: fileMeta.creationTime?.toLocaleString(),
64+
},
65+
{
66+
label: "Last updated",
67+
value: fileMeta.modificationTime?.toLocaleString(),
68+
},
69+
];
70+
71+
const annotations = Object.entries(
72+
componentSpec.metadata?.annotations || {},
73+
).map(([key, value]) => ({ label: key, value: String(value) }));
74+
75+
return (
76+
<BlockStack
77+
gap="4"
78+
className="h-full px-2"
79+
data-context-panel="pipeline-details"
80+
>
81+
<CopyText className="text-lg font-semibold">
82+
{componentSpec.name ?? "Unnamed Pipeline"}
83+
</CopyText>
84+
85+
<InlineStack gap="2">
86+
<RenamePipeline />
87+
<TaskImplementation
88+
displayName={componentSpec.name ?? "Pipeline"}
89+
componentSpec={componentSpec}
90+
showInlineContent={false}
91+
/>
92+
</InlineStack>
93+
94+
<ListBlock items={metadata} marker="none" />
95+
96+
{componentSpec.description && (
97+
<TextBlock title="Description" text={componentSpec.description} />
98+
)}
99+
100+
{digest && (
101+
<TextBlock
102+
title="Digest"
103+
text={digest}
104+
copyable
105+
className="bg-secondary p-2 rounded-md border"
106+
mono
107+
/>
108+
)}
109+
110+
{annotations.length > 0 && (
111+
<ListBlock title="Annotations" items={annotations} marker="none" />
112+
)}
113+
114+
<PipelineIO />
115+
116+
<ContentBlock title="Validations">
117+
<PipelineValidationList
118+
isComponentTreeValid={isComponentTreeValid}
119+
groupedIssues={groupedIssues}
120+
totalIssueCount={globalValidationIssues.length}
121+
onIssueSelect={handleIssueClick}
122+
/>
123+
</ContentBlock>
124+
</BlockStack>
125+
);
126+
};
127+
128+
export default PipelineDetails;

src/components/Editor/components/PipelineValidationList/PipelineValidationList.tsx renamed to src/components/Editor/Context/PipelineValidationList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { cn } from "@/lib/utils";
2020
import { pluralize } from "@/utils/string";
2121
import type { ComponentValidationIssue } from "@/utils/validations";
2222

23-
import type { ValidationIssueGroup } from "../../hooks/useValidationIssueNavigation";
23+
import type { ValidationIssueGroup } from "../hooks/useValidationIssueNavigation";
2424

2525
interface PipelineValidationListProps {
2626
isComponentTreeValid: boolean;
@@ -75,13 +75,13 @@ export const PipelineValidationList = ({
7575
title={`${totalIssueCount} ${pluralize(totalIssueCount, "issue")} detected`}
7676
>
7777
<Paragraph size="sm" className="mb-4">
78-
{" "}
7978
Select an item to jump to its location in the pipeline.
8079
</Paragraph>
8180

8281
<BlockStack gap="2">
8382
{groupedIssues.map((group) => {
8483
const isOpen = openGroups.has(group.pathKey);
84+
8585
return (
8686
<Collapsible
8787
key={group.pathKey}

src/components/Editor/RenamePipeline.tsx renamed to src/components/Editor/Context/RenamePipeline.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import { useLocation, useNavigate } from "@tanstack/react-router";
22
import { Edit3 } from "lucide-react";
33

44
import TooltipButton from "@/components/shared/Buttons/TooltipButton";
5+
import { PipelineNameDialog } from "@/components/shared/Dialogs";
56
import useToastNotification from "@/hooks/useToastNotification";
67
import { useComponentSpec } from "@/providers/ComponentSpecProvider";
78
import { APP_ROUTES } from "@/routes/router";
89
import { renameComponentFileInList } from "@/utils/componentStore";
910
import { USER_PIPELINES_LIST_NAME } from "@/utils/constants";
1011

11-
import { PipelineNameDialog } from "../shared/Dialogs";
12-
1312
const RenamePipeline = () => {
1413
const { componentSpec, saveComponentSpec } = useComponentSpec();
1514
const notify = useToastNotification();

0 commit comments

Comments
 (0)