11import { useTheme } from "@emotion/react" ;
22import 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" ;
63import { API } from "api/api" ;
74import type * as TypesGen from "api/typesGenerated" ;
85import { 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" ;
913import { useProxy } from "contexts/ProxyContext" ;
10- import { type FC , type MouseEvent , useState } from "react" ;
14+ import { type FC , useState } from "react" ;
1115import { createAppLinkHref } from "utils/apps" ;
1216import { generateRandomString } from "utils/random" ;
1317import { AgentButton } from "../AgentButton" ;
@@ -75,21 +79,7 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
7579
7680let primaryTooltip = "" ;
7781if ( 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 /> ;
9383primaryTooltip = "Initializing..." ;
9484}
9585if ( app . health === "unhealthy" ) {
@@ -112,22 +102,13 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
112102canClick = false ;
113103}
114104
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 ) => {
131112if ( ! canClick ) {
132113return ;
133114}
@@ -187,8 +168,23 @@ export const AppLink: FC<AppLinkProps> = ({ app, workspace, agent }) => {
187168}
188169} }
189170>
171+ { icon }
190172{ appDisplayName }
191- </ Link >
192- </ Tooltip >
173+ { canShare && < ShareIcon app = { app } /> }
174+ </ a >
175+ </ AgentButton >
193176) ;
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 ;
194190} ;