Skip to content

Commit ceb7ba3

Browse files
committed
Cleanup PipelineDetails
1 parent f1fefa5 commit ceb7ba3

File tree

10 files changed

+406
-311
lines changed

10 files changed

+406
-311
lines changed

src/components/Editor/PipelineDetails.tsx

Lines changed: 172 additions & 180 deletions
Large diffs are not rendered by default.

src/components/shared/TaskDetails/Blocks/ActionBlock.tsx renamed to src/components/shared/ContextPanel/Blocks/ActionBlock.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { downloadYamlFromComponentText } from "@/utils/URL";
99
import copyToYaml from "@/utils/yaml";
1010

1111
import TooltipButton from "../../Buttons/TooltipButton";
12-
import { blockBaseClass } from "./shared";
1312

1413
interface ActionBlockProps {
1514
displayName: string;
@@ -18,6 +17,7 @@ interface ActionBlockProps {
1817
onDelete?: () => void;
1918
hasDeletionConfirmation?: boolean;
2019
readOnly?: boolean;
20+
className?: string;
2121
}
2222

2323
const ActionBlock = ({
@@ -27,6 +27,7 @@ const ActionBlock = ({
2727
onDelete,
2828
hasDeletionConfirmation = true,
2929
readOnly = false,
30+
className,
3031
}: ActionBlockProps) => {
3132
const notify = useToastNotification();
3233
const [confirmDelete, setConfirmDelete] = useState(false);
@@ -74,7 +75,7 @@ const ActionBlock = ({
7475
}, [onDelete, confirmDelete, hasDeletionConfirmation, notify]);
7576

7677
return (
77-
<InlineStack gap="2" className={blockBaseClass}>
78+
<InlineStack gap="2" className={className}>
7879
<TooltipButton
7980
variant="outline"
8081
tooltip="Download YAML"

src/components/shared/TaskDetails/Blocks/ContentBlock.tsx renamed to src/components/shared/ContextPanel/Blocks/ContentBlock.tsx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,34 +10,35 @@ import { Icon } from "@/components/ui/icon";
1010
import { BlockStack, InlineStack } from "@/components/ui/layout";
1111
import { Heading } from "@/components/ui/typography";
1212

13-
import { blockBaseClass } from "./shared";
14-
1513
type ContentBlockProps =
1614
| {
1715
title: string;
18-
content?: ReactNode;
16+
children?: ReactNode;
1917
collapsible?: false;
2018
defaultOpen?: never;
19+
className?: string;
2120
}
2221
| {
2322
title: string;
24-
content?: ReactNode;
23+
children?: ReactNode;
2524
collapsible: true;
2625
defaultOpen?: boolean;
26+
className?: string;
2727
};
2828

2929
export const ContentBlock = ({
3030
title,
31-
content,
31+
children,
3232
collapsible,
3333
defaultOpen = false,
34+
className,
3435
}: ContentBlockProps) => {
35-
if (!content) {
36+
if (!children) {
3637
return null;
3738
}
3839

3940
return (
40-
<BlockStack className={blockBaseClass}>
41+
<BlockStack className={className}>
4142
<Collapsible className="w-full" defaultOpen={defaultOpen}>
4243
<InlineStack blockAlign="center" gap="1">
4344
<Heading level={3}>{title}</Heading>
@@ -53,10 +54,10 @@ export const ContentBlock = ({
5354

5455
{collapsible ? (
5556
<CollapsibleContent className="w-full mt-1">
56-
{content}
57+
{children}
5758
</CollapsibleContent>
5859
) : (
59-
content
60+
children
6061
)}
6162
</Collapsible>
6263
</BlockStack>

src/components/shared/TaskDetails/Blocks/LinkBlock.tsx renamed to src/components/shared/ContextPanel/Blocks/LinkBlock.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import { Link } from "@/components/ui/link";
44
import { Heading, Paragraph } from "@/components/ui/typography";
55
import { convertGithubUrlToDirectoryUrl, isGithubUrl } from "@/utils/URL";
66

7-
import { blockBaseClass } from "./shared";
8-
97
export function LinkBlock({
108
url,
119
canonicalUrl,
10+
className,
1211
}: {
1312
url?: string;
1413
canonicalUrl?: string;
14+
className?: string;
1515
}) {
1616
if (!url && !canonicalUrl) return null;
1717

1818
return (
19-
<BlockStack className={blockBaseClass}>
19+
<BlockStack className={className}>
2020
<Heading level={3}>URL</Heading>
2121
{url && (
2222
<>
@@ -40,7 +40,12 @@ export function LinkBlock({
4040
);
4141
}
4242

43-
export const URLBlock = ({ href, text }: { href?: string; text: string }) => (
43+
export type URLBlockProps = {
44+
href?: string;
45+
text: string;
46+
};
47+
48+
export const URLBlock = ({ href, text }: URLBlockProps) => (
4449
<InlineStack blockAlign="center" gap="1">
4550
<Link href={href} target="_blank" rel="noopener noreferrer">
4651
<Paragraph size="xs" className="text-sky-500 hover:underline">
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import { BlockStack, InlineStack } from "@/components/ui/layout";
2+
import { Heading, Paragraph } from "@/components/ui/typography";
3+
4+
import { URLBlock, type URLBlockProps } from "./LinkBlock";
5+
6+
export interface ListBlockItemProps {
7+
name?: string;
8+
value?: string | URLBlockProps;
9+
critical?: boolean;
10+
}
11+
12+
interface ListBlockProps {
13+
title?: string;
14+
items: ListBlockItemProps[];
15+
marker?: "bullet" | "number" | "none";
16+
className?: string;
17+
}
18+
19+
export const ListBlock = ({
20+
title,
21+
items,
22+
marker = "bullet",
23+
className,
24+
}: ListBlockProps) => {
25+
const listElement = marker === "number" ? "ol" : "ul";
26+
27+
const getListStyle = () => {
28+
switch (marker) {
29+
case "bullet":
30+
return "pl-5 list-disc";
31+
case "number":
32+
return "pl-5 list-decimal";
33+
case "none":
34+
return "list-none";
35+
default:
36+
return "pl-5 list-disc";
37+
}
38+
};
39+
40+
return (
41+
<BlockStack className={className}>
42+
{title && <Heading level={3}>{title}</Heading>}
43+
<BlockStack as={listElement} gap="1" className={getListStyle()}>
44+
{items.map((item, index) => {
45+
if (!item.value) {
46+
return null;
47+
}
48+
49+
return (
50+
<li key={index} className="w-full">
51+
<ListBlockItem
52+
name={item.name}
53+
value={item.value}
54+
critical={item.critical}
55+
/>
56+
</li>
57+
);
58+
})}
59+
</BlockStack>
60+
</BlockStack>
61+
);
62+
};
63+
64+
const ListBlockItem = ({ name, value, critical }: ListBlockItemProps) => {
65+
if (!value) {
66+
return null;
67+
}
68+
69+
return (
70+
<InlineStack gap="2" blockAlign="center" wrap="nowrap">
71+
{name && (
72+
<Paragraph size="xs" tone={critical ? "critical" : "inherit"}>
73+
{name}:
74+
</Paragraph>
75+
)}
76+
{isURL(value) ? (
77+
<URLBlock href={value.href} text={value.text} />
78+
) : (
79+
<Paragraph
80+
size="xs"
81+
tone={critical ? "critical" : "subdued"}
82+
className="truncate"
83+
>
84+
{value}
85+
</Paragraph>
86+
)}
87+
</InlineStack>
88+
);
89+
};
90+
91+
const isURL = (val: string | URLBlockProps): val is URLBlockProps => {
92+
return typeof val === "object" && val !== null && "href" in val;
93+
};

src/components/shared/TaskDetails/Blocks/TextBlock.tsx renamed to src/components/shared/ContextPanel/Blocks/TextBlock.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,20 @@ import { Heading, Paragraph } from "@/components/ui/typography";
1717
import { useCopyToClipboard } from "@/hooks/useCopyToClip";
1818
import { cn } from "@/lib/utils";
1919

20-
import { blockBaseClass } from "./shared";
21-
2220
interface TextBlockProps {
2321
title: string;
2422
text?: string;
2523
allowCopy?: boolean;
2624
collapsible?: boolean;
25+
className?: string;
2726
}
2827

2928
export const TextBlock = ({
3029
title,
3130
text,
3231
allowCopy,
3332
collapsible,
33+
className,
3434
}: TextBlockProps) => {
3535
const { isCopied, isTooltipOpen, handleCopy, handleTooltipOpen } =
3636
useCopyToClipboard(text);
@@ -80,7 +80,7 @@ export const TextBlock = ({
8080
}
8181

8282
return (
83-
<BlockStack className={blockBaseClass}>
83+
<BlockStack className={className}>
8484
<Collapsible className="w-full">
8585
<InlineStack blockAlign="center" gap="1">
8686
<Heading level={3}>{title}</Heading>

0 commit comments

Comments
 (0)