"use client";
import type { AppItem } from "@/modules/apps/components/app-grid-presenters";
import {
Copy,
ExternalLink,
Play,
RefreshCw,
RotateCcw,
ScrollText,
Settings2,
Square,
TerminalSquare,
Trash2,
} from "@/components/icons/platform-icons";
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/components/ui/tooltip";
import type { ReactNode } from "react";
type AppGridAction =
| "open"
| "start"
| "stop"
| "restart"
| "logs"
| "terminal"
| "settings"
| "update"
| "copy-url"
| "remove";
export function AppGridContextMenu({
app,
hasDashboardUrl,
isBusy,
x,
y,
onAction,
}: {
app: AppItem;
hasDashboardUrl: boolean;
isBusy: boolean;
x: number;
y: number;
onAction: (action: AppGridAction) => void;
}) {
return (
event.stopPropagation()}
>
}
label="Open Dashboard"
disabled={!hasDashboardUrl}
title={!hasDashboardUrl ? "No web port configured for this app." : undefined}
onClick={() => onAction("open")}
/>
{app.status === "running" || app.status === "partial" ? (
}
label="Stop Container"
disabled={isBusy}
onClick={() => onAction("stop")}
/>
) : (
}
label="Start Container"
disabled={isBusy}
onClick={() => onAction("start")}
/>
)}
}
label="Restart Container"
disabled={isBusy}
onClick={() => onAction("restart")}
/>
}
label="View Logs"
onClick={() => onAction("logs")}
/>
}
label="Open in Terminal"
onClick={() => onAction("terminal")}
/>
}
label="App Settings"
onClick={() => onAction("settings")}
/>
}
label="Check Updates"
disabled={isBusy}
onClick={() => onAction("update")}
/>
}
label="Copy URL"
disabled={!hasDashboardUrl}
title={!hasDashboardUrl ? "No web port configured for this app." : undefined}
onClick={() => onAction("copy-url")}
/>
}
label="Remove App"
danger
disabled={isBusy}
onClick={() => onAction("remove")}
/>
);
}
function AppGridContextMenuItem({
danger,
disabled,
icon,
label,
onClick,
title,
}: {
danger?: boolean;
disabled?: boolean;
icon: ReactNode;
label: string;
onClick: () => void;
title?: string;
}) {
const button = (
);
if (title) {
return (
{button}
{title}
);
}
return button;
}