feat: open app in tab or slim-window (#16152)

Close https://github.com/coder/terraform-provider-coder/issues/297
This commit is contained in:
Bruno Quaresma
2025-01-17 10:01:44 -03:00
committed by GitHub
parent e693b66b47
commit eda8190eee

View File

@ -129,12 +129,13 @@ export const AppLink: FC<AppLinkProps> = ({ 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<AppLinkProps> = ({ 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;
}
}
}}
>