Skip to content

fix: Fixed the list display bug caused by more than 200 cloud functions #2035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 14 additions & 16 deletions web/src/pages/app/functions/mods/FunctionPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,30 +128,28 @@ export default function FunctionList() {
const nameParts = item.name.split("/");
let currentNode = root;
nameParts.forEach((_, index) => {
if (currentNode.children.find((node) => node.name === item.name)) {
const index = currentNode.children.findIndex((node) => node.name === item.name);
currentNode.children[index] = item;
return;
} else if (index === nameParts.length - 1) {
currentNode.children.push(item);
return;
const isFinalPart = index === nameParts.length - 1;
const existingItemIndex = currentNode.children.findIndex((node) => node.name === item.name);
if (existingItemIndex !== -1) {
currentNode.children[existingItemIndex] = item;
return;
} else if (isFinalPart) {
currentNode.children.push(item);
return;
}

const name = nameParts.slice(0, index + 1).join("/");
let existingNode = currentNode.children.find(
(node) => node.name === name && node.level === index,
(node) => node.name === name && node.level === index,
);
if (!existingNode) {
// dir
const newNode = {
existingNode = {
_id: item._id,
name,
level: index,
isExpanded: false,
children: [],
};
currentNode.children.push(newNode);
existingNode = newNode;
currentNode.children.push(existingNode);
}
currentNode = existingNode;
});
Expand All @@ -160,7 +158,7 @@ export default function FunctionList() {
return root;
},
[functionRoot],
);
);

const filterFunctions = useMemo(() => {
const res = generateRoot(
Expand Down Expand Up @@ -669,9 +667,9 @@ export default function FunctionList() {
title={
<div className="flex">
{t`FunctionPanel.FunctionList`}
{filterFunctions.length ? (
{allFunctionList.length ? (
<Badge rounded={"full"} ml="1">
{filterFunctions.length}
{allFunctionList.length}
</Badge>
) : null}
</div>
Expand Down
Loading