Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ab21652

Browse files
committed
chore: show iframe controls on preview slug only
1 parent 556b095 commit ab21652

File tree

1 file changed

+36
-34
lines changed

1 file changed

+36
-34
lines changed

site/src/pages/TaskPage/TaskAppIframe.tsx

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -58,42 +58,44 @@ export const TaskAppIFrame: FC<TaskAppIFrameProps> = ({
5858

5959
return (
6060
<div className={cn([active ? "flex" : "hidden", "w-full h-full flex-col"])}>
61-
<div className="bg-surface-tertiary flex items-center p-2 py-1 gap-1">
62-
<Button
63-
size="icon"
64-
variant="subtle"
65-
onClick={(e) => {
66-
e.preventDefault();
67-
if (frameRef.current?.contentWindow) {
68-
frameRef.current.contentWindow.location.href = appHref();
69-
}
70-
}}
71-
>
72-
<HouseIcon />
73-
<span className="sr-only">Home</span>
74-
</Button>
61+
{app.slug === "preview" && (
62+
<div className="bg-surface-tertiary flex items-center p-2 py-1 gap-1">
63+
<Button
64+
size="icon"
65+
variant="subtle"
66+
onClick={(e) => {
67+
e.preventDefault();
68+
if (frameRef.current?.contentWindow) {
69+
frameRef.current.contentWindow.location.href = appHref();
70+
}
71+
}}
72+
>
73+
<HouseIcon />
74+
<span className="sr-only">Home</span>
75+
</Button>
7576

76-
{/* Possibly we will put a URL bar here, but for now we cannot due to
77-
* cross-origin restrictions in iframes. */}
78-
<div className="w-full"></div>
77+
{/* Possibly we will put a URL bar here, but for now we cannot due to
78+
* cross-origin restrictions in iframes. */}
79+
<div className="w-full"></div>
7980

80-
<DropdownMenu>
81-
<DropdownMenuTrigger asChild>
82-
<Button size="icon" variant="subtle" aria-label="More options">
83-
<EllipsisVertical aria-hidden="true" />
84-
<span className="sr-only">More options</span>
85-
</Button>
86-
</DropdownMenuTrigger>
87-
<DropdownMenuContent align="end">
88-
<DropdownMenuItem asChild>
89-
<RouterLink to={frameSrc} target="_blank">
90-
<ExternalLinkIcon />
91-
Open app in new tab
92-
</RouterLink>
93-
</DropdownMenuItem>
94-
</DropdownMenuContent>
95-
</DropdownMenu>
96-
</div>
81+
<DropdownMenu>
82+
<DropdownMenuTrigger asChild>
83+
<Button size="icon" variant="subtle" aria-label="More options">
84+
<EllipsisVertical aria-hidden="true" />
85+
<span className="sr-only">More options</span>
86+
</Button>
87+
</DropdownMenuTrigger>
88+
<DropdownMenuContent align="end">
89+
<DropdownMenuItem asChild>
90+
<RouterLink to={frameSrc} target="_blank">
91+
<ExternalLinkIcon />
92+
Open app in new tab
93+
</RouterLink>
94+
</DropdownMenuItem>
95+
</DropdownMenuContent>
96+
</DropdownMenu>
97+
</div>
98+
)}
9799

98100
<iframe
99101
ref={frameRef}

0 commit comments

Comments
 (0)