mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-28 00:47:13 +09:00
Use inline sort/filter getters instead of mapping columns
Replace the satisfies-ColumnsType + .map(applyColumn) approach with inline tableState.sortOrder()/filteredValue() getters set per column, so the column arrays stay plain literals (no satisfies, no constraints; UsersTable stays any[]). Move useColumnSearch into util/ next to useTableQueryState. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
4e94092730
commit
8cacdc5112
12 files changed
+86
-67
No files matched your search
@@ -1,7 +1,6 @@
|
||||
import React, { useContext, useEffect, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Button, Form, Input, Modal, Table } from "antd";
|
||||
import type { ColumnsType } from "antd/es/table";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
|
||||
@@ -13,7 +12,7 @@ import PageHeader from "./PageHeader";
|
||||
import PageLayout from "./PageLayout";
|
||||
import PluginExtra from "./PluginExtra";
|
||||
import useTableQueryState from "../util/useTableQueryState";
|
||||
import useColumnSearch from "./useColumnSearch";
|
||||
import useColumnSearch from "../util/useColumnSearch";
|
||||
|
||||
const strcmp = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" }).compare;
|
||||
|
||||
@@ -75,18 +74,20 @@ export default function RolesPage() {
|
||||
extra={account.hasPermission("core.role.create") ? <CreateRoleButton /> : undefined}
|
||||
/>
|
||||
<Table
|
||||
columns={([
|
||||
columns={[
|
||||
{
|
||||
title: "Name",
|
||||
dataIndex: "name",
|
||||
sorter: (a, b) => strcmp(a.name, b.name),
|
||||
sortOrder: tableState.sortOrder("name"),
|
||||
filteredValue: tableState.filteredValue("name"),
|
||||
...nameSearch,
|
||||
},
|
||||
{
|
||||
title: "Description",
|
||||
dataIndex: "description",
|
||||
},
|
||||
] satisfies ColumnsType<lib.Role>).map(tableState.applyColumn)}
|
||||
]}
|
||||
dataSource={[...roles.values()]}
|
||||
pagination={tableState.pagination}
|
||||
rowKey={role => role.id}
|
||||
|
||||
Reference in new issue
Block a user