From 63b5f0b998ec7db16b262612cf84f9169ed405c5 Mon Sep 17 00:00:00 2001 From: Asher Date: Thu, 19 Jun 2025 09:22:36 -0800 Subject: [PATCH] feat: add app iframe controls (#18421) Add a home and "open in new tab" button. Other controls are not possible due to cross-origin restrictions. Closes #18178 --------- Co-authored-by: BrunoQuaresma --- site/src/pages/TaskPage/TaskAppIframe.tsx | 88 ++++++++++++++++++----- site/src/pages/TaskPage/TaskApps.tsx | 43 +++++------ 2 files changed, 93 insertions(+), 38 deletions(-) diff --git a/site/src/pages/TaskPage/TaskAppIframe.tsx b/site/src/pages/TaskPage/TaskAppIframe.tsx index 5a3d0ed509..860fc64cbb 100644 --- a/site/src/pages/TaskPage/TaskAppIframe.tsx +++ b/site/src/pages/TaskPage/TaskAppIframe.tsx @@ -1,7 +1,16 @@ import type { WorkspaceApp } from "api/typesGenerated"; +import { Button } from "components/Button/Button"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "components/DropdownMenu/DropdownMenu"; +import { EllipsisVertical, ExternalLinkIcon, HouseIcon } from "lucide-react"; import { useAppLink } from "modules/apps/useAppLink"; import type { Task } from "modules/tasks/tasks"; -import type { FC } from "react"; +import { type FC, useRef } from "react"; +import { Link as RouterLink } from "react-router-dom"; import { cn } from "utils/cn"; type TaskAppIFrameProps = { @@ -31,24 +40,69 @@ export const TaskAppIFrame: FC = ({ workspace: task.workspace, }); - let href = link.href; - try { - const url = new URL(link.href); - if (pathname) { - url.pathname = pathname; + const appHref = (): string => { + try { + const url = new URL(link.href, location.href); + if (pathname) { + url.pathname = pathname; + } + return url.toString(); + } catch (err) { + console.warn(`Failed to parse URL ${link.href} for app ${app.id}`, err); + return link.href; } - href = url.toString(); - } catch (err) { - console.warn(`Failed to parse URL ${link.href} for app ${app.id}`, err); - } + }; + + const frameRef = useRef(null); + const frameSrc = appHref(); return ( -