Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,18 @@ export default class ModuleList extends React.PureComponent<Props> {
prefixedPath,
files,
} = this.props;

const filesToShow: { path: string }[] = [];
const directoriesToShow: Set<string> = new Set();
const pathParts = prefixedPath.split('/');

Object.keys(files).forEach(path => {
if (path.startsWith(prefixedPath)) {
const filePathParts = path.split('/');

if (filePathParts.length === pathParts.length) {
if (path.endsWith('/')) {
directoriesToShow.add(path);
} else {
filesToShow.push({ path });
}
} else if (filePathParts.length === pathParts.length + 1) {
filePathParts.pop();
directoriesToShow.add(filePathParts.join('/') + '/');
}
}
});

const fileListWithoutPrefix = Object.keys(files)
.filter(file => file.startsWith(prefixedPath))
.map(file => file.substring(prefixedPath.length));

const directoriesToShow = new Set(fileListWithoutPrefix
.filter(file => file.includes('/'))
.map(file => `${prefixedPath}${file.split('/')[0]}/`));

const filesToShow = fileListWithoutPrefix
.filter(file => !file.includes('/'))
.map(file => ({ path: `${prefixedPath}${file}` }));

return (
<div style={{ marginLeft: `${0.5 * depth}rem` }}>
Expand Down