({
workspace,
app,
active,
})
| 27 | }; |
| 28 | |
| 29 | export const TaskAppIFrame: FC<TaskAppIFrameProps> = ({ |
| 30 | workspace, |
| 31 | app, |
| 32 | active, |
| 33 | }) => { |
| 34 | const link = useAppLink(app, { |
| 35 | agent: app.agent, |
| 36 | workspace, |
| 37 | }); |
| 38 | const proxy = useProxy(); |
| 39 | const frameRef = useRef<HTMLIFrameElement>(null); |
| 40 | const shouldDisplayWildcardWarning = |
| 41 | app.subdomain && !proxy.proxy?.preferredWildcardHostname; |
| 42 | |
| 43 | if (shouldDisplayWildcardWarning) { |
| 44 | return ( |
| 45 | <div className="h-full flex items-center justify-center pb-4"> |
| 46 | <TaskWildcardWarning /> |
| 47 | </div> |
| 48 | ); |
| 49 | } |
| 50 | |
| 51 | return ( |
| 52 | <div className={cn([active ? "flex" : "hidden", "w-full h-full flex-col"])}> |
| 53 | {app.slug === "preview" && ( |
| 54 | <div className="bg-surface-tertiary flex items-center p-2 py-1 gap-1"> |
| 55 | <Button |
| 56 | size="icon" |
| 57 | variant="subtle" |
| 58 | onClick={(e) => { |
| 59 | e.preventDefault(); |
| 60 | if (frameRef.current?.contentWindow) { |
| 61 | frameRef.current.contentWindow.location.href = link.href; |
| 62 | } |
| 63 | }} |
| 64 | > |
| 65 | <HouseIcon /> |
| 66 | <span className="sr-only">Home</span> |
| 67 | </Button> |
| 68 | |
| 69 | {/* Possibly we will put a URL bar here, but for now we cannot due to |
| 70 | * cross-origin restrictions in iframes. */} |
| 71 | <div className="w-full"></div> |
| 72 | |
| 73 | <DropdownMenu> |
| 74 | <DropdownMenuTrigger asChild> |
| 75 | <Button size="icon" variant="subtle" aria-label="More options"> |
| 76 | <EllipsisVerticalIcon aria-hidden="true" /> |
| 77 | <span className="sr-only">More options</span> |
| 78 | </Button> |
| 79 | </DropdownMenuTrigger> |
| 80 | <DropdownMenuContent align="end"> |
| 81 | <DropdownMenuItem asChild> |
| 82 | <RouterLink to={link.href} target="_blank"> |
| 83 | <ExternalLinkIcon /> |
| 84 | Open app in new tab |
| 85 | </RouterLink> |
| 86 | </DropdownMenuItem> |
nothing calls this directly
no test coverage detected