Skip to content

Commit eda8190

Browse files
feat: open app in tab or slim-window (#16152)
Close coder/terraform-provider-coder#297
1 parent e693b66 commit eda8190

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

site/src/modules/resources/AppLink/AppLink.tsx

+20-9
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,13 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
129129
}
130130

131131
event.preventDefault();
132+
132133
// This is an external URI like "vscode://", so
133134
// it needs to be opened with the browser protocol handler.
134-
if (app.external && !app.url.startsWith("http")) {
135-
// If the protocol is external the browser does not
136-
// redirect the user from the page.
135+
const shouldOpenAppExternally =
136+
app.external && !app.url.startsWith("http");
137137

138+
if (shouldOpenAppExternally) {
138139
// This is a magic undocumented string that is replaced
139140
// with a brand-new session token from the backend.
140141
// This only exists for external URLs, and should only
@@ -149,12 +150,22 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
149150
setFetchingSessionToken(false);
150151
}
151152
window.location.href = url;
152-
} else {
153-
window.open(
154-
href,
155-
Language.appTitle(appDisplayName, generateRandomString(12)),
156-
"width=900,height=600",
157-
);
153+
return;
154+
}
155+
156+
switch (app.open_in) {
157+
case "slim-window": {
158+
window.open(
159+
href,
160+
Language.appTitle(appDisplayName, generateRandomString(12)),
161+
"width=900,height=600",
162+
);
163+
return;
164+
}
165+
default: {
166+
window.open(href);
167+
return;
168+
}
158169
}
159170
}}
160171
>

0 commit comments

Comments
 (0)