Skip to content

Commit acfb34b

Browse files
committed
improvement: move Task Actions out of details tab
1 parent f87dde9 commit acfb34b

5 files changed

Lines changed: 49 additions & 18 deletions

File tree

src/components/shared/Dialogs/ComponentDetailsDialog.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { PublishedComponentDetails } from "../ManageComponent/PublishedComponent
2424
import { useFlagValue } from "../Settings/useFlags";
2525
import { withSuspenseWrapper } from "../SuspenseWrapper";
2626
import { TaskDetails, TaskImplementation, TaskIO } from "../TaskDetails";
27+
import TaskActions from "../TaskDetails/Actions";
2728
import { DialogContext } from "./dialog.context";
2829

2930
interface ComponentDetailsProps {
@@ -120,11 +121,12 @@ const ComponentDetailsDialogContent = withSuspenseWrapper(
120121

121122
<div className="overflow-auto h-[40vh]">
122123
<TabsContent value="details" className="h-full">
123-
{remoteComponentLibrarySearchEnabled ? (
124+
{remoteComponentLibrarySearchEnabled && (
124125
<PublishedComponentDetails component={componentRef} />
125-
) : null}
126+
)}
126127

127128
<TaskDetails componentRef={componentRef} />
129+
<TaskActions componentRef={componentRef} className="mt-2" />
128130
</TabsContent>
129131

130132
<TabsContent value="io" className="h-full">

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

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import { ComponentDetailsDialog } from "@/components/shared/Dialogs";
1010
import { ComponentFavoriteToggle } from "@/components/shared/FavoriteComponentToggle";
1111
import { StatusIcon } from "@/components/shared/Status";
1212
import { TaskDetails } from "@/components/shared/TaskDetails";
13+
import TaskActions from "@/components/shared/TaskDetails/Actions";
1314
import { Icon } from "@/components/ui/icon";
1415
import { BlockStack, InlineStack } from "@/components/ui/layout";
1516
import { Separator } from "@/components/ui/separator";
1617
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
1718
import { Text } from "@/components/ui/typography";
19+
import { useHydrateComponentReference } from "@/hooks/useHydrateComponentReference";
1820
import { useExecutionDataOptional } from "@/providers/ExecutionDataProvider";
1921
import { type TaskNodeContextType } from "@/providers/TaskNodeProvider";
2022
import { isGraphImplementation } from "@/utils/componentSpec";
@@ -33,6 +35,10 @@ interface TaskOverviewProps {
3335
const TaskOverview = ({ taskNode }: TaskOverviewProps) => {
3436
const { displayName, taskSpec, taskId, state, callbacks } = taskNode;
3537

38+
const hydratedComponentRef = useHydrateComponentReference(
39+
taskSpec?.componentRef ?? {},
40+
);
41+
3642
const executionData = useExecutionDataOptional();
3743
const details = executionData?.details;
3844

@@ -57,8 +63,12 @@ const TaskOverview = ({ taskNode }: TaskOverviewProps) => {
5763
const canRename = !readOnly && isSubgraph;
5864

5965
return (
60-
<BlockStack className="h-full" data-context-panel="task-overview">
61-
<InlineStack gap="2" className="px-2 pb-2">
66+
<BlockStack
67+
gap="4"
68+
className="h-full px-2"
69+
data-context-panel="task-overview"
70+
>
71+
<InlineStack gap="2">
6272
{isSubgraph && <Icon name="Workflow" />}
6373
<Text size="lg" weight="semibold" className="wrap-anywhere">
6474
{displayName}
@@ -72,7 +82,15 @@ const TaskOverview = ({ taskNode }: TaskOverviewProps) => {
7282
{readOnly && <StatusIcon status={status} tooltip label="task" />}
7383
</InlineStack>
7484

75-
<div className="px-4 overflow-y-auto pb-4 h-full w-full">
85+
{!!hydratedComponentRef && (
86+
<TaskActions
87+
componentRef={hydratedComponentRef}
88+
taskNode={taskNode}
89+
readOnly={readOnly}
90+
/>
91+
)}
92+
93+
<div className="overflow-y-auto pb-4 h-full w-full">
7694
<Tabs defaultValue="io" className="h-full">
7795
<TabsList className="mb-2">
7896
<TabsTrigger value="io" className="flex-1">

src/components/shared/TaskDetails/Actions.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,13 @@ const TaskActions = ({
8080
deleteComponent,
8181
].filter(Boolean);
8282

83-
return <ActionBlock actions={actions} className={className} />;
83+
return (
84+
<ActionBlock
85+
actions={actions}
86+
className={className}
87+
data-testid="task-actions"
88+
/>
89+
);
8490
};
8591

8692
export default TaskActions;

src/components/shared/TaskDetails/Details.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { KeyValueList } from "../ContextPanel/Blocks/KeyValueList";
1111
import { TextBlock } from "../ContextPanel/Blocks/TextBlock";
1212
import { InlineEditor } from "../InlineEditor/InlineEditor";
1313
import { withSuspenseWrapper } from "../SuspenseWrapper";
14-
import TaskActions from "./Actions";
1514
import { DisplayNameEditor } from "./DisplayNameEditor";
1615
import { ExecutionDetails } from "./ExecutionDetails";
1716
import { GithubDetails } from "./GithubDetails";
@@ -180,13 +179,6 @@ const TaskDetailsInternal = ({
180179
/>
181180
</ContentBlock>
182181
)}
183-
184-
<TaskActions
185-
componentRef={hydratedComponentRef}
186-
taskNode={taskNode}
187-
readOnly={readOnly}
188-
className={BASE_BLOCK_CLASS}
189-
/>
190182
</BlockStack>
191183
);
192184
};

tests/e2e/helpers.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,29 @@ export async function removeComponentFromCanvas(
236236
componentName: string,
237237
): Promise<void> {
238238
const node = locateNodeByName(page, componentName);
239+
239240
await node.click();
240-
await node.press("Delete");
241+
await expect(node).toHaveClass(/selected/);
242+
243+
await waitForContextPanel(page, "task-overview");
244+
245+
const flowWrapper = page.locator(".react-flow");
246+
await flowWrapper.focus();
247+
248+
// eslint-disable-next-line playwright/no-wait-for-timeout
249+
await page.waitForTimeout(100);
250+
251+
await page.keyboard.press("Delete");
241252

242-
// Wait for confirmation dialog to appear and be interactive
243253
const confirmDialog = page.locator('[role="alertdialog"]');
244-
const continueButton = confirmDialog.getByText("Continue");
254+
await expect(confirmDialog).toBeVisible({ timeout: 10000 });
255+
256+
const continueButton = confirmDialog.getByRole("button", {
257+
name: "Continue",
258+
});
245259
await expect(continueButton).toBeVisible();
246260
await continueButton.click();
247261

248-
// Wait for the node to be removed from the DOM
249262
await expect(node).toBeHidden();
250263
await expect(confirmDialog).toBeHidden();
251264
}

0 commit comments

Comments
 (0)