diff --git a/.changes/unreleased/Docs-20230806-191713.yaml b/.changes/unreleased/Docs-20230806-191713.yaml new file mode 100644 index 00000000..9fab03c7 --- /dev/null +++ b/.changes/unreleased/Docs-20230806-191713.yaml @@ -0,0 +1,6 @@ +kind: Docs +body: Fix crash when folder had the same name as a macro +time: 2023-08-06T19:17:13.611347561Z +custom: + Author: etnnth + Issue: "442" diff --git a/src/app/services/project_service.js b/src/app/services/project_service.js index 3ec2620a..99d641bc 100644 --- a/src/app/services/project_service.js +++ b/src/app/services/project_service.js @@ -687,11 +687,7 @@ angular var dirpath = _.initial(path); - if (node.resource_type == 'macro') { - var fname = node.name; - } else { - var fname = _.last(path); - } + var fname = `${node.resource_type}.${_.last(path)}.${node.name}`; if (node.resource_type == 'model' && node.version != null) { var display_name = node.name + "_v" + node.version; @@ -701,17 +697,18 @@ angular var cur_dir = tree; _.each(dirpath, function(dir) { - if (!cur_dir[dir]) { - cur_dir[dir] = { + var dname = `dir.${dir}` + if (!cur_dir[dname]) { + cur_dir[dname] = { type: 'folder', name: dir, active: is_active, items: {} }; } else if (is_active) { - cur_dir[dir].active = true; + cur_dir[dname].active = true; } - cur_dir = cur_dir[dir].items; + cur_dir = cur_dir[dname].items; }) cur_dir[fname] = { type: 'file',