mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
feat(site): allow opening web terminal to container (#16797)
Co-authored-by: BrunoQuaresma <bruno_nonato_quaresma@hotmail.com>
This commit is contained in:
@@ -55,6 +55,8 @@ const TerminalPage: FC = () => {
|
||||
// a round-trip, and must be a UUIDv4.
|
||||
const reconnectionToken = searchParams.get("reconnect") ?? uuidv4();
|
||||
const command = searchParams.get("command") || undefined;
|
||||
const containerName = searchParams.get("container") || undefined;
|
||||
const containerUser = searchParams.get("container_user") || undefined;
|
||||
// The workspace name is in the format:
|
||||
// <workspace name>[.<agent name>]
|
||||
const workspaceNameParts = params.workspace?.split(".");
|
||||
@@ -234,6 +236,8 @@ const TerminalPage: FC = () => {
|
||||
command,
|
||||
terminal.rows,
|
||||
terminal.cols,
|
||||
containerName,
|
||||
containerUser,
|
||||
)
|
||||
.then((url) => {
|
||||
if (disposed) {
|
||||
@@ -302,6 +306,8 @@ const TerminalPage: FC = () => {
|
||||
workspace.error,
|
||||
workspace.isLoading,
|
||||
workspaceAgent,
|
||||
containerName,
|
||||
containerUser,
|
||||
]);
|
||||
|
||||
return (
|
||||
|
||||
@@ -7,6 +7,8 @@ export const terminalWebsocketUrl = async (
|
||||
command: string | undefined,
|
||||
height: number,
|
||||
width: number,
|
||||
containerName: string | undefined,
|
||||
containerUser: string | undefined,
|
||||
): Promise<string> => {
|
||||
const query = new URLSearchParams({ reconnect });
|
||||
if (command) {
|
||||
@@ -14,6 +16,12 @@ export const terminalWebsocketUrl = async (
|
||||
}
|
||||
query.set("height", height.toString());
|
||||
query.set("width", width.toString());
|
||||
if (containerName) {
|
||||
query.set("container", containerName);
|
||||
}
|
||||
if (containerName && containerUser) {
|
||||
query.set("container_user", containerUser);
|
||||
}
|
||||
|
||||
const url = new URL(baseUrl || `${location.protocol}//${location.host}`);
|
||||
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
||||
|
||||
Reference in New Issue
Block a user