Skip to content

Commit 1bcf398

Browse files
authored
Add Info Dialog to Task Details Header (#1210)
## Description <!-- Please provide a brief description of the changes made in this pull request. Include any relevant context or reasoning for the changes. --> Adds the "Task Definition" info icon to the task details panel, next to the header. The "delete from component library" trash can has been removed and the functionality can now be accessed from within the dialog (it was confusing to have two trash can icons in the same view). Also changed the "Delete definition" icon to not be a trash can. ## Related Issue and Pull requests <!-- Link to any related issues using the format #<issue-number> --> Closes Shopify/oasis-frontend#265 ## Type of Change <!-- Please delete options that are not relevant --> - [x] Improvement ## Checklist <!-- Please ensure the following are completed before submitting the PR --> - [ ] I have tested this does not break current pipelines / runs functionality - [ ] I have tested the changes on staging ## Screenshots (if applicable) <!-- Include any screenshots that might help explain the changes or provide visual context --> ![image.png](https://app.graphite.dev/user-attachments/assets/ebf8c46f-ccca-4bbf-add2-7282b3c78563.png) ![image.png](https://app.graphite.dev/user-attachments/assets/5b1c0ff8-2056-4bdc-9ae4-36292c57c2a5.png) ## Test Instructions <!-- Detail steps and prerequisites for testing the changes in this PR --> - Can open info dialog from task details header - Can remove a component definition from within the info dialog and no longer from the task details pane - All else works as expected and css/layout is not broken anywhere ## Additional Comments <!-- Add any additional context or information that reviewers might need to know regarding this PR -->
1 parent 2cb4a25 commit 1bcf398

File tree

3 files changed

+52
-28
lines changed

3 files changed

+52
-28
lines changed

src/components/shared/Dialogs/ComponentDetailsDialog.tsx

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type { ComponentReference } from "@/utils/componentSpec";
1919
import InfoIconButton from "../Buttons/InfoIconButton";
2020
import TooltipButton from "../Buttons/TooltipButton";
2121
import { ComponentEditorDialog } from "../ComponentEditor/ComponentEditorDialog";
22+
import { ComponentFavoriteToggle } from "../FavoriteComponentToggle";
2223
import { InfoBox } from "../InfoBox";
2324
import { PublishComponent } from "../ManageComponent/PublishComponent";
2425
import { PublishedComponentDetails } from "../ManageComponent/PublishedComponentDetails";
@@ -184,12 +185,7 @@ const ComponentDetails = ({
184185
const [open, setOpen] = useState(false);
185186
const dialogTriggerButton = trigger || <InfoIconButton />;
186187

187-
const onOpenChange = (open: boolean) => {
188-
setOpen(open);
189-
if (!open) {
190-
onClose?.();
191-
}
192-
};
188+
const componentText = component.text;
193189

194190
const dialogContextValue = useMemo(
195191
() => ({
@@ -201,6 +197,17 @@ const ComponentDetails = ({
201197
[],
202198
);
203199

200+
const handleCloseEditDialog = useCallback(() => {
201+
setIsEditDialogOpen(false);
202+
}, []);
203+
204+
const onOpenChange = useCallback((open: boolean) => {
205+
setOpen(open);
206+
if (!open) {
207+
onClose?.();
208+
}
209+
}, []);
210+
204211
const handleEditComponent = useCallback(() => {
205212
setIsEditDialogOpen(true);
206213
}, []);
@@ -213,6 +220,7 @@ const ComponentDetails = ({
213220
variant="secondary"
214221
onClick={handleEditComponent}
215222
tooltip="Edit Component Definition"
223+
key={`${displayName}-edit-button`}
216224
>
217225
<Icon name="FilePenLine" />
218226
</TooltipButton>
@@ -221,12 +229,6 @@ const ComponentDetails = ({
221229
return [...actions, EditButton];
222230
}, [actions, hasEnabledInAppEditor, handleEditComponent]);
223231

224-
const componentText = component.text;
225-
226-
const handleCloseEditDialog = useCallback(() => {
227-
setIsEditDialogOpen(false);
228-
}, []);
229-
230232
return (
231233
<>
232234
<Dialog modal open={open} onOpenChange={onOpenChange}>
@@ -245,6 +247,7 @@ const ComponentDetails = ({
245247
<DialogHeader>
246248
<DialogTitle className="flex items-center gap-2 mr-5">
247249
<span>{displayName}</span>
250+
<ComponentFavoriteToggle component={component} />
248251
</DialogTitle>
249252
</DialogHeader>
250253

src/components/shared/FavoriteComponentToggle.tsx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
import { PackagePlus, Star, Trash2 } from "lucide-react";
1+
import { PackagePlus, Star } from "lucide-react";
22
import type { MouseEvent, PropsWithChildren } from "react";
33
import { useCallback, useMemo, useState } from "react";
44

55
import { ConfirmationDialog } from "@/components/shared/Dialogs";
66
import { Button } from "@/components/ui/button";
7+
import { Icon } from "@/components/ui/icon";
78
import { cn } from "@/lib/utils";
89
import { useComponentLibrary } from "@/providers/ComponentLibraryProvider";
910
import type { ComponentReference } from "@/utils/componentSpec";
1011
import { getComponentName } from "@/utils/getComponentName";
1112

1213
interface ComponentFavoriteToggleProps {
1314
component: ComponentReference;
15+
hideDelete?: boolean;
1416
}
1517

1618
interface StateButtonProps {
1719
active?: boolean;
20+
isDanger?: boolean;
1821
onClick?: () => void;
1922
}
2023

2124
const IconStateButton = ({
2225
active,
26+
isDanger = false,
2327
onClick,
2428
children,
2529
}: PropsWithChildren<StateButtonProps>) => {
@@ -37,8 +41,12 @@ const IconStateButton = ({
3741
onClick={handleFavorite}
3842
data-testid="favorite-star"
3943
className={cn(
40-
"w-fit h-fit p-1 hover:text-yellow-500",
41-
active ? "text-yellow-500" : "text-gray-500/50",
44+
"w-fit h-fit p-1 hover:text-warning",
45+
active ? "text-warning" : "text-gray-500/50",
46+
{
47+
"hover:text-destructive": isDanger,
48+
"text-destructive": isDanger && active,
49+
},
4250
)}
4351
variant="ghost"
4452
size="icon"
@@ -69,14 +77,15 @@ const AddToLibraryButton = ({ active, onClick }: StateButtonProps) => {
6977

7078
const DeleteFromLibraryButton = ({ active, onClick }: StateButtonProps) => {
7179
return (
72-
<IconStateButton active={active} onClick={onClick}>
73-
<Trash2 className="h-4 w-4" />
80+
<IconStateButton active={active} onClick={onClick} isDanger>
81+
<Icon name="PackageX" />
7482
</IconStateButton>
7583
);
7684
};
7785

7886
export const ComponentFavoriteToggle = ({
7987
component,
88+
hideDelete = false,
8089
}: ComponentFavoriteToggleProps) => {
8190
const {
8291
addToComponentLibrary,
@@ -140,6 +149,8 @@ export const ComponentFavoriteToggle = ({
140149
handleDelete();
141150
}, [component, isInLibrary, addToComponentLibrary, handleDelete]);
142151

152+
const showDeleteButton = isInLibrary && isUserComponent && !hideDelete;
153+
143154
return (
144155
<>
145156
{!isInLibrary && <AddToLibraryButton onClick={openConfirmationDialog} />}
@@ -148,7 +159,7 @@ export const ComponentFavoriteToggle = ({
148159
<FavoriteStarButton active={isFavorited} onClick={onFavorite} />
149160
)}
150161

151-
{isInLibrary && isUserComponent && (
162+
{showDeleteButton && (
152163
<DeleteFromLibraryButton onClick={openConfirmationDialog} />
153164
)}
154165

src/components/shared/ReactFlow/FlowCanvas/TaskNode/TaskOverview/TaskOverview.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@ import {
88

99
import type { TooltipButtonProps } from "@/components/shared/Buttons/TooltipButton";
1010
import TooltipButton from "@/components/shared/Buttons/TooltipButton";
11+
import { ComponentDetailsDialog } from "@/components/shared/Dialogs";
1112
import { ComponentFavoriteToggle } from "@/components/shared/FavoriteComponentToggle";
1213
import { StatusIcon } from "@/components/shared/Status";
1314
import {
1415
TaskDetails,
1516
TaskImplementation,
1617
} from "@/components/shared/TaskDetails";
18+
import { BlockStack, InlineStack } from "@/components/ui/layout";
1719
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
20+
import { Text } from "@/components/ui/typography";
1821
import { useExecutionDataOptional } from "@/providers/ExecutionDataProvider";
1922
import { type TaskNodeContextType } from "@/providers/TaskNodeProvider";
2023
import { isGraphImplementation } from "@/utils/componentSpec";
@@ -56,13 +59,20 @@ const TaskOverview = ({ taskNode, actions }: TaskOverviewProps) => {
5659
const executionId = details?.child_task_execution_ids?.[taskId];
5760

5861
return (
59-
<div className="flex flex-col h-full" data-context-panel="task-overview">
60-
<div className="flex items-center gap-2 px-2 pb-2 font-semibold text-lg">
61-
{name} <ComponentFavoriteToggle component={taskSpec.componentRef} />
62-
{runStatus && <StatusIcon status={runStatus} tooltip label="task" />}
63-
</div>
62+
<BlockStack className="h-full" data-context-panel="task-overview">
63+
<InlineStack gap="2" blockAlign="center" className="px-2 pb-2">
64+
<Text size="lg" weight="semibold">
65+
{name}
66+
</Text>
67+
<ComponentFavoriteToggle component={taskSpec.componentRef} hideDelete />
68+
<ComponentDetailsDialog
69+
displayName={name}
70+
component={taskSpec.componentRef}
71+
/>
72+
{!!runStatus && <StatusIcon status={runStatus} tooltip label="task" />}
73+
</InlineStack>
6474

65-
<div className="flex flex-col px-4 gap-4 overflow-y-auto pb-4 h-full">
75+
<div className="px-4 overflow-y-auto pb-4 h-full w-full">
6676
<Tabs defaultValue="io" className="h-full">
6777
<TabsList className="mb-2">
6878
<TabsTrigger value="io" className="flex-1">
@@ -91,7 +101,7 @@ const TaskOverview = ({ taskNode, actions }: TaskOverviewProps) => {
91101
</TabsTrigger>
92102
)}
93103
</TabsList>
94-
<TabsContent value="details" className="h-full">
104+
<TabsContent value="details">
95105
<TaskDetails
96106
displayName={name}
97107
executionId={executionId}
@@ -123,7 +133,7 @@ const TaskOverview = ({ taskNode, actions }: TaskOverviewProps) => {
123133
))}
124134
/>
125135
</TabsContent>
126-
<TabsContent value="io" className="h-full">
136+
<TabsContent value="io">
127137
{!readOnly && (
128138
<>
129139
<ArgumentsSection
@@ -144,7 +154,7 @@ const TaskOverview = ({ taskNode, actions }: TaskOverviewProps) => {
144154
)}
145155
</TabsContent>
146156
{readOnly && !isSubgraph && (
147-
<TabsContent value="logs" className="h-full">
157+
<TabsContent value="logs">
148158
{!!executionId && (
149159
<div className="flex w-full justify-end pr-4">
150160
<OpenLogsInNewWindowLink
@@ -163,7 +173,7 @@ const TaskOverview = ({ taskNode, actions }: TaskOverviewProps) => {
163173
)}
164174
</Tabs>
165175
</div>
166-
</div>
176+
</BlockStack>
167177
);
168178
};
169179

0 commit comments

Comments
 (0)