@@ -13,19 +13,23 @@ const CloneTabs = ({ endpoint }: any) => {
1313 const [ copied , setCopied ] = useState < boolean > ( false )
1414 const [ active_tab , setActiveTab ] = useState < string > ( 'HTTP' )
1515 const [ open , setOpen ] = useState ( false )
16+ const [ repo_name , setRepo_name ] = useState < string > ( '' )
1617 const url = new URL ( MONO_API_URL )
1718
1819 useEffect ( ( ) => {
1920 if ( MONO_API_URL ) {
2021 const url = new URL ( MONO_API_URL )
2122
22- if ( active_tab === '1' ) {
23- setText ( `${ url . href } ${ pathname ?. replace ( '/myorganization/code/tree/' , '' ) } .git` )
24- } else {
25- setText ( `ssh://git@${ url . host } ${ pathname ?. replace ( '/myorganization/code/tree' , '' ) } .git` )
23+ setRepo_name ( pathname ?. split ( "/code/tree/" ) [ 1 ] ! ! )
24+
25+ if ( active_tab === 'HTTP' ) {
26+ setText ( `${ url . href } ${ repo_name } .git` )
27+ }
28+ if ( active_tab === 'SSH' ) {
29+ setText ( `ssh://git@${ url . host } /${ repo_name } .git` )
2630 }
2731 }
28- } , [ pathname , active_tab , endpoint ] )
32+ } , [ pathname , active_tab , endpoint , repo_name ] )
2933
3034 const handleCopy = ( ) => {
3135 copy ( text )
@@ -36,20 +40,20 @@ const CloneTabs = ({ endpoint }: any) => {
3640 const tabContent = [
3741 {
3842 value : 'HTTP' ,
39- inputValue : `${ url . href } ${ pathname ?. replace ( '/myorganization/code/tree/' , '' ) } .git` ,
43+ inputValue : `${ url . href } ${ repo_name } .git` ,
4044 info : 'Clone using the web URL.'
4145 } ,
4246 {
4347 value : 'SSH' ,
44- inputValue : `ssh://git@${ url . host } ${ pathname ?. replace ( '/myorganization/code/tree' , '' ) } .git` ,
48+ inputValue : `ssh://git@${ url . host } / ${ repo_name } .git` ,
4549 info : 'Use a password-protected SSH key.'
4650 }
4751 ]
4852
4953 return (
5054 < >
51- < Popover open = { open } onOpenChange = { setOpen } modal >
52- < PopoverTrigger asChild >
55+ < Popover open = { open } onOpenChange = { setOpen } >
56+ < PopoverTrigger >
5357 < Button variant = 'base' >
5458 < Flex gap = '3' >
5559 < DownloadIcon />
@@ -69,7 +73,7 @@ const CloneTabs = ({ endpoint }: any) => {
6973 asChild
7074 addDismissibleLayer
7175 >
72- < Tabs . Root defaultValue = 'HTTP' onValueChange = { setActiveTab } >
76+ < Tabs . Root defaultValue = { active_tab } onValueChange = { setActiveTab } >
7377 < Tabs . List size = '1' className = 'p-2' >
7478 < Tabs . Trigger value = 'HTTP' >
7579 < Button variant = { active_tab === 'HTTP' ? 'flat' : 'plain' } > HTTP</ Button >
@@ -82,7 +86,6 @@ const CloneTabs = ({ endpoint }: any) => {
8286 { tabContent ?. map ( ( _item ) => {
8387 return (
8488 < Tabs . Content value = { _item . value } key = { _item . value } >
85- < Flex direction = 'column' >
8689 < Flex align = 'center' >
8790 < input
8891 value = { _item . inputValue }
@@ -94,7 +97,6 @@ const CloneTabs = ({ endpoint }: any) => {
9497 </ Button >
9598 </ Flex >
9699 < div className = 'ml-2 text-gray-500' > { _item . info } </ div >
97- </ Flex >
98100 </ Tabs . Content >
99101 )
100102 } ) }
0 commit comments