Skip to content

Commit 6581b3a

Browse files
committed
feat_favorites_toggle_ui
1 parent 2aba91b commit 6581b3a

5 files changed

Lines changed: 80 additions & 14 deletions

File tree

src/components/Editor/Context/PipelineDetails.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ContentBlock } from "@/components/shared/ContextPanel/Blocks/ContentBlo
77
import { KeyValueList } from "@/components/shared/ContextPanel/Blocks/KeyValueList";
88
import { TextBlock } from "@/components/shared/ContextPanel/Blocks/TextBlock";
99
import { CopyText } from "@/components/shared/CopyText/CopyText";
10+
import { FavoriteToggle } from "@/components/shared/FavoriteToggle";
1011
import { PipelineDescription } from "@/components/shared/PipelineDescription/PipelineDescription";
1112
import { PipelineRunNameTemplateEditor } from "@/components/shared/PipelineRunNameTemplate/PipelineRunNameTemplateEditor";
1213
import { useFlagValue } from "@/components/shared/Settings/useFlags";
@@ -102,6 +103,16 @@ const PipelineDetails = () => {
102103
const actions = [
103104
<RenamePipeline key="rename-pipeline-action" />,
104105
<ViewYamlButton key="view-pipeline-yaml" componentSpec={componentSpec} />,
106+
...(componentSpec.name
107+
? [
108+
<FavoriteToggle
109+
key="favorite-pipeline"
110+
type="pipeline"
111+
id={componentSpec.name}
112+
name={componentSpec.name}
113+
/>,
114+
]
115+
: []),
105116
];
106117

107118
return (

src/components/Home/PipelineSection/PipelineRow.tsx

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useNavigate } from "@tanstack/react-router";
22
import { type MouseEvent } from "react";
33

44
import { ConfirmationDialog } from "@/components/shared/Dialogs";
5+
import { FavoriteToggle } from "@/components/shared/FavoriteToggle";
56
import { HighlightText } from "@/components/shared/HighlightText";
67
import { PipelineRunInfoCondensed } from "@/components/shared/PipelineRunDisplay/PipelineRunInfoCondensed";
78
import { PipelineRunsList } from "@/components/shared/PipelineRunDisplay/PipelineRunsList";
@@ -161,20 +162,23 @@ const PipelineRow = withSuspenseWrapper(
161162
{name && <PipelineRunsButton pipelineName={name} />}
162163
</TableCell>
163164
<TableCell className="w-0">
164-
<ConfirmationDialog
165-
trigger={
166-
<Button
167-
variant="ghost"
168-
size="icon"
169-
className="opacity-0 group-hover:opacity-100 cursor-pointer text-destructive-foreground hover:text-destructive-foreground"
170-
>
171-
<Icon name="Trash" />
172-
</Button>
173-
}
174-
title={`Delete pipeline "${name}"?`}
175-
description="Are you sure you want to delete this pipeline? Existing pipeline runs will not be impacted. This action cannot be undone."
176-
onConfirm={confirmPipelineDelete}
177-
/>
165+
<InlineStack gap="1" blockAlign="center">
166+
{name && <FavoriteToggle type="pipeline" id={name} name={name} />}
167+
<ConfirmationDialog
168+
trigger={
169+
<Button
170+
variant="ghost"
171+
size="icon"
172+
className="opacity-0 group-hover:opacity-100 cursor-pointer text-destructive-foreground hover:text-destructive-foreground"
173+
>
174+
<Icon name="Trash" />
175+
</Button>
176+
}
177+
title={`Delete pipeline "${name}"?`}
178+
description="Are you sure you want to delete this pipeline? Existing pipeline runs will not be impacted. This action cannot be undone."
179+
onConfirm={confirmPipelineDelete}
180+
/>
181+
</InlineStack>
178182
</TableCell>
179183
</TableRow>
180184
);

src/components/Home/RunSection/RunRow.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useNavigate } from "@tanstack/react-router";
33
import { type MouseEvent } from "react";
44

55
import type { PipelineRunResponse } from "@/api/types.gen";
6+
import { FavoriteToggle } from "@/components/shared/FavoriteToggle";
67
import { StatusBar, StatusIcon } from "@/components/shared/Status";
78
import { TagList } from "@/components/shared/Tags/TagList";
89
import { Button } from "@/components/ui/button";
@@ -120,6 +121,9 @@ const RunRow = ({ run }: { run: PipelineRunResponse }) => {
120121
<TableCell className="max-w-64">
121122
{tags && tags.length > 0 && <TagList tags={tags} />}
122123
</TableCell>
124+
<TableCell className="w-0">
125+
<FavoriteToggle type="run" id={runId} name={name} />
126+
</TableCell>
123127
</TableRow>
124128
);
125129
};

src/components/PipelineRun/RunToolbar.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { FavoriteToggle } from "@/components/shared/FavoriteToggle";
12
import { InlineStack } from "@/components/ui/layout";
23
import { useCheckComponentSpecFromPath } from "@/hooks/useCheckComponentSpecFromPath";
34
import { useUserDetails } from "@/hooks/useUserDetails";
@@ -66,6 +67,9 @@ export const RunToolbar = () => {
6667
isViewingSubgraph ? "top-23" : "top-14",
6768
)}
6869
>
70+
{runId && pipelineName && (
71+
<FavoriteToggle type="run" id={runId} name={pipelineName} />
72+
)}
6973
<ViewYamlButton componentSpec={componentSpec} displayLabel="View" />
7074

7175
{canAccessEditorSpec && pipelineName && (
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { Star } from "lucide-react";
2+
import { type MouseEvent,useCallback } from "react";
3+
4+
import { Button } from "@/components/ui/button";
5+
import { type FavoriteType, useFavorites } from "@/hooks/useFavorites";
6+
import { cn } from "@/lib/utils";
7+
8+
interface FavoriteToggleProps {
9+
type: FavoriteType;
10+
id: string;
11+
name: string;
12+
}
13+
14+
export const FavoriteToggle = ({ type, id, name }: FavoriteToggleProps) => {
15+
const { isFavorite, toggleFavorite } = useFavorites();
16+
const active = isFavorite(type, id);
17+
18+
const handleClick = useCallback(
19+
(e: MouseEvent) => {
20+
e.stopPropagation();
21+
toggleFavorite({ type, id, name });
22+
},
23+
[type, id, name, toggleFavorite],
24+
);
25+
26+
return (
27+
<Button
28+
onClick={handleClick}
29+
data-testid="favorite-toggle"
30+
className={cn(
31+
"w-fit h-fit p-1 hover:text-warning",
32+
active ? "text-warning" : "text-gray-500/50",
33+
)}
34+
variant="ghost"
35+
size="icon"
36+
>
37+
<Star
38+
className="h-4 w-4"
39+
fill={active ? "oklch(79.5% 0.184 86.047)" : "none"}
40+
/>
41+
</Button>
42+
);
43+
};

0 commit comments

Comments
 (0)