Skip to content

Commit

Permalink
added file size prop
Browse files Browse the repository at this point in the history
  • Loading branch information
MVarshini committed Jan 10, 2024
1 parent 473e19d commit 29944a1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions dashboard/src/actions/tocActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const fetchTOC =
if (!isSubDir) {
const inventoryLink = uriTemplate(endpoints, "datasets_inventory", {
dataset: datasetId,
target: "",
target: path,
});
dispatch({
type: TYPES.SET_INVENTORY_LINK,
Expand All @@ -45,7 +45,7 @@ export const fetchTOC =
dispatch({ type: TYPES.COMPLETED });
};

const setOptions = (data, isParent, keyPath, isDirectory) => {
const makeOptions = (data, isParent, keyPath, isDirectory) => {
const options = data.map((item) => ({
name: item.name,
id: isParent ? `${keyPath}*${item.name}` : item.name,
Expand All @@ -56,6 +56,14 @@ const setOptions = (data, isParent, keyPath, isDirectory) => {
options.forEach((opt) => {
opt["children"] = [];
});
} else {
data.forEach((item) => {
options.forEach((opt) => {
if (item.name === opt.name) {
opt["size"] = item.size;
}
});
});
}
return options;
};
Expand All @@ -72,13 +80,13 @@ export const parseToTreeView =
(contentData, activeItem, isSubDir, parent) => (dispatch, getState) => {
const keyPath = parent.replaceAll("/", "*");
const drillMenuData = [...getState().toc.drillMenuData];
const directories = setOptions(
const directories = makeOptions(
contentData.directories,
parent,
keyPath,
true
);
const files = setOptions(contentData.files, parent, keyPath, false);
const files = makeOptions(contentData.files, parent, keyPath, false);
const treeOptions = [...directories, ...files];
if (isSubDir) {
if (activeItem.includes("*")) {
Expand Down

0 comments on commit 29944a1

Please sign in to comment.