This is an automated email from the ASF dual-hosted git repository.

dengliming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 64660b30 fix: use rule total for MCP tool pagination (#681)
64660b30 is described below

commit 64660b3094e197ff6b34b156698467a3c39be4f8
Author: Carlos Acosta <[email protected]>
AuthorDate: Sun Sep 27 00:31:16 2026 -0500

    fix: use rule total for MCP tool pagination (#681)
    
    Co-authored-by: Aeontra <aeontra@localhost>
---
 src/routes/Plugin/McpServer/index.js           |  4 +-
 src/routes/Plugin/McpServer/pagination.test.js | 79 ++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 2 deletions(-)

diff --git a/src/routes/Plugin/McpServer/index.js 
b/src/routes/Plugin/McpServer/index.js
index 444c5df8..ff01cdde 100755
--- a/src/routes/Plugin/McpServer/index.js
+++ b/src/routes/Plugin/McpServer/index.js
@@ -1045,8 +1045,8 @@ export default class McpServer extends Component {
       ruleList,
       selectorList,
       selectorTotal,
+      ruleTotal,
       currentSelector,
-      toolTotal,
     } = this.props;
 
     const selectColumns = [
@@ -1522,7 +1522,7 @@ export default class McpServer extends Component {
               dataSource={ruleList}
               rowSelection={toolRowSelection}
               pagination={{
-                total: toolTotal,
+                total: ruleTotal,
                 showTotal: (showTotal) => `${showTotal}`,
                 showSizeChanger: true,
                 pageSizeOptions: ["12", "20", "50", "100"],
diff --git a/src/routes/Plugin/McpServer/pagination.test.js 
b/src/routes/Plugin/McpServer/pagination.test.js
new file mode 100644
index 00000000..fc2e55a9
--- /dev/null
+++ b/src/routes/Plugin/McpServer/pagination.test.js
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import React from "react";
+import { Table } from "antd";
+import ConnectedMcpServer from "./index";
+
+jest.mock("react-json-view", () => () => null);
+jest.mock("../Common/Selector", () => () => null);
+jest.mock("./ToolsModal", () => () => null);
+jest.mock("./JsonEditModal", () => () => null);
+jest.mock("./McpConfigModal", () => () => null);
+jest.mock("./SwaggerImportModal", () => () => null);
+jest.mock(
+  "../../../utils/AuthButton",
+  () =>
+    ({ children }) =>
+      children,
+);
+jest.mock("../../../utils/IntlUtils", () => ({
+  getCurrentLocale: jest.fn(),
+  getIntlContent: (key) => key,
+}));
+jest.mock("../../../utils/namespacePlugin", () => ({
+  getUpdateModal: jest.fn(),
+  updateNamespacePluginsEnabledByNamespace: jest.fn(),
+}));
+
+const McpServer = ConnectedMcpServer.WrappedComponent;
+
+const findElement = (node, predicate) => {
+  if (!React.isValidElement(node)) {
+    return null;
+  }
+  if (predicate(node)) {
+    return node;
+  }
+  return React.Children.toArray(node.props.children).reduce(
+    (match, child) => match || findElement(child, predicate),
+    null,
+  );
+};
+
+it("uses common.ruleTotal for tool table pagination", () => {
+  const ruleList = [{ id: "tool-1" }];
+  const component = new McpServer({
+    currentSelector: null,
+    dispatch: jest.fn(),
+    plugins: [],
+    ruleList,
+    ruleTotal: 37,
+    selectorList: [],
+    selectorTotal: 0,
+  });
+
+  const tree = component.render();
+  const toolTable = findElement(
+    tree,
+    (element) =>
+      element.type === Table && element.props.dataSource === ruleList,
+  );
+
+  expect(toolTable).not.toBeNull();
+  expect(toolTable.props.pagination.total).toBe(37);
+});

Reply via email to