1
+ import Box from "@mui/material/Box" ;
1
2
import Link from "@mui/material/Link" ;
2
3
import Popover from "@mui/material/Popover" ;
3
- import { makeStyles } from "@mui/styles" ;
4
+ import CircularProgress from "@mui/material/CircularProgress" ;
5
+ import OpenInNewOutlined from "@mui/icons-material/OpenInNewOutlined" ;
6
+ import { css } from "@emotion/css" ;
7
+ import { useTheme } from "@emotion/react" ;
4
8
import { useRef , useState } from "react" ;
9
+ import { useQuery } from "react-query" ;
5
10
import { colors } from "theme/colors" ;
6
11
import {
7
12
HelpTooltipLink ,
@@ -11,16 +16,12 @@ import {
11
16
} from "components/HelpTooltip/HelpTooltip" ;
12
17
import { SecondaryAgentButton } from "components/Resources/AgentButton" ;
13
18
import { docs } from "utils/docs" ;
14
- import Box from "@mui/material/Box" ;
15
- import { useQuery } from "react-query" ;
16
19
import { getAgentListeningPorts } from "api/api" ;
17
- import {
20
+ import type {
18
21
WorkspaceAgent ,
19
22
WorkspaceAgentListeningPort ,
20
23
} from "api/typesGenerated" ;
21
- import CircularProgress from "@mui/material/CircularProgress" ;
22
24
import { portForwardURL } from "utils/portForward" ;
23
- import OpenInNewOutlined from "@mui/icons-material/OpenInNewOutlined" ;
24
25
25
26
export interface PortForwardButtonProps {
26
27
host : string ;
@@ -30,10 +31,10 @@ export interface PortForwardButtonProps {
30
31
}
31
32
32
33
export const PortForwardButton : React . FC < PortForwardButtonProps > = ( props ) => {
34
+ const theme = useTheme ( ) ;
33
35
const anchorRef = useRef < HTMLButtonElement > ( null ) ;
34
36
const [ isOpen , setIsOpen ] = useState ( false ) ;
35
37
const id = isOpen ? "schedule-popover" : undefined ;
36
- const styles = useStyles ( ) ;
37
38
const portsQuery = useQuery ( {
38
39
queryKey : [ "portForward" , props . agent . id ] ,
39
40
queryFn : ( ) => getAgentListeningPorts ( props . agent . id ) ,
@@ -78,7 +79,14 @@ export const PortForwardButton: React.FC<PortForwardButtonProps> = (props) => {
78
79
) }
79
80
</ SecondaryAgentButton >
80
81
< Popover
81
- classes = { { paper : styles . popoverPaper } }
82
+ classes = { {
83
+ paper : css `
84
+ padding : 0 ;
85
+ width : ${ theme . spacing ( 38 ) } ;
86
+ color : ${ theme . palette . text . secondary } ;
87
+ margin-top : ${ theme . spacing ( 0.5 ) } ;
88
+ ` ,
89
+ } }
82
90
id = { id }
83
91
open = { isOpen }
84
92
anchorEl = { anchorRef . current }
@@ -245,31 +253,3 @@ export const PortForwardPopoverView: React.FC<
245
253
</ >
246
254
) ;
247
255
} ;
248
-
249
- const useStyles = makeStyles ( ( theme ) => ( {
250
- popoverPaper : {
251
- padding : 0 ,
252
- width : theme . spacing ( 38 ) ,
253
- color : theme . palette . text . secondary ,
254
- marginTop : theme . spacing ( 0.5 ) ,
255
- } ,
256
-
257
- openUrlButton : {
258
- flexShrink : 0 ,
259
- } ,
260
-
261
- portField : {
262
- // The default border don't contrast well with the popover
263
- "& .MuiOutlinedInput-root .MuiOutlinedInput-notchedOutline" : {
264
- borderColor : colors . gray [ 10 ] ,
265
- } ,
266
- } ,
267
-
268
- code : {
269
- margin : theme . spacing ( 2 , 0 ) ,
270
- } ,
271
-
272
- form : {
273
- margin : theme . spacing ( 2 , 0 ) ,
274
- } ,
275
- } ) ) ;
0 commit comments