From a9c97e85647f504c825f5ba51e4357cd9957a3d6 Mon Sep 17 00:00:00 2001 From: Omkar Phansopkar Date: Mon, 2 Oct 2023 18:28:34 +0530 Subject: [PATCH] Fixed #542 file icon being shown for empty directories Signed-off-by: Omkar Phansopkar --- package-lock.json | 24 +++++++++---------- package.json | 2 +- src/services/workbenchDB.ts | 1 + tests/test-scans/fileTree/expectedFileTree.ts | 11 +++++++++ 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 78506f18..59f68147 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,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", @@ -20963,15 +20963,15 @@ } }, "node_modules/rc-tree": { - "version": "5.7.2", - "resolved": "https://registry.npmjs.org/rc-tree/-/rc-tree-5.7.2.tgz", - "integrity": "sha512-nmnL6qLnfwVckO5zoqKL2I9UhwDqzyCtjITQCkwhimyz1zfuFkG5ZPIXpzD/Guzso94qQA/QrMsvzic5W6QDjg==", + "version": "5.7.12", + "resolved": "https://registry.npmjs.org/rc-tree/-/rc-tree-5.7.12.tgz", + "integrity": "sha512-LXA5nY2hG5koIAlHW5sgXgLpOMz+bFRbnZZ+cCg0tQs4Wv1AmY7EDi1SK7iFXhslYockbqUerQan82jljoaItg==", "dependencies": { "@babel/runtime": "^7.10.1", "classnames": "2.x", "rc-motion": "^2.0.1", "rc-util": "^5.16.1", - "rc-virtual-list": "^3.4.8" + "rc-virtual-list": "^3.5.1" }, "engines": { "node": ">=10.x" @@ -20982,9 +20982,9 @@ } }, "node_modules/rc-util": { - "version": "5.28.0", - "resolved": "https://registry.npmjs.org/rc-util/-/rc-util-5.28.0.tgz", - "integrity": "sha512-KYDjhGodswVj29v0TRciKTqRPgumIFvFDndbCD227pitQ+0Cei196rxk+OXb/blu6V8zdTRK5RjCJn+WmHLvBA==", + "version": "5.37.0", + "resolved": "https://registry.npmjs.org/rc-util/-/rc-util-5.37.0.tgz", + "integrity": "sha512-cPMV8DzaHI1KDaS7XPRXAf4J7mtBqjvjikLpQieaeOO7+cEbqY2j7Kso/T0R0OiEZTNcLS/8Zl9YrlXiO9UbjQ==", "dependencies": { "@babel/runtime": "^7.18.3", "react-is": "^16.12.0" @@ -20995,14 +20995,14 @@ } }, "node_modules/rc-virtual-list": { - "version": "3.4.13", - "resolved": "https://registry.npmjs.org/rc-virtual-list/-/rc-virtual-list-3.4.13.tgz", - "integrity": "sha512-cPOVDmcNM7rH6ANotanMDilW/55XnFPw0Jh/GQYtrzZSy3AmWvCnqVNyNC/pgg3lfVmX2994dlzAhuUrd4jG7w==", + "version": "3.11.2", + "resolved": "https://registry.npmjs.org/rc-virtual-list/-/rc-virtual-list-3.11.2.tgz", + "integrity": "sha512-MTFLL2LOHr3+/+r+WjTIs6j8XmJE6EqdOsJvCH8SWig7qyik3aljCEImUtw5tdWR0tQhXUfbv7P7nZaLY91XPg==", "dependencies": { "@babel/runtime": "^7.20.0", "classnames": "^2.2.6", "rc-resize-observer": "^1.0.0", - "rc-util": "^5.15.0" + "rc-util": "^5.36.0" }, "engines": { "node": ">=8.x" diff --git a/package.json b/package.json index df40ec07..bf16dce2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/services/workbenchDB.ts b/src/services/workbenchDB.ts index d94223eb..815e278a 100644 --- a/src/services/workbenchDB.ts +++ b/src/services/workbenchDB.ts @@ -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", diff --git a/tests/test-scans/fileTree/expectedFileTree.ts b/tests/test-scans/fileTree/expectedFileTree.ts index 3630d2dc..43598a39 100644 --- a/tests/test-scans/fileTree/expectedFileTree.ts +++ b/tests/test-scans/fileTree/expectedFileTree.ts @@ -87,6 +87,7 @@ export const FileTreeSamples: { parent: "#", name: null, type: "directory", + isLeaf: false, children: [ { id: 2, @@ -96,6 +97,7 @@ export const FileTreeSamples: { parent: "manifests", name: null, type: "directory", + isLeaf: false, children: [ { id: 4, @@ -105,6 +107,7 @@ export const FileTreeSamples: { parent: "manifests/folder1", name: null, type: "directory", + isLeaf: false, children: [ { id: 5, @@ -114,6 +117,7 @@ export const FileTreeSamples: { parent: "manifests/folder1/folder2", name: null, type: "file", + isLeaf: true, }, ], }, @@ -125,6 +129,7 @@ export const FileTreeSamples: { parent: "manifests/folder1", name: null, type: "file", + isLeaf: true, }, ], }, @@ -136,6 +141,7 @@ export const FileTreeSamples: { parent: "manifests", name: null, type: "directory", + isLeaf: false, children: [ { id: 7, @@ -145,6 +151,7 @@ export const FileTreeSamples: { parent: "manifests/folder3", name: null, type: "file", + isLeaf: true, }, ], }, @@ -156,6 +163,7 @@ export const FileTreeSamples: { parent: "manifests", name: null, type: "file", + isLeaf: true, }, { id: 8, @@ -165,6 +173,7 @@ export const FileTreeSamples: { parent: "manifests", name: null, type: "file", + isLeaf: true, }, ], }, @@ -190,6 +199,7 @@ export const FileTreeSamples: { parent: "#", name: null, type: "directory", + isLeaf: false, children: [], }, ], @@ -214,6 +224,7 @@ export const FileTreeSamples: { parent: "#", name: null, type: "file", + isLeaf: true, }, ], },