Skip to content

Commit e8dfb04

Browse files
committed
feat: User Notes on Pipelines
1 parent 4807921 commit e8dfb04

4 files changed

Lines changed: 87 additions & 16 deletions

File tree

src/components/Editor/Context/PipelineDetails.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ import { useFlagValue } from "@/components/shared/Settings/useFlags";
1313
import { BlockStack } from "@/components/ui/layout";
1414
import useToastNotification from "@/hooks/useToastNotification";
1515
import { useComponentSpec } from "@/providers/ComponentSpecProvider";
16+
import { PIPELINE_NOTES_ANNOTATION } from "@/utils/annotations";
1617
import { getComponentFileFromList } from "@/utils/componentStore";
1718
import { USER_PIPELINES_LIST_NAME } from "@/utils/constants";
1819

1920
import PipelineIO from "../../shared/Execution/PipelineIO";
21+
import { PipelineNotesEditor } from "./PipelineNotesEditor";
2022
import { PipelineValidationList } from "./PipelineValidationList";
2123
import RenamePipeline from "./RenamePipeline";
2224

25+
const EXCLUDED_ANNOTATIONS = [PIPELINE_NOTES_ANNOTATION];
26+
2327
const PipelineDetails = () => {
2428
const notify = useToastNotification();
2529
const { componentSpec, digest, globalValidationIssues } = useComponentSpec();
@@ -79,12 +83,12 @@ const PipelineDetails = () => {
7983
},
8084
];
8185

82-
const annotations = Object.entries(
83-
componentSpec.metadata?.annotations || {},
84-
).map(([key, value]) => ({
85-
label: key,
86-
value: String(value),
87-
}));
86+
const annotations = Object.entries(componentSpec.metadata?.annotations || {})
87+
.filter(([key]) => !EXCLUDED_ANNOTATIONS.includes(key))
88+
.map(([key, value]) => ({
89+
label: key,
90+
value: String(value),
91+
}));
8892

8993
const actions = [
9094
<RenamePipeline key="rename-pipeline-action" />,
@@ -136,6 +140,10 @@ const PipelineDetails = () => {
136140
onIssueSelect={handleIssueClick}
137141
/>
138142
</ContentBlock>
143+
144+
<ContentBlock title="Notes">
145+
<PipelineNotesEditor />
146+
</ContentBlock>
139147
</BlockStack>
140148
);
141149
};
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { useState } from "react";
2+
3+
import { Textarea } from "@/components/ui/textarea";
4+
import { useComponentSpec } from "@/providers/ComponentSpecProvider";
5+
import {
6+
getAnnotationValue,
7+
PIPELINE_NOTES_ANNOTATION,
8+
} from "@/utils/annotations";
9+
10+
export const PipelineNotesEditor = () => {
11+
const { componentSpec, setComponentSpec } = useComponentSpec();
12+
13+
const annotations = componentSpec.metadata?.annotations;
14+
const notes =
15+
getAnnotationValue(annotations, PIPELINE_NOTES_ANNOTATION) ?? "";
16+
17+
const [value, setValue] = useState(notes);
18+
19+
const onInputChange = (value: string) => {
20+
setValue(value);
21+
};
22+
23+
const onBlur = () => {
24+
setComponentSpec({
25+
...componentSpec,
26+
metadata: {
27+
...componentSpec.metadata,
28+
annotations: {
29+
...annotations,
30+
[PIPELINE_NOTES_ANNOTATION]: value,
31+
},
32+
},
33+
});
34+
};
35+
36+
return (
37+
<Textarea
38+
value={value}
39+
onChange={(e) => onInputChange(e.target.value)}
40+
onBlur={onBlur}
41+
placeholder="Share context about this pipeline..."
42+
className="text-xs"
43+
/>
44+
);
45+
};

src/components/PipelineRun/RunDetails.tsx

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ import { InfoBox } from "@/components/shared/InfoBox";
77
import { LoadingScreen } from "@/components/shared/LoadingScreen";
88
import { StatusBar } from "@/components/shared/Status";
99
import { BlockStack, InlineStack } from "@/components/ui/layout";
10-
import { Text } from "@/components/ui/typography";
10+
import { Paragraph, Text } from "@/components/ui/typography";
1111
import { useBackend } from "@/providers/BackendProvider";
1212
import { useComponentSpec } from "@/providers/ComponentSpecProvider";
1313
import { useExecutionData } from "@/providers/ExecutionDataProvider";
14+
import {
15+
getAnnotationValue,
16+
PIPELINE_NOTES_ANNOTATION,
17+
} from "@/utils/annotations";
1418
import {
1519
flattenExecutionStatusStats,
1620
getExecutionStatusLabel,
1721
getOverallExecutionStatusFromStats,
1822
} from "@/utils/executionStatus";
1923

24+
const EXCLUDED_ANNOTATIONS = [PIPELINE_NOTES_ANNOTATION];
25+
2026
export const RunDetails = () => {
2127
const { configured } = useBackend();
2228
const { componentSpec } = useComponentSpec();
@@ -60,7 +66,15 @@ export const RunDetails = () => {
6066
getOverallExecutionStatusFromStats(executionStatusStats);
6167
const statusLabel = getExecutionStatusLabel(overallStatus);
6268

63-
const annotations = componentSpec.metadata?.annotations || {};
69+
const pipelineAnnotations = componentSpec.metadata?.annotations || {};
70+
const pipelineNotes = getAnnotationValue(
71+
pipelineAnnotations,
72+
PIPELINE_NOTES_ANNOTATION,
73+
);
74+
75+
const displayedAnnotations = Object.entries(pipelineAnnotations)
76+
.filter(([key]) => !EXCLUDED_ANNOTATIONS.includes(key))
77+
.map(([key, value]) => ({ label: key, value: String(value) }));
6478

6579
return (
6680
<BlockStack gap="6" className="p-2 h-full">
@@ -98,17 +112,20 @@ export const RunDetails = () => {
98112
<StatusBar executionStatusStats={executionStatusStats} />
99113
</ContentBlock>
100114

101-
{Object.keys(annotations).length > 0 && (
102-
<KeyValueList
103-
title="Annotations"
104-
items={Object.entries(annotations).map(([key, value]) => ({
105-
label: key,
106-
value: String(value),
107-
}))}
108-
/>
115+
{displayedAnnotations.length > 0 && (
116+
<KeyValueList title="Annotations" items={displayedAnnotations} />
109117
)}
110118

111119
<PipelineIO taskArguments={details.task_spec.arguments} />
120+
121+
<ContentBlock title="Notes">
122+
<BlockStack>
123+
<Paragraph size="xs">Pipeline Notes</Paragraph>
124+
<Paragraph size="xs" tone="subdued">
125+
{pipelineNotes || "No notes available for this pipeline."}
126+
</Paragraph>
127+
</BlockStack>
128+
</ContentBlock>
112129
</BlockStack>
113130
);
114131
};

src/utils/annotations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,4 @@ function hasAnnotation(
5252

5353
export const DISPLAY_NAME_MAX_LENGTH = 100;
5454
export const TASK_DISPLAY_NAME_ANNOTATION = "display_name";
55+
export const PIPELINE_NOTES_ANNOTATION = "notes";

0 commit comments

Comments
 (0)