- Notifications
You must be signed in to change notification settings - Fork1k
fix: make app tabs scrollable#19881
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
9 commits Select commitHold shift + click to select a range
78e0dc6
fix: move overflowing apps into a dropdown
BrunoQuaresma2b14f98
use horizontal scrolling
BrunoQuaresma41f3e2c
remove unecessary attr
BrunoQuaresma20f370d
apply PR review suggestions
BrunoQuaresmac9f526b
Merge branch 'main' of https://github.com/coder/coder into bq/fix-app…
BrunoQuaresma2207d08
fixes
BrunoQuaresmae4a57ef
fix and add new stories
BrunoQuaresmaa87b7cc
apply pr review comments
BrunoQuaresmac65d2bd
fix lint
BrunoQuaresmaFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,34 @@ | ||
import type { | ||
Workspace, | ||
WorkspaceAgent, | ||
WorkspaceApp, | ||
} from "api/typesGenerated"; | ||
export const AI_PROMPT_PARAMETER_NAME = "AI Prompt"; | ||
export type Task = { | ||
workspace: Workspace; | ||
prompt: string; | ||
}; | ||
export type WorkspaceAppWithAgent = WorkspaceApp & { | ||
agent: WorkspaceAgent; | ||
}; | ||
export function getTaskApps(task: Task): WorkspaceAppWithAgent[] { | ||
return ( | ||
task.workspace.latest_build.resources | ||
.flatMap((r) => r.agents ?? []) | ||
.flatMap((agent) => | ||
agent.apps.map((app) => ({ | ||
...app, | ||
agent, | ||
})), | ||
) | ||
// The Chat UI app will be displayed in the sidebar, so we don't want to | ||
// show it as a tab. | ||
.filter( | ||
(app) => app.id !== task.workspace.latest_build.ai_task_sidebar_app_id, | ||
) | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { Button } from "components/Button/Button"; | ||
import { | ||
DropdownMenu, | ||
@@ -7,55 +6,42 @@ import { | ||
DropdownMenuTrigger, | ||
} from "components/DropdownMenu/DropdownMenu"; | ||
import { Spinner } from "components/Spinner/Spinner"; | ||
import { useProxy } from "contexts/ProxyContext"; | ||
import { EllipsisVertical, ExternalLinkIcon, HouseIcon } from "lucide-react"; | ||
import { useAppLink } from "modules/apps/useAppLink"; | ||
import type { Task, WorkspaceAppWithAgent } from "modules/tasks/tasks"; | ||
import { type FC, useRef } from "react"; | ||
import { Link as RouterLink } from "react-router"; | ||
import { cn } from "utils/cn"; | ||
import { TaskWildcardWarning } from "./TaskWildcardWarning"; | ||
type TaskAppIFrameProps = { | ||
task: Task; | ||
app:WorkspaceAppWithAgent; | ||
active: boolean; | ||
}; | ||
export const TaskAppIFrame: FC<TaskAppIFrameProps> = ({ | ||
task, | ||
app, | ||
active, | ||
}) => { | ||
BrunoQuaresma marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
const link = useAppLink(app, { | ||
agent: app.agent, | ||
workspace: task.workspace, | ||
}); | ||
BrunoQuaresma marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
const proxy = useProxy(); | ||
const frameRef = useRef<HTMLIFrameElement>(null); | ||
const shouldDisplayWildcardWarning = | ||
app.subdomain && !proxy.proxy?.preferredWildcardHostname; | ||
if (shouldDisplayWildcardWarning) { | ||
return ( | ||
<div className="h-full flex items-center justify-center pb-4"> | ||
<TaskWildcardWarning /> | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div className={cn([active ? "flex" : "hidden", "w-full h-full flex-col"])}> | ||
@@ -67,7 +53,7 @@ export const TaskAppIFrame: FC<TaskAppIFrameProps> = ({ | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
if (frameRef.current?.contentWindow) { | ||
frameRef.current.contentWindow.location.href =link.href; | ||
} | ||
}} | ||
> | ||
@@ -88,7 +74,7 @@ export const TaskAppIFrame: FC<TaskAppIFrameProps> = ({ | ||
</DropdownMenuTrigger> | ||
<DropdownMenuContent align="end"> | ||
<DropdownMenuItem asChild> | ||
<RouterLink to={link.href} target="_blank"> | ||
<ExternalLinkIcon /> | ||
Open app in new tab | ||
</RouterLink> | ||
@@ -103,7 +89,7 @@ export const TaskAppIFrame: FC<TaskAppIFrameProps> = ({ | ||
app.health === "unhealthy" ? ( | ||
<iframe | ||
ref={frameRef} | ||
src={link.href} | ||
title={link.label} | ||
loading="eager" | ||
className={"w-full h-full border-0"} | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.