Skip to content

Commit cdd5672

Browse files
committed
Cleanup PipelineDetails
1 parent de10ea2 commit cdd5672

File tree

7 files changed

+296
-286
lines changed

7 files changed

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