mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: open app in tab or slim-window (#16152)
Close https://github.com/coder/terraform-provider-coder/issues/297
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
Reference in New Issue
Block a user