1
1
import { useTheme } from "@emotion/react" ;
2
2
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline" ;
3
- import CircularProgress from "@mui/material/CircularProgress" ;
4
- import Link from "@mui/material/Link" ;
5
- import Tooltip from "@mui/material/Tooltip" ;
6
3
import { API } from "api/api" ;
7
4
import type * as TypesGen from "api/typesGenerated" ;
8
5
import { displayError } from "components/GlobalSnackbar/utils" ;
6
+ import { Spinner } from "components/Spinner/Spinner" ;
7
+ import {
8
+ Tooltip ,
9
+ TooltipContent ,
10
+ TooltipProvider ,
11
+ TooltipTrigger ,
12
+ } from "components/Tooltip/Tooltip" ;
9
13
import { useProxy } from "contexts/ProxyContext" ;
10
- import { type FC , type MouseEvent , useState } from "react" ;
14
+ import { type FC , useState } from "react" ;
11
15
import { createAppLinkHref } from "utils/apps" ;
12
16
import { generateRandomString } from "utils/random" ;
13
17
import { AgentButton } from "../AgentButton" ;
@@ -75,21 +79,7 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
75
79
76
80
let primaryTooltip = "" ;
77
81
if ( app . health === "initializing" ) {
78
- icon = (
79
- // This is a hack to make the spinner appear in the center of the start
80
- // icon space
81
- < span
82
- css = { {
83
- display :"flex" ,
84
- width :"100%" ,
85
- height :"100%" ,
86
- alignItems :"center" ,
87
- justifyContent :"center" ,
88
- } }
89
- >
90
- < CircularProgress size = { 14 } />
91
- </ span >
92
- ) ;
82
+ icon = < Spinner loading /> ;
93
83
primaryTooltip = "Initializing..." ;
94
84
}
95
85
if ( app . health === "unhealthy" ) {
@@ -112,22 +102,13 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
112
102
canClick = false ;
113
103
}
114
104
115
- const isPrivateApp = app . sharing_level === "owner" ;
116
-
117
- return (
118
- < Tooltip title = { primaryTooltip } >
119
- < Link
120
- color = "inherit"
121
- component = { AgentButton }
122
- startIcon = { icon }
123
- endIcon = { isPrivateApp ?undefined :< ShareIcon app = { app } /> }
124
- disabled = { ! canClick }
125
- href = { href }
126
- css = { {
127
- pointerEvents :canClick ?undefined :"none" ,
128
- textDecoration :"none !important" ,
129
- } }
130
- onClick = { async ( event :MouseEvent < HTMLElement > ) => {
105
+ const canShare = app . sharing_level !== "owner" ;
106
+
107
+ const button = (
108
+ < AgentButton asChild >
109
+ < a
110
+ href = { canClick ?href :undefined }
111
+ onClick = { async ( event ) => {
131
112
if ( ! canClick ) {
132
113
return ;
133
114
}
@@ -187,8 +168,23 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
187
168
}
188
169
} }
189
170
>
171
+ { icon }
190
172
{ appDisplayName }
191
- </ Link >
192
- </ Tooltip >
173
+ { canShare && < ShareIcon app = { app } /> }
174
+ </ a >
175
+ </ AgentButton >
193
176
) ;
177
+
178
+ if ( primaryTooltip ) {
179
+ return (
180
+ < TooltipProvider >
181
+ < Tooltip >
182
+ < TooltipTrigger asChild > { button } </ TooltipTrigger >
183
+ < TooltipContent > { primaryTooltip } </ TooltipContent >
184
+ </ Tooltip >
185
+ </ TooltipProvider >
186
+ ) ;
187
+ }
188
+
189
+ return button ;
194
190
} ;