From 774daa1b3ec4e382d3102d7f55a04ac8de33d45f Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Wed, 15 Jan 2025 17:14:54 +0000 Subject: [PATCH 1/3] feat: open app on tab or slim-window --- .../src/modules/resources/AppLink/AppLink.tsx | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/site/src/modules/resources/AppLink/AppLink.tsx b/site/src/modules/resources/AppLink/AppLink.tsx index 1d82a46087f21..f27089e3b307a 100644 --- a/site/src/modules/resources/AppLink/AppLink.tsx +++ b/site/src/modules/resources/AppLink/AppLink.tsx @@ -129,12 +129,12 @@ 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 isBrowserProtocol = app.external && !app.url.startsWith("http"); + if (isBrowserProtocol) { // 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 +149,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; + } + case "tab": { + window.open(href); + return; + } } }} > From 1eae743d76edb66387b74e2c8d0a605deaf603c1 Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Fri, 17 Jan 2025 12:37:19 +0000 Subject: [PATCH 2/3] Improve naming --- site/src/modules/resources/AppLink/AppLink.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/site/src/modules/resources/AppLink/AppLink.tsx b/site/src/modules/resources/AppLink/AppLink.tsx index f27089e3b307a..94cdda4b148cc 100644 --- a/site/src/modules/resources/AppLink/AppLink.tsx +++ b/site/src/modules/resources/AppLink/AppLink.tsx @@ -132,9 +132,10 @@ export const AppLink: FC = ({ app, workspace, agent }) => { // This is an external URI like "vscode://", so // it needs to be opened with the browser protocol handler. - const isBrowserProtocol = app.external && !app.url.startsWith("http"); + const shouldOpenAppExternally = + app.external && !app.url.startsWith("http"); - if (isBrowserProtocol) { + 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 From 30c9a6d0eb8506e8e1c03ee5c184da7b8cc96f1a Mon Sep 17 00:00:00 2001 From: BrunoQuaresma Date: Fri, 17 Jan 2025 12:37:49 +0000 Subject: [PATCH 3/3] Default to tab --- site/src/modules/resources/AppLink/AppLink.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/src/modules/resources/AppLink/AppLink.tsx b/site/src/modules/resources/AppLink/AppLink.tsx index 94cdda4b148cc..15ccfb3d0ed71 100644 --- a/site/src/modules/resources/AppLink/AppLink.tsx +++ b/site/src/modules/resources/AppLink/AppLink.tsx @@ -162,7 +162,7 @@ export const AppLink: FC = ({ app, workspace, agent }) => { ); return; } - case "tab": { + default: { window.open(href); return; }