1- import { ButtonLink } from "@lib/components/Button" ;
1+ import { Button } from "@lib/components/Button" ;
22import { useTooltip } from "@lib/hooks/useTooltip" ;
33import { getSupportedIntegration } from "@lib/integrations" ;
44import { EIntegrationParseError } from "@lib/integrations/error" ;
@@ -7,8 +7,9 @@ import { PortalProps } from "@lib/utils/dom/portal";
77import { EError , ENoIntegrationError } from "@lib/utils/error" ;
88import { ModalErrorBoundaryProvider } from "@lib/wrappers/ErrorBoundary" ;
99import { DevPodLogo } from "@src/icons/devpod" ;
10- import { StrictMode } from "react" ;
10+ import { StrictMode , useCallback } from "react" ;
1111import { createPortal } from "react-dom" ;
12+ import { useErrorBoundary } from "react-error-boundary" ;
1213
1314export function getDevPodUrl ( url : string ) {
1415 try {
@@ -32,7 +33,7 @@ export function getDevPodUrl(url: string) {
3233 const { hostname, protocol } = new URL ( url ) ;
3334
3435 const branchSuffix = branch ? `@${ branch } ` : "" ;
35- return `https://devpod.sh/open#${ protocol } : //${ hostname } /${ repo } ${ branchSuffix } ` ;
36+ return `https://devpod.sh/open#${ protocol } //${ hostname } /${ repo } ${ branchSuffix } ` ;
3637 } catch ( error ) {
3738 console . error ( EError . serialize ( error ) ) ;
3839 throw error ;
@@ -44,23 +45,29 @@ function CloneButtonInner({
4445 className,
4546} : PortalProps & { className ?: string } ) {
4647 const { isHovering, bindTarget, bindTooltip } =
47- useTooltip < HTMLAnchorElement > ( ) ;
48+ useTooltip < HTMLButtonElement > ( ) ;
49+ const { showBoundary : showError } = useErrorBoundary ( ) ;
4850
49- const link = getDevPodUrl ( window . location . href ) ;
51+ const clone = useCallback ( ( ) => {
52+ try {
53+ const link = getDevPodUrl ( window . location . href ) ;
54+ window . open ( link , "_blank" , "noreferrer" ) ;
55+ } catch ( error ) {
56+ showError ( error ) ;
57+ }
58+ } , [ showError ] ) ;
5059
5160 return (
5261 < div className = "flex justify-center items-center" >
53- < ButtonLink
54- rel = "noreferrer"
55- target = "_blank"
56- href = { link }
62+ < Button
63+ onClick = { clone }
5764 color = "primary"
5865 { ...bindTarget }
5966 className = { className }
6067 >
6168 < DevPodLogo aria-label = "" className = "w-6 h-6 text-primary-contrast" /> { " " }
6269 DevPod
63- </ ButtonLink >
70+ </ Button >
6471 { createPortal (
6572 < div
6673 className = { clsx (
0 commit comments