Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
750 bytes
|
Line | |
---|
1 | const React = require('react');
|
---|
2 |
|
---|
3 | module.exports = function FileBreadcrumbs({ fileFilter = '', setFileFilter }) {
|
---|
4 | const parts = fileFilter.split('/');
|
---|
5 | const breadcrumbs = [
|
---|
6 | {
|
---|
7 | path: '',
|
---|
8 | name: 'all files'
|
---|
9 | },
|
---|
10 | ...parts.map((part, i) => ({
|
---|
11 | path: parts.slice(0, i + 1).join('/'),
|
---|
12 | name: part
|
---|
13 | }))
|
---|
14 | ];
|
---|
15 |
|
---|
16 | return breadcrumbs.map(({ path, name }) =>
|
---|
17 | path === fileFilter ? (
|
---|
18 | name
|
---|
19 | ) : (
|
---|
20 | <>
|
---|
21 | <a
|
---|
22 | href="javascript:void(0)"
|
---|
23 | onClick={() => setFileFilter(path)}
|
---|
24 | >
|
---|
25 | {name}
|
---|
26 | </a>
|
---|
27 | /
|
---|
28 | </>
|
---|
29 | )
|
---|
30 | );
|
---|
31 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.