Skip to content

Commit 8ab89de

Browse files
committed
Adds copy to other titles
1 parent c686853 commit 8ab89de

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

src/components/Editor/PipelineDetails.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useEffect, useState } from "react";
33

44
import { PipelineValidationList } from "@/components/Editor/components/PipelineValidationList/PipelineValidationList";
55
import { useValidationIssueNavigation } from "@/components/Editor/hooks/useValidationIssueNavigation";
6+
import { CopyText } from "@/components/shared/CopyText/CopyText";
67
import { Button } from "@/components/ui/button";
78
import { Icon } from "@/components/ui/icon";
89
import { InlineStack } from "@/components/ui/layout";
@@ -134,9 +135,9 @@ const PipelineDetails = () => {
134135
{/* Header */}
135136
<div className="flex items-center gap-2 max-w-[90%]">
136137
<Network className="w-6 h-6 text-secondary-foreground rotate-270 min-w-6 min-h-6" />
137-
<h2 className="text-lg font-semibold" data-testid="pipeline-name">
138+
<CopyText className="text-lg font-semibold" alwaysShowButton>
138139
{componentSpec.name ?? "Unnamed Pipeline"}
139-
</h2>
140+
</CopyText>
140141
<RenamePipeline />
141142
</div>
142143

src/components/PipelineRun/RunDetails.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Frown, Videotape } from "lucide-react";
22

3+
import { CopyText } from "@/components/shared/CopyText/CopyText";
34
import { Spinner } from "@/components/ui/spinner";
45
import { useCheckComponentSpecFromPath } from "@/hooks/useCheckComponentSpecFromPath";
56
import { useUserDetails } from "@/hooks/useUserDetails";
@@ -84,9 +85,9 @@ export const RunDetails = () => {
8485
<div className="p-2 flex flex-col gap-6 h-full">
8586
<div className="flex items-center gap-2 max-w-[90%]">
8687
<Videotape className="w-6 h-6 text-gray-500" />
87-
<h2 className="text-lg font-semibold">
88+
<CopyText className="text-lg font-semibold" alwaysShowButton>
8889
{componentSpec.name ?? "Unnamed Pipeline"}
89-
</h2>
90+
</CopyText>
9091
<StatusIcon status={runStatus} tooltip />
9192
</div>
9293

src/components/shared/CopyText/CopyText.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ interface CopyTextProps {
1414
children: string;
1515
className?: string;
1616
showButton?: boolean;
17+
alwaysShowButton?: boolean;
1718
}
1819

1920
export const CopyText = ({
2021
children,
2122
className,
2223
showButton = true,
24+
alwaysShowButton = false,
2325
}: CopyTextProps) => {
2426
const [isCopied, setIsCopied] = useState(false);
2527
const [isFlashing, setIsFlashing] = useState(false);
@@ -81,12 +83,17 @@ export const CopyText = ({
8183
variant="ghost"
8284
size="icon"
8385
className={cn(
84-
"h-6 w-6 shrink-0 opacity-0 transition-opacity group-hover:opacity-100",
85-
isCopied && "opacity-100",
86+
"h-6 w-6 shrink-0 transition-opacity duration-200",
87+
alwaysShowButton || isCopied
88+
? "opacity-100"
89+
: "opacity-0 group-hover:opacity-100",
8690
)}
8791
onClick={handleButtonClick}
8892
>
89-
<CopyIcon isCopied={isCopied} isHovered={isHovered} />
93+
<CopyIcon
94+
isCopied={isCopied}
95+
alwaysShow={alwaysShowButton || isHovered}
96+
/>
9097
</Button>
9198
)}
9299
</InlineStack>
@@ -96,10 +103,10 @@ export const CopyText = ({
96103

97104
interface CopyIconProps {
98105
isCopied: boolean;
99-
isHovered: boolean;
106+
alwaysShow: boolean;
100107
}
101108

102-
const CopyIcon = ({ isCopied, isHovered }: CopyIconProps) => (
109+
const CopyIcon = ({ isCopied, alwaysShow }: CopyIconProps) => (
103110
<span className="relative h-3.5 w-3.5">
104111
<Icon
105112
name="Check"
@@ -114,7 +121,7 @@ const CopyIcon = ({ isCopied, isHovered }: CopyIconProps) => (
114121
size="sm"
115122
className={cn(
116123
"absolute inset-0 text-muted-foreground transition-all duration-200",
117-
isHovered && !isCopied
124+
alwaysShow && !isCopied
118125
? "rotate-0 scale-100 opacity-100"
119126
: "rotate-90 scale-0 opacity-0",
120127
)}

0 commit comments

Comments
 (0)