-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathBranchDirEntry.jsx
45 lines (36 loc) · 1017 Bytes
/
BranchDirEntry.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import PropTypes from 'prop-types'
import qs from 'qs'
import { useLocation } from 'react-router-dom'
import { usePrefetchBranchDirEntry } from 'services/pathContents/branch/dir'
import DirEntry from '../BaseEntries/DirEntry'
function BranchDirEntry({ branch, urlPath, name }) {
const location = useLocation()
const queryParams = qs.parse(location.search, {
ignoreQueryPrefix: true,
depth: 1,
})
const filters = {
...(queryParams?.flags ? { flags: queryParams.flags } : {}),
...(queryParams?.components ? { components: queryParams.components } : {}),
}
const { runPrefetch } = usePrefetchBranchDirEntry({
branch,
path: name,
filters,
})
return (
<DirEntry
linkRef={branch}
name={name}
urlPath={urlPath}
runPrefetch={runPrefetch}
queryParams={filters}
/>
)
}
BranchDirEntry.propTypes = {
branch: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
urlPath: PropTypes.string,
}
export default BranchDirEntry