From eda8190eee72bfb54d568272defdee4eb843e357 Mon Sep 17 00:00:00 2001 From: Bruno Quaresma Date: Fri, 17 Jan 2025 10:01:44 -0300 Subject: [PATCH] feat: open app in tab or slim-window (#16152) Close https://github.com/coder/terraform-provider-coder/issues/297 --- .../src/modules/resources/AppLink/AppLink.tsx | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/site/src/modules/resources/AppLink/AppLink.tsx b/site/src/modules/resources/AppLink/AppLink.tsx index 1d82a46087..15ccfb3d0e 100644 --- a/site/src/modules/resources/AppLink/AppLink.tsx +++ b/site/src/modules/resources/AppLink/AppLink.tsx @@ -129,12 +129,13 @@ export const AppLink: FC = ({ app, workspace, agent }) => { } event.preventDefault(); + // This is an external URI like "vscode://", so // it needs to be opened with the browser protocol handler. - if (app.external && !app.url.startsWith("http")) { - // If the protocol is external the browser does not - // redirect the user from the page. + const shouldOpenAppExternally = + app.external && !app.url.startsWith("http"); + if (shouldOpenAppExternally) { // This is a magic undocumented string that is replaced // with a brand-new session token from the backend. // This only exists for external URLs, and should only @@ -149,12 +150,22 @@ export const AppLink: FC = ({ app, workspace, agent }) => { setFetchingSessionToken(false); } window.location.href = url; - } else { - window.open( - href, - Language.appTitle(appDisplayName, generateRandomString(12)), - "width=900,height=600", - ); + return; + } + + switch (app.open_in) { + case "slim-window": { + window.open( + href, + Language.appTitle(appDisplayName, generateRandomString(12)), + "width=900,height=600", + ); + return; + } + default: { + window.open(href); + return; + } } }} >