Skip to content

Commit 2536d2a

Browse files
authored
Fix mobile: shrink dropdown place duplicate with sign in move read-only (#133)
Co-authored-by: Chris Tate <ctate@users.noreply.github.com>
1 parent dc73064 commit 2536d2a

File tree

1 file changed

+54
-29
lines changed

1 file changed

+54
-29
lines changed

components/workflow/workflow-toolbar.tsx

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,25 +1084,10 @@ function ToolbarActions({
10841084
const selectedEdge = edges.find((edge) => edge.id === selectedEdgeId);
10851085
const hasSelection = selectedNode || selectedEdge;
10861086

1087-
// For non-owners viewing public workflows, only show duplicate button
1087+
// For non-owners viewing public workflows, don't show toolbar actions
1088+
// (Duplicate button is now in the main toolbar next to Sign In)
10881089
if (workflowId && !state.isOwner) {
1089-
return (
1090-
<Button
1091-
className="h-9 border hover:bg-black/5 dark:hover:bg-white/5"
1092-
disabled={state.isDuplicating}
1093-
onClick={actions.handleDuplicate}
1094-
size="sm"
1095-
title="Duplicate to your workflows"
1096-
variant="secondary"
1097-
>
1098-
{state.isDuplicating ? (
1099-
<Loader2 className="mr-2 size-4 animate-spin" />
1100-
) : (
1101-
<Copy className="mr-2 size-4" />
1102-
)}
1103-
Duplicate
1104-
</Button>
1105-
);
1090+
return null;
11061091
}
11071092

11081093
if (!workflowId) {
@@ -1476,6 +1461,33 @@ function RunButtonGroup({
14761461
);
14771462
}
14781463

1464+
// Duplicate Button Component - placed next to Sign In for non-owners
1465+
function DuplicateButton({
1466+
isDuplicating,
1467+
onDuplicate,
1468+
}: {
1469+
isDuplicating: boolean;
1470+
onDuplicate: () => void;
1471+
}) {
1472+
return (
1473+
<Button
1474+
className="h-9 border hover:bg-black/5 dark:hover:bg-white/5"
1475+
disabled={isDuplicating}
1476+
onClick={onDuplicate}
1477+
size="sm"
1478+
title="Duplicate to your workflows"
1479+
variant="secondary"
1480+
>
1481+
{isDuplicating ? (
1482+
<Loader2 className="mr-2 size-4 animate-spin" />
1483+
) : (
1484+
<Copy className="mr-2 size-4" />
1485+
)}
1486+
Duplicate
1487+
</Button>
1488+
);
1489+
}
1490+
14791491
// Workflow Menu Component
14801492
function WorkflowMenuComponent({
14811493
workflowId,
@@ -1487,12 +1499,12 @@ function WorkflowMenuComponent({
14871499
actions: ReturnType<typeof useWorkflowActions>;
14881500
}) {
14891501
return (
1490-
<div className="flex items-center gap-2">
1491-
<div className="flex h-9 items-center overflow-hidden rounded-md border bg-secondary text-secondary-foreground">
1502+
<div className="flex flex-col gap-1">
1503+
<div className="flex h-9 max-w-[160px] items-center overflow-hidden rounded-md border bg-secondary text-secondary-foreground sm:max-w-none">
14921504
<DropdownMenu onOpenChange={(open) => open && actions.loadWorkflows()}>
14931505
<DropdownMenuTrigger className="flex h-full cursor-pointer items-center gap-2 px-3 font-medium text-sm transition-all hover:bg-black/5 dark:hover:bg-white/5">
1494-
<WorkflowIcon className="size-4" />
1495-
<p className="font-medium text-sm">
1506+
<WorkflowIcon className="size-4 shrink-0" />
1507+
<p className="truncate font-medium text-sm">
14961508
{workflowId ? (
14971509
state.workflowName
14981510
) : (
@@ -1502,7 +1514,7 @@ function WorkflowMenuComponent({
15021514
</>
15031515
)}
15041516
</p>
1505-
<ChevronDown className="size-3 opacity-50" />
1517+
<ChevronDown className="size-3 shrink-0 opacity-50" />
15061518
</DropdownMenuTrigger>
15071519
<DropdownMenuContent align="start" className="w-64">
15081520
<DropdownMenuItem
@@ -1539,7 +1551,7 @@ function WorkflowMenuComponent({
15391551
</DropdownMenu>
15401552
</div>
15411553
{workflowId && !state.isOwner && (
1542-
<span className="text-muted-foreground text-xs uppercase">
1554+
<span className="text-muted-foreground text-xs uppercase lg:hidden">
15431555
Read-only
15441556
</span>
15451557
)}
@@ -2043,11 +2055,18 @@ export const WorkflowToolbar = ({ workflowId }: WorkflowToolbarProps) => {
20432055
className="flex flex-col gap-2 rounded-none border-none bg-transparent p-0 lg:flex-row lg:items-center"
20442056
position="top-left"
20452057
>
2046-
<WorkflowMenuComponent
2047-
actions={actions}
2048-
state={state}
2049-
workflowId={workflowId}
2050-
/>
2058+
<div className="flex items-center gap-2">
2059+
<WorkflowMenuComponent
2060+
actions={actions}
2061+
state={state}
2062+
workflowId={workflowId}
2063+
/>
2064+
{workflowId && !state.isOwner && (
2065+
<span className="hidden text-muted-foreground text-xs uppercase lg:inline">
2066+
Read-only
2067+
</span>
2068+
)}
2069+
</div>
20512070
</Panel>
20522071

20532072
<div className="pointer-events-auto absolute top-4 right-4 z-10">
@@ -2064,6 +2083,12 @@ export const WorkflowToolbar = ({ workflowId }: WorkflowToolbarProps) => {
20642083
<DeployButton />
20652084
</>
20662085
)}
2086+
{workflowId && !state.isOwner && (
2087+
<DuplicateButton
2088+
isDuplicating={state.isDuplicating}
2089+
onDuplicate={actions.handleDuplicate}
2090+
/>
2091+
)}
20672092
<UserMenu />
20682093
</div>
20692094
</div>

0 commit comments

Comments
 (0)