Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5655ec6

Browse files
authored
Revert "fix: open terminal and coder_app in a new tab, not window (#6044)" (#6106)
This reverts commit a655f03.
1 parent 0ccab0c commit 5655ec6

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

site/src/components/AppLink/AppLink.tsx

+18
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,15 @@ import Tooltip from "@material-ui/core/Tooltip"
66
import ErrorOutlineIcon from "@material-ui/icons/ErrorOutline"
77
import { FC } from "react"
88
import * as TypesGen from "../../api/typesGenerated"
9+
import { generateRandomString } from "../../util/random"
910
import { BaseIcon } from "./BaseIcon"
1011
import { ShareIcon } from "./ShareIcon"
1112

13+
const Language = {
14+
appTitle: (appName: string, identifier: string): string =>
15+
`${appName} - ${identifier}`,
16+
}
17+
1218
export interface AppLinkProps {
1319
appsHost?: string
1420
workspace: TypesGen.Workspace
@@ -92,6 +98,18 @@ export const AppLink: FC<AppLinkProps> = ({
9298
href={href}
9399
target="_blank"
94100
className={canClick ? styles.link : styles.disabledLink}
101+
onClick={
102+
canClick
103+
? (event) => {
104+
event.preventDefault()
105+
window.open(
106+
href,
107+
Language.appTitle(appDisplayName, generateRandomString(12)),
108+
"width=900,height=600",
109+
)
110+
}
111+
: undefined
112+
}
95113
>
96114
{button}
97115
</Link>

site/src/components/TerminalLink/TerminalLink.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import ComputerIcon from "@material-ui/icons/Computer"
55
import { FC } from "react"
66
import * as TypesGen from "../../api/typesGenerated"
77
import { combineClasses } from "../../util/combineClasses"
8+
import { generateRandomString } from "../../util/random"
89

910
export const Language = {
1011
linkText: "Terminal",
12+
terminalTitle: (identifier: string): string => `Terminal - ${identifier}`,
1113
}
1214

1315
export interface TerminalLinkProps {
@@ -40,6 +42,14 @@ export const TerminalLink: FC<React.PropsWithChildren<TerminalLinkProps>> = ({
4042
href={href}
4143
className={combineClasses([styles.link, className])}
4244
target="_blank"
45+
onClick={(event) => {
46+
event.preventDefault()
47+
window.open(
48+
href,
49+
Language.terminalTitle(generateRandomString(12)),
50+
"width=900,height=600",
51+
)
52+
}}
4353
>
4454
<Button startIcon={<ComputerIcon />} size="small">
4555
{Language.linkText}

0 commit comments

Comments
 (0)