Skip to content

Commit

Permalink
Fixed #542 file icon being shown for empty directories
Browse files Browse the repository at this point in the history
Signed-off-by: Omkar Phansopkar <[email protected]>
  • Loading branch information
OmkarPh committed Oct 2, 2023
1 parent f39c86a commit a9c97e8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"nock": "^13.3.0",
"pg": "^8.10.0",
"pg-hstore": "^2.3.4",
"rc-tree": "^5.7.0",
"rc-tree": "^5.7.12",
"react": "^18.2.0",
"react-bootstrap": "^2.5.0",
"react-chartjs-2": "^5.2.0",
Expand Down
1 change: 1 addition & 0 deletions src/services/workbenchDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ export class WorkbenchDB {
parent: file.getDataValue("parent"),
name: file.getDataValue("name"),
type: fileType,
isLeaf: fileType == "file",
...(fileType == "directory" && { children: [] }),
// @TODO - Trial to fix rc-tree showing file icon instead of empty directory https://github.com/nexB/scancode-workbench/issues/542
// isLeaf: fileType == "file",
Expand Down
11 changes: 11 additions & 0 deletions tests/test-scans/fileTree/expectedFileTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const FileTreeSamples: {
parent: "#",
name: null,
type: "directory",
isLeaf: false,
children: [
{
id: 2,
Expand All @@ -96,6 +97,7 @@ export const FileTreeSamples: {
parent: "manifests",
name: null,
type: "directory",
isLeaf: false,
children: [
{
id: 4,
Expand All @@ -105,6 +107,7 @@ export const FileTreeSamples: {
parent: "manifests/folder1",
name: null,
type: "directory",
isLeaf: false,
children: [
{
id: 5,
Expand All @@ -114,6 +117,7 @@ export const FileTreeSamples: {
parent: "manifests/folder1/folder2",
name: null,
type: "file",
isLeaf: true,
},
],
},
Expand All @@ -125,6 +129,7 @@ export const FileTreeSamples: {
parent: "manifests/folder1",
name: null,
type: "file",
isLeaf: true,
},
],
},
Expand All @@ -136,6 +141,7 @@ export const FileTreeSamples: {
parent: "manifests",
name: null,
type: "directory",
isLeaf: false,
children: [
{
id: 7,
Expand All @@ -145,6 +151,7 @@ export const FileTreeSamples: {
parent: "manifests/folder3",
name: null,
type: "file",
isLeaf: true,
},
],
},
Expand All @@ -156,6 +163,7 @@ export const FileTreeSamples: {
parent: "manifests",
name: null,
type: "file",
isLeaf: true,
},
{
id: 8,
Expand All @@ -165,6 +173,7 @@ export const FileTreeSamples: {
parent: "manifests",
name: null,
type: "file",
isLeaf: true,
},
],
},
Expand All @@ -190,6 +199,7 @@ export const FileTreeSamples: {
parent: "#",
name: null,
type: "directory",
isLeaf: false,
children: [],
},
],
Expand All @@ -214,6 +224,7 @@ export const FileTreeSamples: {
parent: "#",
name: null,
type: "file",
isLeaf: true,
},
],
},
Expand Down

0 comments on commit a9c97e8

Please sign in to comment.