mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-02-23 06:38:24 +00:00
refactor: simplify findProcessGroupByPath function
This commit is contained in:
parent
11ce256363
commit
236c6d70ac
@ -265,38 +265,19 @@ export default function ProcessModelTreePage({
|
|||||||
const levels = path.split('/');
|
const levels = path.split('/');
|
||||||
let currentGroup: ProcessGroupLite | undefined;
|
let currentGroup: ProcessGroupLite | undefined;
|
||||||
|
|
||||||
let assembledGroups = '';
|
let newGroups: ProcessGroupLite[] = [];
|
||||||
levels.forEach((level: string) => {
|
if (groupsToProcess) {
|
||||||
if (assembledGroups === '') {
|
|
||||||
assembledGroups = level;
|
|
||||||
} else {
|
|
||||||
assembledGroups = `${assembledGroups}/${level}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
let newGroups: ProcessGroupLite[] = [];
|
|
||||||
if (currentGroup && currentGroup.process_groups !== undefined) {
|
|
||||||
newGroups = currentGroup.process_groups;
|
|
||||||
} else if (groupsToProcess) {
|
|
||||||
newGroups = groupsToProcess;
|
newGroups = groupsToProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!newGroups) {
|
for (const level of levels) {
|
||||||
newGroups = [];
|
const assembledPath = levels.slice(0, levels.indexOf(level) + 1).join('/');
|
||||||
}
|
currentGroup = newGroups.find((processGroup: any) => processGroup.id === assembledPath);
|
||||||
if (newGroups === null) {
|
|
||||||
newGroups = [];
|
|
||||||
}
|
|
||||||
if (newGroups && Array.isArray(newGroups)) {
|
|
||||||
currentGroup = newGroups.find(
|
|
||||||
(processGroup: any) => processGroup.id === assembledGroups,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (!currentGroup) {
|
if (!currentGroup) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
return currentGroup;
|
newGroups = currentGroup.process_groups || [];
|
||||||
});
|
}
|
||||||
|
|
||||||
return currentGroup;
|
return currentGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user