Skip to content

Commit

Permalink
* Applied changes from decap PR for non-index files decaporg/decap-cm…
Browse files Browse the repository at this point in the history
  • Loading branch information
Net-Slayer committed Dec 8, 2023
1 parent 13f42e0 commit fae2a10
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
7 changes: 4 additions & 3 deletions packages/core/src/components/collections/NestedCollection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ const TreeNode = ({
return (
<>
{sortedData.map(node => {
const leaf = node.children.length <= 1 && !node.children[0]?.isDir && depth > 0;
// const leaf = node.children.length <= 1 && !node.children[0]?.isDir && depth > 0;
const leaf = node.children.length === 0 && depth > 0;
if (leaf) {
return null;
}
Expand All @@ -93,8 +94,8 @@ const TreeNode = ({
}
const title = getNodeTitle(node);

const hasChildren = depth === 0 || node.children.some(c => c.children.some(c => c.isDir));

// const hasChildren = depth === 0 || node.children.some(c => c.children.some(c => c.isDir));
const hasChildren = depth === 0 || node.children.some(c => c.isDir);
return (
<Fragment key={node.path}>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,22 @@ function getGroupTitle(group: GroupOfEntries, t: t) {

export function filterNestedEntries(path: string, collectionFolder: string, entries: Entry[]) {
const filtered = entries.filter(e => {
const entryPath = e.path.slice(collectionFolder.length + 1);
let entryPath = e.path.slice(collectionFolder.length + 1);
if (!entryPath.startsWith(path)) {
return false;
}

// only show immediate children
if (path) {
// non root path
const trimmed = entryPath.slice(path.length + 1);
return trimmed.split('/').length === 2;
} else {
// root path
return entryPath.split('/').length <= 2;
// // non root path
// const trimmed = entryPath.slice(path.length + 1);
// return trimmed.split('/').length === 2;
// } else {
// // root path
// return entryPath.split('/').length <= 2;
entryPath = entryPath.slice(path.length + 1);
}
return !entryPath.includes('/');
});
return filtered;
}
Expand Down

0 comments on commit fae2a10

Please sign in to comment.