mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-02-23 14:48:35 +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(
|
function findProcessGroupByPath(
|
||||||
groupsToProcess: ProcessGroup[] | ProcessGroupLite[],
|
groupsToProcess: ProcessGroup[] | ProcessGroupLite[] | null,
|
||||||
path: string,
|
path: string,
|
||||||
): ProcessGroupLite | undefined {
|
): ProcessGroupLite | undefined {
|
||||||
const levels = path.split('/');
|
const levels = path.split('/');
|
||||||
@ -256,12 +256,36 @@ export default function ProcessModelTreePage({
|
|||||||
} else {
|
} else {
|
||||||
assembledGroups = `${assembledGroups}/${level}`;
|
assembledGroups = `${assembledGroups}/${level}`;
|
||||||
}
|
}
|
||||||
currentGroup = (
|
|
||||||
(currentGroup ? currentGroup.process_groups : groupsToProcess) || []
|
// let newGroups = currentGroup
|
||||||
).find(
|
// ? currentGroup.process_groups
|
||||||
(processGroup: ProcessGroup | ProcessGroupLite) =>
|
// : groupsToProcess;
|
||||||
processGroup.id === assembledGroups,
|
|
||||||
|
// 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) {
|
if (!currentGroup) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user