Skip to content

Commit a0e5cbe

Browse files
authored
fix(UI): fix TreeView layout (#1400)
fix(UI): change CloneTabs path
1 parent 1fd56fb commit a0e5cbe

5 files changed

Lines changed: 47 additions & 40 deletions

File tree

moon/apps/web/components/CodeView/BlobView/CodeContent.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ const CodeContent = ({ fileContent, path }: { fileContent: string; path?: string
220220
style={{
221221
backgroundColor: selectedLine === i ? '#f0f7ff' : 'transparent'
222222
}}
223-
className='flex'
223+
className='flex justify-self-auto'
224224
onClick={() => handleLineClick(i)}
225225
>
226226
<span className='inline-block w-8'>
@@ -242,10 +242,12 @@ const CodeContent = ({ fileContent, path }: { fileContent: string; path?: string
242242
null}
243243
</span>
244244
<span className={styles.codeLineNumber}>{i + 1}</span>
245-
{line.map((token, key) => (
246-
// eslint-disable-next-line react/no-array-index-key
247-
<span key={key} {...getTokenProps({ token })} />
248-
))}
245+
<span className="max-w-[80%]">
246+
{line.map((token, key) => (
247+
// eslint-disable-next-line react/no-array-index-key
248+
<span key={key} {...getTokenProps({ token })} />
249+
))}
250+
</span>
249251
</div>
250252
))}
251253
{lfs && <span>(Sorry about that, but we can’t show files that are this big right now.)</span>}

moon/apps/web/components/CodeView/TreeView/CloneTabs.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -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
})}

moon/apps/web/components/CodeView/TreeView/RepoTree.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const handleNodeToggle = useCallback((_event: React.SyntheticEvent | null, nodeI
134134
items={treeAllData}
135135
expandedItems={expandedNodes}
136136
onExpandedItemsChange={handleNodeToggle}
137-
sx={{ height: 'fit-content', flexGrow: 1, width: 400, overflow: 'auto' }}
137+
sx={{ height: 'fit-content', flexGrow: 1, width: '100%', overflow: 'auto' }}
138138
slots={{
139139
item: (itemProps) => (
140140
<CustomTreeItem

moon/apps/web/pages/[org]/code/blob/[...path].tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ import { Theme } from '@radix-ui/themes'
1212

1313
const codeStyle = {
1414
borderRadius: 8,
15+
width: '80%',
1516
background: '#fff',
16-
border: '1px solid #d1d9e0',
17-
margin: '0 8px',
18-
flexGrow: 1,
19-
minWidth: 0
17+
height: 'calc(100vh - 96px)',
18+
overflow: 'auto',
19+
paddingRight: '8px'
2020
}
2121

2222
const treeStyle = {
2323
borderRadius: 8,
24-
overflow: 'hidden',
25-
width: '400px',
26-
background: '#fff'
24+
width: '20%',
25+
minWidth: '300px',
26+
flexShrink: 0,
27+
background: '#fff',
28+
height: 'calc(100vh - 96px)',
29+
overflow: 'auto',
30+
paddingRight: '8px'
2731
}
2832

2933
function BlobPage() {
@@ -42,7 +46,7 @@ function BlobPage() {
4246

4347
return (
4448
<Theme>
45-
<div className='relative m-4 h-screen overflow-auto'>
49+
<div className='relative m-4 h-screen'>
4650
<BreadCrumb path={path} />
4751
{/* tree */}
4852
<div className='flex gap-4'>
@@ -54,11 +58,7 @@ function BlobPage() {
5458
<div className='m-2'>
5559
<CommitHistory flag={'details'} info={commitInfo} />
5660
</div>
57-
<div className='flex w-full flex-wrap gap-4'>
58-
<div style={codeStyle}>
59-
<CodeContent fileContent={fileContent} path={path} />
60-
</div>
61-
</div>
61+
<CodeContent fileContent={fileContent} path={path} />
6262
</div>
6363
</div>
6464
</div>

moon/apps/web/pages/[org]/code/tree/[...path]/index.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,28 @@ function TreeDetailPage() {
4545

4646
const treeStyle = {
4747
borderRadius: 8,
48-
width: '400px',
49-
minWidth: '0px',
48+
width: '20%',
49+
minWidth: '300px',
5050
flexShrink: 0,
51-
background: '#fff'
51+
background: '#fff',
52+
height: 'calc(100vh - 96px)',
53+
overflow: 'auto',
54+
paddingRight: '8px'
5255
}
5356

5457
const codeStyle = {
5558
borderRadius: 8,
56-
overflow: 'hidden',
5759
width: 'calc(80% - 8px)',
58-
height: '100%',
59-
background: '#fff'
60+
background: '#fff',
61+
height: 'calc(100vh - 96px)',
62+
overflow: 'auto',
63+
paddingRight: '8px'
6064
}
6165

6266
return (
6367
<Theme>
64-
<div className='relative m-4 h-screen overflow-auto'>
65-
<div className='h-12 flex justify-between items-center'>
68+
<div className='relative m-4 h-screen'>
69+
<div className='h-12 flex justify-between items-center'>
6670
<BreadCrumb path={path} />
6771
{canClone?.data && (
6872
<div className='m-1 flex justify-end'>
@@ -71,7 +75,6 @@ function TreeDetailPage() {
7175
)}
7276
</div>
7377
<div className='flex gap-4'>
74-
{/* tree */}
7578
<div style={treeStyle}>
7679
<RepoTree onCommitInfoChange={(path: string) => setNewPath(path)} />
7780
</div>

0 commit comments

Comments
 (0)