mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-02-22 22:28:15 +00:00
fix: Handle null process groups in findProcessGroupByPath
This commit is contained in:
parent
57c7829cd4
commit
39c62b9c0e
@ -243,7 +243,7 @@ export default function ProcessModelTreePage({
|
||||
};
|
||||
|
||||
function findProcessGroupByPath(
|
||||
groupsToProcess: ProcessGroup[] | ProcessGroupLite[],
|
||||
groupsToProcess: ProcessGroup[] | ProcessGroupLite[] | null,
|
||||
path: string,
|
||||
): ProcessGroupLite | undefined {
|
||||
const levels = path.split('/');
|
||||
@ -256,12 +256,36 @@ export default function ProcessModelTreePage({
|
||||
} else {
|
||||
assembledGroups = `${assembledGroups}/${level}`;
|
||||
}
|
||||
currentGroup = (
|
||||
(currentGroup ? currentGroup.process_groups : groupsToProcess) || []
|
||||
).find(
|
||||
(processGroup: ProcessGroup | ProcessGroupLite) =>
|
||||
processGroup.id === assembledGroups,
|
||||
);
|
||||
|
||||
// let newGroups = currentGroup
|
||||
// ? currentGroup.process_groups
|
||||
// : groupsToProcess;
|
||||
|
||||
// works
|
||||
// let newGroups = currentGroup ? currentGroup.process_groups : [];
|
||||
|
||||
let newGroups: ProcessGroupLite[] | ProcessGroup[] = [];
|
||||
if (currentGroup && currentGroup.process_groups !== undefined) {
|
||||
newGroups = currentGroup.process_groups;
|
||||
} else if (groupsToProcess) {
|
||||
newGroups = groupsToProcess;
|
||||
}
|
||||
|
||||
// currentGroup
|
||||
// ? currentGroup.process_groups
|
||||
// : groupsToProcess;
|
||||
|
||||
if (!newGroups) {
|
||||
newGroups = [];
|
||||
}
|
||||
if (newGroups === null) {
|
||||
newGroups = [];
|
||||
}
|
||||
if (newGroups && Array.isArray(newGroups)) {
|
||||
currentGroup = newGroups.find(
|
||||
(processGroup: any) => processGroup.id === assembledGroups,
|
||||
);
|
||||
}
|
||||
if (!currentGroup) {
|
||||
return undefined;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user