You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
750 B
32 lines
750 B
|
3 years ago
|
const React = require('react');
|
||
|
|
|
||
|
|
module.exports = function FileBreadcrumbs({ fileFilter = '', setFileFilter }) {
|
||
|
|
const parts = fileFilter.split('/');
|
||
|
|
const breadcrumbs = [
|
||
|
|
{
|
||
|
|
path: '',
|
||
|
|
name: 'all files'
|
||
|
|
},
|
||
|
|
...parts.map((part, i) => ({
|
||
|
|
path: parts.slice(0, i + 1).join('/'),
|
||
|
|
name: part
|
||
|
|
}))
|
||
|
|
];
|
||
|
|
|
||
|
|
return breadcrumbs.map(({ path, name }) =>
|
||
|
|
path === fileFilter ? (
|
||
|
|
name
|
||
|
|
) : (
|
||
|
|
<>
|
||
|
|
<a
|
||
|
|
href="javascript:void(0)"
|
||
|
|
onClick={() => setFileFilter(path)}
|
||
|
|
>
|
||
|
|
{name}
|
||
|
|
</a>
|
||
|
|
/
|
||
|
|
</>
|
||
|
|
)
|
||
|
|
);
|
||
|
|
};
|