mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-27 00:37:14 +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
@@ -3,8 +3,6 @@ import { useNavigate } from "react-router-dom";
|
|||||||
import { Button, Flex, Form, InputNumber, Modal, Space, Switch, Table, Tooltip, Typography } from "antd";
|
import { Button, Flex, Form, InputNumber, Modal, Space, Switch, Table, Tooltip, Typography } from "antd";
|
||||||
import { ExclamationCircleOutlined, CopyOutlined } from "@ant-design/icons";
|
import { ExclamationCircleOutlined, CopyOutlined } from "@ant-design/icons";
|
||||||
|
|
||||||
import type { ColumnsType } from "antd/es/table";
|
|
||||||
|
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
|
|
||||||
import webUiPackage from "../../package.json";
|
import webUiPackage from "../../package.json";
|
||||||
@@ -23,7 +21,7 @@ import { useHosts } from "../model/host";
|
|||||||
import { useSystems } from "../model/system";
|
import { useSystems } from "../model/system";
|
||||||
import notify, { notifyErrorHandler } from "../util/notify";
|
import notify, { notifyErrorHandler } from "../util/notify";
|
||||||
import useTableQueryState from "../util/useTableQueryState";
|
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;
|
const strcmp = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" }).compare;
|
||||||
|
|
||||||
@@ -221,17 +219,20 @@ export default function HostsPage() {
|
|||||||
/>
|
/>
|
||||||
<Table
|
<Table
|
||||||
style={{ overflowX: "auto" }}
|
style={{ overflowX: "auto" }}
|
||||||
columns={([
|
columns={[
|
||||||
{
|
{
|
||||||
title: "Name",
|
title: "Name",
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
sorter: (a, b) => strcmp(a.name, b.name),
|
sorter: (a, b) => strcmp(a.name, b.name),
|
||||||
|
sortOrder: tableState.sortOrder("name"),
|
||||||
|
filteredValue: tableState.filteredValue("name"),
|
||||||
...nameSearch,
|
...nameSearch,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "CPU Model",
|
title: "CPU Model",
|
||||||
dataIndex: "cpuModel",
|
dataIndex: "cpuModel",
|
||||||
sorter: (a, b) => strcmp(systems.get(a.id)?.cpuModel ?? "", systems.get(b.id)?.cpuModel ?? ""),
|
sorter: (a, b) => strcmp(systems.get(a.id)?.cpuModel ?? "", systems.get(b.id)?.cpuModel ?? ""),
|
||||||
|
sortOrder: tableState.sortOrder("cpuModel"),
|
||||||
render: (_, host) => systems.get(host.id)?.cpuModel,
|
render: (_, host) => systems.get(host.id)?.cpuModel,
|
||||||
hidden: !showCpuModel,
|
hidden: !showCpuModel,
|
||||||
},
|
},
|
||||||
@@ -239,6 +240,7 @@ export default function HostsPage() {
|
|||||||
title: "CPU%",
|
title: "CPU%",
|
||||||
key: "cpuPct",
|
key: "cpuPct",
|
||||||
sorter: (a, b) => (systems.get(a.id)?.cpuRatio ?? 0) - (systems.get(b.id)?.cpuRatio ?? 0),
|
sorter: (a, b) => (systems.get(a.id)?.cpuRatio ?? 0) - (systems.get(b.id)?.cpuRatio ?? 0),
|
||||||
|
sortOrder: tableState.sortOrder("cpuPct"),
|
||||||
render: (_, host) => <MetricCpuRatio system={systems.get(host.id)} />,
|
render: (_, host) => <MetricCpuRatio system={systems.get(host.id)} />,
|
||||||
hidden: !showRatios,
|
hidden: !showRatios,
|
||||||
},
|
},
|
||||||
@@ -248,6 +250,7 @@ export default function HostsPage() {
|
|||||||
sorter: (a, b) => (
|
sorter: (a, b) => (
|
||||||
(systems.get(a.id)?.cpuUsed ?? 0) - (systems.get(b.id)?.cpuUsed ?? 0)
|
(systems.get(a.id)?.cpuUsed ?? 0) - (systems.get(b.id)?.cpuUsed ?? 0)
|
||||||
),
|
),
|
||||||
|
sortOrder: tableState.sortOrder("cores"),
|
||||||
render: (_, host) => <MetricCpuUsed system={systems.get(host.id)} />,
|
render: (_, host) => <MetricCpuUsed system={systems.get(host.id)} />,
|
||||||
hidden: !showNumbers,
|
hidden: !showNumbers,
|
||||||
},
|
},
|
||||||
@@ -257,6 +260,7 @@ export default function HostsPage() {
|
|||||||
sorter: (a, b) => (
|
sorter: (a, b) => (
|
||||||
(systems.get(a.id)?.memoryRatio ?? 0) - (systems.get(b.id)?.memoryRatio ?? 0)
|
(systems.get(a.id)?.memoryRatio ?? 0) - (systems.get(b.id)?.memoryRatio ?? 0)
|
||||||
),
|
),
|
||||||
|
sortOrder: tableState.sortOrder("memPct"),
|
||||||
render: (_, host) => <MetricMemoryRatio system={systems.get(host.id)} />,
|
render: (_, host) => <MetricMemoryRatio system={systems.get(host.id)} />,
|
||||||
hidden: !showRatios,
|
hidden: !showRatios,
|
||||||
},
|
},
|
||||||
@@ -266,6 +270,7 @@ export default function HostsPage() {
|
|||||||
sorter: (a, b) => (
|
sorter: (a, b) => (
|
||||||
(systems.get(a.id)?.memoryUsed ?? 0) - (systems.get(b.id)?.memoryUsed ?? 0)
|
(systems.get(a.id)?.memoryUsed ?? 0) - (systems.get(b.id)?.memoryUsed ?? 0)
|
||||||
),
|
),
|
||||||
|
sortOrder: tableState.sortOrder("memory"),
|
||||||
render: (_, host) => <MetricMemoryUsed system={systems.get(host.id)} />,
|
render: (_, host) => <MetricMemoryUsed system={systems.get(host.id)} />,
|
||||||
hidden: !showNumbers,
|
hidden: !showNumbers,
|
||||||
},
|
},
|
||||||
@@ -273,6 +278,7 @@ export default function HostsPage() {
|
|||||||
title: "Disk%",
|
title: "Disk%",
|
||||||
key: "diskPct",
|
key: "diskPct",
|
||||||
sorter: (a, b) => (systems.get(a.id)?.diskAvailable ?? 0) - (systems.get(b.id)?.diskAvailable ?? 0),
|
sorter: (a, b) => (systems.get(a.id)?.diskAvailable ?? 0) - (systems.get(b.id)?.diskAvailable ?? 0),
|
||||||
|
sortOrder: tableState.sortOrder("diskPct"),
|
||||||
render: (_, host) => <MetricDiskRatio system={systems.get(host.id)} />,
|
render: (_, host) => <MetricDiskRatio system={systems.get(host.id)} />,
|
||||||
hidden: !showRatios,
|
hidden: !showRatios,
|
||||||
},
|
},
|
||||||
@@ -282,6 +288,7 @@ export default function HostsPage() {
|
|||||||
sorter: (a, b) => (
|
sorter: (a, b) => (
|
||||||
(systems.get(a.id)?.diskUsed ?? 0) - (systems.get(b.id)?.diskUsed ?? 0)
|
(systems.get(a.id)?.diskUsed ?? 0) - (systems.get(b.id)?.diskUsed ?? 0)
|
||||||
),
|
),
|
||||||
|
sortOrder: tableState.sortOrder("disk"),
|
||||||
render: (_, host) => <MetricDiskUsed system={systems.get(host.id)} />,
|
render: (_, host) => <MetricDiskUsed system={systems.get(host.id)} />,
|
||||||
hidden: !showNumbers,
|
hidden: !showNumbers,
|
||||||
},
|
},
|
||||||
@@ -295,11 +302,13 @@ export default function HostsPage() {
|
|||||||
</Tooltip>}
|
</Tooltip>}
|
||||||
</Space>,
|
</Space>,
|
||||||
sorter: (a, b) => strcmp(a.version, b.version),
|
sorter: (a, b) => strcmp(a.version, b.version),
|
||||||
|
sortOrder: tableState.sortOrder("version"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Public address",
|
title: "Public address",
|
||||||
dataIndex: "publicAddress",
|
dataIndex: "publicAddress",
|
||||||
sorter: (a, b) => strcmp(a.publicAddress??"", b.publicAddress??""),
|
sorter: (a, b) => strcmp(a.publicAddress??"", b.publicAddress??""),
|
||||||
|
sortOrder: tableState.sortOrder("publicAddress"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Connected",
|
title: "Connected",
|
||||||
@@ -309,8 +318,9 @@ export default function HostsPage() {
|
|||||||
<RestartRequired system={systems.get(host.id)}/>
|
<RestartRequired system={systems.get(host.id)}/>
|
||||||
</>,
|
</>,
|
||||||
sorter: (a, b) => Number(a.connected) - Number(b.connected),
|
sorter: (a, b) => Number(a.connected) - Number(b.connected),
|
||||||
|
sortOrder: tableState.sortOrder("connected"),
|
||||||
},
|
},
|
||||||
] satisfies ColumnsType<lib.HostDetails>).map(tableState.applyColumn)}
|
]}
|
||||||
dataSource={[...hosts.values()]}
|
dataSource={[...hosts.values()]}
|
||||||
rowKey={host => host.id}
|
rowKey={host => host.id}
|
||||||
pagination={tableState.pagination}
|
pagination={tableState.pagination}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import * as lib from "@clusterio/lib";
|
|||||||
import Link from "./Link";
|
import Link from "./Link";
|
||||||
import { instancePublicAddress } from "../util/instance";
|
import { instancePublicAddress } from "../util/instance";
|
||||||
import useTableQueryState from "../util/useTableQueryState";
|
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;
|
const strcmp = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" }).compare;
|
||||||
|
|
||||||
@@ -53,8 +53,9 @@ export default function InstanceList(props: InstanceListProps) {
|
|||||||
{
|
{
|
||||||
title: "Name",
|
title: "Name",
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
defaultSortOrder: "ascend",
|
|
||||||
sorter: (a, b) => strcmp(a["name"], b["name"]),
|
sorter: (a, b) => strcmp(a["name"], b["name"]),
|
||||||
|
sortOrder: tableState.sortOrder("name"),
|
||||||
|
filteredValue: tableState.filteredValue("name"),
|
||||||
...nameSearch,
|
...nameSearch,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -70,6 +71,7 @@ export default function InstanceList(props: InstanceListProps) {
|
|||||||
<RestartRequired system={instance.assignedHost ? systems.get(instance.assignedHost) : undefined}/>
|
<RestartRequired system={instance.assignedHost ? systems.get(instance.assignedHost) : undefined}/>
|
||||||
</Space>,
|
</Space>,
|
||||||
sorter: (a, b) => strcmp(hostName(a.assignedHost), hostName(b.assignedHost)),
|
sorter: (a, b) => strcmp(hostName(a.assignedHost), hostName(b.assignedHost)),
|
||||||
|
sortOrder: tableState.sortOrder("assignedHost"),
|
||||||
responsive: ["sm"],
|
responsive: ["sm"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -94,6 +96,7 @@ export default function InstanceList(props: InstanceListProps) {
|
|||||||
instancePublicAddress(a, hosts.get(a.assignedHost!) ?? null),
|
instancePublicAddress(a, hosts.get(a.assignedHost!) ?? null),
|
||||||
instancePublicAddress(b, hosts.get(b.assignedHost!) ?? null)
|
instancePublicAddress(b, hosts.get(b.assignedHost!) ?? null)
|
||||||
),
|
),
|
||||||
|
sortOrder: tableState.sortOrder("publicAddress"),
|
||||||
responsive: ["lg"],
|
responsive: ["lg"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -101,6 +104,7 @@ export default function InstanceList(props: InstanceListProps) {
|
|||||||
key: "version",
|
key: "version",
|
||||||
render: (_, instance) => instance.factorioVersion ?? "unknown",
|
render: (_, instance) => instance.factorioVersion ?? "unknown",
|
||||||
sorter: (a, b) => integerFactorioVersionOrDefault(a) - integerFactorioVersionOrDefault(b),
|
sorter: (a, b) => integerFactorioVersionOrDefault(a) - integerFactorioVersionOrDefault(b),
|
||||||
|
sortOrder: tableState.sortOrder("version"),
|
||||||
responsive: ["xl"],
|
responsive: ["xl"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -108,6 +112,7 @@ export default function InstanceList(props: InstanceListProps) {
|
|||||||
key: "status",
|
key: "status",
|
||||||
render: (_, instance) => <InstanceStatusTag status={instance["status"]} />,
|
render: (_, instance) => <InstanceStatusTag status={instance["status"]} />,
|
||||||
sorter: (a, b) => strcmp(a["status"], b["status"]),
|
sorter: (a, b) => strcmp(a["status"], b["status"]),
|
||||||
|
sortOrder: tableState.sortOrder("status"),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -125,11 +130,9 @@ export default function InstanceList(props: InstanceListProps) {
|
|||||||
columns.splice(1, 1);
|
columns.splice(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const finalColumns = columns.map(tableState.applyColumn);
|
|
||||||
|
|
||||||
return <Table
|
return <Table
|
||||||
size={props.size || "large"}
|
size={props.size || "large"}
|
||||||
columns={finalColumns}
|
columns={columns}
|
||||||
dataSource={[...props.instances.values()]}
|
dataSource={[...props.instances.values()]}
|
||||||
rowKey={instance => instance["id"]}
|
rowKey={instance => instance["id"]}
|
||||||
pagination={tableState.pagination}
|
pagination={tableState.pagination}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
ImportOutlined, PlusOutlined, SearchOutlined, DownloadOutlined,
|
ImportOutlined, PlusOutlined, SearchOutlined, DownloadOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import type { ColumnsType } from "antd/es/table";
|
|
||||||
|
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
|
|
||||||
import { useAccount } from "../model/account";
|
import { useAccount } from "../model/account";
|
||||||
@@ -579,23 +577,25 @@ export default function ModsPage() {
|
|||||||
</Space>}
|
</Space>}
|
||||||
/>
|
/>
|
||||||
<Table
|
<Table
|
||||||
columns={([
|
columns={[
|
||||||
{
|
{
|
||||||
title: "Name",
|
title: "Name",
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
sorter: (a, b) => strcmp(a.name, b.name),
|
sorter: (a, b) => strcmp(a.name, b.name),
|
||||||
|
sortOrder: modPackTable.sortOrder("name"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Factorio Version",
|
title: "Factorio Version",
|
||||||
dataIndex: "factorioVersion",
|
dataIndex: "factorioVersion",
|
||||||
sorter: (a, b) => a.integerFactorioVersion - b.integerFactorioVersion,
|
sorter: (a, b) => a.integerFactorioVersion - b.integerFactorioVersion,
|
||||||
|
sortOrder: modPackTable.sortOrder("factorioVersion"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Mods",
|
title: "Mods",
|
||||||
key: "mods",
|
key: "mods",
|
||||||
render: (_, modPack) => modPack.mods.size,
|
render: (_, modPack) => modPack.mods.size,
|
||||||
},
|
},
|
||||||
] satisfies ColumnsType<lib.ModPack>).map(modPackTable.applyColumn)}
|
]}
|
||||||
dataSource={[...modPacks.values()]}
|
dataSource={[...modPacks.values()]}
|
||||||
pagination={modPackTable.pagination}
|
pagination={modPackTable.pagination}
|
||||||
onChange={modPackTable.onChange}
|
onChange={modPackTable.onChange}
|
||||||
@@ -625,13 +625,14 @@ export default function ModsPage() {
|
|||||||
>
|
>
|
||||||
<Dropzone />
|
<Dropzone />
|
||||||
<Table
|
<Table
|
||||||
columns={([
|
columns={[
|
||||||
{
|
{
|
||||||
title: "Name",
|
title: "Name",
|
||||||
dataIndex: "title",
|
dataIndex: "title",
|
||||||
sorter: (a, b) => (
|
sorter: (a, b) => (
|
||||||
strcmp(a.name, b.name) || a.integerVersion - b.integerVersion
|
strcmp(a.name, b.name) || a.integerVersion - b.integerVersion
|
||||||
),
|
),
|
||||||
|
sortOrder: modTable.sortOrder("title"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Version",
|
title: "Version",
|
||||||
@@ -647,6 +648,7 @@ export default function ModsPage() {
|
|||||||
dataIndex: "filename",
|
dataIndex: "filename",
|
||||||
responsive: ["xl"],
|
responsive: ["xl"],
|
||||||
sorter: (a, b) => strcmp(a.filename, b.filename),
|
sorter: (a, b) => strcmp(a.filename, b.filename),
|
||||||
|
sortOrder: modTable.sortOrder("filename"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Size",
|
title: "Size",
|
||||||
@@ -655,6 +657,7 @@ export default function ModsPage() {
|
|||||||
render: (_, mod) => lib.formatBytes(mod.size),
|
render: (_, mod) => lib.formatBytes(mod.size),
|
||||||
align: "right",
|
align: "right",
|
||||||
sorter: (a, b) => a.size - b.size,
|
sorter: (a, b) => a.size - b.size,
|
||||||
|
sortOrder: modTable.sortOrder("size"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Action",
|
title: "Action",
|
||||||
@@ -662,7 +665,7 @@ export default function ModsPage() {
|
|||||||
responsive: ["lg"],
|
responsive: ["lg"],
|
||||||
render: (_, mod) => actions(mod),
|
render: (_, mod) => actions(mod),
|
||||||
},
|
},
|
||||||
] satisfies ColumnsType<lib.ModInfo>).map(modTable.applyColumn)}
|
]}
|
||||||
expandable={{
|
expandable={{
|
||||||
expandedRowRender: (mod: lib.ModInfo) => <ModDetails mod={mod} actions={actions} />,
|
expandedRowRender: (mod: lib.ModInfo) => <ModDetails mod={mod} actions={actions} />,
|
||||||
expandedRowClassName: () => "no-expanded-padding",
|
expandedRowClassName: () => "no-expanded-padding",
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { useContext, useEffect, useState } from "react";
|
import React, { useContext, useEffect, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { Table } from "antd";
|
import { Table } from "antd";
|
||||||
import type { ColumnsType } from "antd/es/table";
|
|
||||||
import CloseCircleFilled from "@ant-design/icons/CloseCircleFilled";
|
import CloseCircleFilled from "@ant-design/icons/CloseCircleFilled";
|
||||||
import InfoCircleFilled from "@ant-design/icons/InfoCircleFilled";
|
import InfoCircleFilled from "@ant-design/icons/InfoCircleFilled";
|
||||||
|
|
||||||
@@ -12,7 +11,7 @@ import ControlContext from "./ControlContext";
|
|||||||
import PageLayout from "./PageLayout";
|
import PageLayout from "./PageLayout";
|
||||||
import PageHeader from "./PageHeader";
|
import PageHeader from "./PageHeader";
|
||||||
import useTableQueryState from "../util/useTableQueryState";
|
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;
|
const strcmp = new Intl.Collator(undefined, { numeric: true, sensitivity: "base" }).compare;
|
||||||
|
|
||||||
@@ -65,12 +64,14 @@ export default function PluginsPage() {
|
|||||||
return <PageLayout nav={[{ name: "Plugins" }]}>
|
return <PageLayout nav={[{ name: "Plugins" }]}>
|
||||||
<PageHeader title="Plugins" />
|
<PageHeader title="Plugins" />
|
||||||
<Table
|
<Table
|
||||||
columns={([
|
columns={[
|
||||||
{
|
{
|
||||||
title: "Name",
|
title: "Name",
|
||||||
key: "name",
|
key: "name",
|
||||||
render: (_, plugin) => (plugin.info ? plugin.info.title : plugin.meta.name),
|
render: (_, plugin) => (plugin.info ? plugin.info.title : plugin.meta.name),
|
||||||
sorter: (a, b) => strcmp(a.info ? a.info.title : a.meta.name, b.info ? b.info.title : b.meta.name),
|
sorter: (a, b) => strcmp(a.info ? a.info.title : a.meta.name, b.info ? b.info.title : b.meta.name),
|
||||||
|
sortOrder: tableState.sortOrder("name"),
|
||||||
|
filteredValue: tableState.filteredValue("name"),
|
||||||
...nameSearch,
|
...nameSearch,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -89,15 +90,17 @@ export default function PluginsPage() {
|
|||||||
return plugin.package.version;
|
return plugin.package.version;
|
||||||
},
|
},
|
||||||
sorter: (a, b) => strcmp(a.meta.version, b.meta.version),
|
sorter: (a, b) => strcmp(a.meta.version, b.meta.version),
|
||||||
|
sortOrder: tableState.sortOrder("version"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Loaded",
|
title: "Loaded",
|
||||||
key: "loaded",
|
key: "loaded",
|
||||||
render: (_, plugin) => (plugin.package ? "Yes" : null),
|
render: (_, plugin) => (plugin.package ? "Yes" : null),
|
||||||
sorter: (a, b) => Number(Boolean(a.package)) - Number(Boolean(b.package)),
|
sorter: (a, b) => Number(Boolean(a.package)) - Number(Boolean(b.package)),
|
||||||
|
sortOrder: tableState.sortOrder("loaded"),
|
||||||
responsive: ["sm"],
|
responsive: ["sm"],
|
||||||
},
|
},
|
||||||
] satisfies ColumnsType<PluginRow>).map(tableState.applyColumn)}
|
]}
|
||||||
dataSource={tableContents}
|
dataSource={tableContents}
|
||||||
rowKey={plugin => plugin.meta.name}
|
rowKey={plugin => plugin.meta.name}
|
||||||
pagination={tableState.pagination}
|
pagination={tableState.pagination}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { useContext, useEffect, useState } from "react";
|
import React, { useContext, useEffect, useState } from "react";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import { Button, Form, Input, Modal, Table } from "antd";
|
import { Button, Form, Input, Modal, Table } from "antd";
|
||||||
import type { ColumnsType } from "antd/es/table";
|
|
||||||
|
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
|
|
||||||
@@ -13,7 +12,7 @@ import PageHeader from "./PageHeader";
|
|||||||
import PageLayout from "./PageLayout";
|
import PageLayout from "./PageLayout";
|
||||||
import PluginExtra from "./PluginExtra";
|
import PluginExtra from "./PluginExtra";
|
||||||
import useTableQueryState from "../util/useTableQueryState";
|
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;
|
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}
|
extra={account.hasPermission("core.role.create") ? <CreateRoleButton /> : undefined}
|
||||||
/>
|
/>
|
||||||
<Table
|
<Table
|
||||||
columns={([
|
columns={[
|
||||||
{
|
{
|
||||||
title: "Name",
|
title: "Name",
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
sorter: (a, b) => strcmp(a.name, b.name),
|
sorter: (a, b) => strcmp(a.name, b.name),
|
||||||
|
sortOrder: tableState.sortOrder("name"),
|
||||||
|
filteredValue: tableState.filteredValue("name"),
|
||||||
...nameSearch,
|
...nameSearch,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Description",
|
title: "Description",
|
||||||
dataIndex: "description",
|
dataIndex: "description",
|
||||||
},
|
},
|
||||||
] satisfies ColumnsType<lib.Role>).map(tableState.applyColumn)}
|
]}
|
||||||
dataSource={[...roles.values()]}
|
dataSource={[...roles.values()]}
|
||||||
pagination={tableState.pagination}
|
pagination={tableState.pagination}
|
||||||
rowKey={role => role.id}
|
rowKey={role => role.id}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
} from "antd";
|
} from "antd";
|
||||||
import CaretLeftOutlined from "@ant-design/icons/CaretLeftOutlined";
|
import CaretLeftOutlined from "@ant-design/icons/CaretLeftOutlined";
|
||||||
import LeftOutlined from "@ant-design/icons/LeftOutlined";
|
import LeftOutlined from "@ant-design/icons/LeftOutlined";
|
||||||
import type { ColumnsType } from "antd/es/table";
|
|
||||||
|
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
|
|
||||||
@@ -214,7 +213,7 @@ export default function SavesList(props: { instance: lib.InstanceDetails }) {
|
|||||||
const saveTable = <Table
|
const saveTable = <Table
|
||||||
className="save-list-table"
|
className="save-list-table"
|
||||||
size="small"
|
size="small"
|
||||||
columns={([
|
columns={[
|
||||||
{
|
{
|
||||||
title: "Name",
|
title: "Name",
|
||||||
key: "name",
|
key: "name",
|
||||||
@@ -224,6 +223,7 @@ export default function SavesList(props: { instance: lib.InstanceDetails }) {
|
|||||||
{save.loadByDefault && <Tooltip title="Save loaded by default"><LeftOutlined /></Tooltip>}
|
{save.loadByDefault && <Tooltip title="Save loaded by default"><LeftOutlined /></Tooltip>}
|
||||||
</>,
|
</>,
|
||||||
sorter: (a, b) => a.name.localeCompare(b.name),
|
sorter: (a, b) => a.name.localeCompare(b.name),
|
||||||
|
sortOrder: tableState.sortOrder("name"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Size",
|
title: "Size",
|
||||||
@@ -232,14 +232,16 @@ export default function SavesList(props: { instance: lib.InstanceDetails }) {
|
|||||||
render: (_, save) => lib.formatBytes(save.size),
|
render: (_, save) => lib.formatBytes(save.size),
|
||||||
align: "right",
|
align: "right",
|
||||||
sorter: (a, b) => a.size - b.size,
|
sorter: (a, b) => a.size - b.size,
|
||||||
|
sortOrder: tableState.sortOrder("size"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Last Modified",
|
title: "Last Modified",
|
||||||
key: "mtimeMs",
|
key: "mtimeMs",
|
||||||
render: (_, save) => new Date(save.mtimeMs).toLocaleString(),
|
render: (_, save) => new Date(save.mtimeMs).toLocaleString(),
|
||||||
sorter: (a, b) => a.mtimeMs - b.mtimeMs,
|
sorter: (a, b) => a.mtimeMs - b.mtimeMs,
|
||||||
|
sortOrder: tableState.sortOrder("mtimeMs"),
|
||||||
},
|
},
|
||||||
] satisfies ColumnsType<lib.SaveDetails>).map(tableState.applyColumn)}
|
]}
|
||||||
dataSource={[...saves.values()]}
|
dataSource={[...saves.values()]}
|
||||||
pagination={tableState.pagination}
|
pagination={tableState.pagination}
|
||||||
onChange={tableState.onChange}
|
onChange={tableState.onChange}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import {
|
|||||||
Row, Table, Tag, Select, Space, Spin, Switch,
|
Row, Table, Tag, Select, Space, Spin, Switch,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import DeleteOutlined from "@ant-design/icons/DeleteOutlined";
|
import DeleteOutlined from "@ant-design/icons/DeleteOutlined";
|
||||||
import type { ColumnsType } from "antd/es/table";
|
|
||||||
|
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
|
|
||||||
@@ -299,24 +298,27 @@ export default function UserViewPage() {
|
|||||||
<SectionHeader title="Instance stats" />
|
<SectionHeader title="Instance stats" />
|
||||||
<Table
|
<Table
|
||||||
size="small"
|
size="small"
|
||||||
columns={([
|
columns={[
|
||||||
{
|
{
|
||||||
title: "Instance",
|
title: "Instance",
|
||||||
key: "instance",
|
key: "instance",
|
||||||
render: (_, [id]) => instanceName(id),
|
render: (_, [id]) => instanceName(id),
|
||||||
sorter: (a, b) => strcmp(instanceName(a[0]), instanceName(b[0])),
|
sorter: (a, b) => strcmp(instanceName(a[0]), instanceName(b[0])),
|
||||||
|
sortOrder: statsTable.sortOrder("instance"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Online time",
|
title: "Online time",
|
||||||
key: "onlineTime",
|
key: "onlineTime",
|
||||||
render: (_, [, stats]) => formatDuration(stats.onlineTimeMs || 0),
|
render: (_, [, stats]) => formatDuration(stats.onlineTimeMs || 0),
|
||||||
sorter: (a, b) => (a[1].onlineTimeMs || 0) - (b[1].onlineTimeMs || 0),
|
sorter: (a, b) => (a[1].onlineTimeMs || 0) - (b[1].onlineTimeMs || 0),
|
||||||
|
sortOrder: statsTable.sortOrder("onlineTime"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Join count",
|
title: "Join count",
|
||||||
key: "joinCoint",
|
key: "joinCoint",
|
||||||
render: (_, [, stats]) => stats.joinCount || 0,
|
render: (_, [, stats]) => stats.joinCount || 0,
|
||||||
sorter: (a, b) => (a[1].joinCount || 0) - (b[1].joinCount || 0),
|
sorter: (a, b) => (a[1].joinCount || 0) - (b[1].joinCount || 0),
|
||||||
|
sortOrder: statsTable.sortOrder("joinCoint"),
|
||||||
responsive: ["sm"],
|
responsive: ["sm"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -324,14 +326,16 @@ export default function UserViewPage() {
|
|||||||
key: "firstSeen",
|
key: "firstSeen",
|
||||||
render: (_, [id]) => formatFirstSeen(user, id),
|
render: (_, [id]) => formatFirstSeen(user, id),
|
||||||
sorter: (a, b) => sortFirstSeen(user, user, a[0], b[0]),
|
sorter: (a, b) => sortFirstSeen(user, user, a[0], b[0]),
|
||||||
|
sortOrder: statsTable.sortOrder("firstSeen"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Last seen",
|
title: "Last seen",
|
||||||
key: "lastSeen",
|
key: "lastSeen",
|
||||||
render: (_, [id]) => formatLastSeen(user, id),
|
render: (_, [id]) => formatLastSeen(user, id),
|
||||||
sorter: (a, b) => sortLastSeen(user, user, a[0], b[0]),
|
sorter: (a, b) => sortLastSeen(user, user, a[0], b[0]),
|
||||||
|
sortOrder: statsTable.sortOrder("lastSeen"),
|
||||||
},
|
},
|
||||||
] satisfies ColumnsType<[number, lib.PlayerStats]>).map(statsTable.applyColumn)}
|
]}
|
||||||
dataSource={[...(user.instanceStats || []).entries()]}
|
dataSource={[...(user.instanceStats || []).entries()]}
|
||||||
pagination={statsTable.pagination}
|
pagination={statsTable.pagination}
|
||||||
onChange={statsTable.onChange}
|
onChange={statsTable.onChange}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import React from "react";
|
|||||||
import { Table, Tag } from "antd";
|
import { Table, Tag } from "antd";
|
||||||
import { SearchOutlined } from "@ant-design/icons";
|
import { SearchOutlined } from "@ant-design/icons";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate } from "react-router-dom";
|
||||||
import type { ColumnType } from "antd/es/table/interface";
|
|
||||||
|
|
||||||
import * as lib from "@clusterio/lib";
|
import * as lib from "@clusterio/lib";
|
||||||
|
|
||||||
@@ -92,15 +91,16 @@ export default function UsersTable(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const columns: ColumnType<lib.UserDetails>[] = [
|
const columns: any[] = [
|
||||||
{
|
{
|
||||||
title: "Name",
|
title: "Name",
|
||||||
key: "name",
|
key: "name",
|
||||||
render: (_: any, user: lib.UserDetails) => (
|
render: (_: any, user: lib.UserDetails) => (
|
||||||
<Username user={user} withStatus />
|
<Username user={user} withStatus />
|
||||||
),
|
),
|
||||||
defaultSortOrder: "ascend",
|
|
||||||
sorter: (a: lib.UserDetails, b: lib.UserDetails) => strcmp(a.name, b.name),
|
sorter: (a: lib.UserDetails, b: lib.UserDetails) => strcmp(a.name, b.name),
|
||||||
|
sortOrder: tableState.sortOrder("name"),
|
||||||
|
filteredValue: tableState.filteredValue("name"),
|
||||||
filterIcon: (filtered: boolean) => (
|
filterIcon: (filtered: boolean) => (
|
||||||
<SearchOutlined style={{ color: filtered ? "#1677ff" : undefined }} />
|
<SearchOutlined style={{ color: filtered ? "#1677ff" : undefined }} />
|
||||||
),
|
),
|
||||||
@@ -113,6 +113,7 @@ export default function UsersTable(
|
|||||||
key: "roles",
|
key: "roles",
|
||||||
filters: roleFilters,
|
filters: roleFilters,
|
||||||
filterMultiple: true,
|
filterMultiple: true,
|
||||||
|
filteredValue: tableState.filteredValue("roles"),
|
||||||
onFilter: (value: boolean | React.Key, record: lib.UserDetails) => (
|
onFilter: (value: boolean | React.Key, record: lib.UserDetails) => (
|
||||||
record.roleIds.has(Number(value))
|
record.roleIds.has(Number(value))
|
||||||
),
|
),
|
||||||
@@ -136,6 +137,7 @@ export default function UsersTable(
|
|||||||
const statsB = getUserStats(b, instanceId);
|
const statsB = getUserStats(b, instanceId);
|
||||||
return (statsA?.onlineTimeMs ?? 0) - (statsB?.onlineTimeMs ?? 0);
|
return (statsA?.onlineTimeMs ?? 0) - (statsB?.onlineTimeMs ?? 0);
|
||||||
},
|
},
|
||||||
|
sortOrder: tableState.sortOrder("onlineTime"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Join Count",
|
title: "Join Count",
|
||||||
@@ -148,27 +150,30 @@ export default function UsersTable(
|
|||||||
const statsB = getUserStats(b, instanceId);
|
const statsB = getUserStats(b, instanceId);
|
||||||
return (statsA?.joinCount ?? 0) - (statsB?.joinCount ?? 0);
|
return (statsA?.joinCount ?? 0) - (statsB?.joinCount ?? 0);
|
||||||
},
|
},
|
||||||
|
sortOrder: tableState.sortOrder("joinCount"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "First Seen",
|
title: "First Seen",
|
||||||
key: "firstSeen",
|
key: "firstSeen",
|
||||||
filterMultiple: false,
|
filterMultiple: false,
|
||||||
filters: durationFilters,
|
filters: durationFilters,
|
||||||
|
filteredValue: tableState.filteredValue("firstSeen"),
|
||||||
onFilter: (value: any, record: lib.UserDetails) => onFilterDuration(value, record, calculateFirstSeen),
|
onFilter: (value: any, record: lib.UserDetails) => onFilterDuration(value, record, calculateFirstSeen),
|
||||||
render: (_: any, user: lib.UserDetails) => formatFirstSeen(user, instanceId),
|
render: (_: any, user: lib.UserDetails) => formatFirstSeen(user, instanceId),
|
||||||
sorter: (a: lib.UserDetails, b: lib.UserDetails) => sortFirstSeen(a, b, instanceId, instanceId),
|
sorter: (a: lib.UserDetails, b: lib.UserDetails) => sortFirstSeen(a, b, instanceId, instanceId),
|
||||||
|
sortOrder: tableState.sortOrder("firstSeen"),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Last Seen",
|
title: "Last Seen",
|
||||||
key: "lastSeen",
|
key: "lastSeen",
|
||||||
filterMultiple: false,
|
filterMultiple: false,
|
||||||
filters: durationFilters,
|
filters: durationFilters,
|
||||||
defaultFilteredValue: onlyOnline ? ["online"] : undefined,
|
// Default to online-only when nothing for this column is in the URL yet.
|
||||||
|
filteredValue: tableState.filteredValue("lastSeen") ?? (onlyOnline ? ["online"] : null),
|
||||||
onFilter: (value: any, record: lib.UserDetails) => onFilterDuration(value, record, calculateLastSeen),
|
onFilter: (value: any, record: lib.UserDetails) => onFilterDuration(value, record, calculateLastSeen),
|
||||||
sorter: (a: lib.UserDetails, b: lib.UserDetails) => sortLastSeen(a, b, instanceId, instanceId),
|
sorter: (a: lib.UserDetails, b: lib.UserDetails) => sortLastSeen(a, b, instanceId, instanceId),
|
||||||
|
sortOrder: tableState.sortOrder("lastSeen"),
|
||||||
render: (_: any, user: lib.UserDetails) => formatLastSeen(user, instanceId),
|
render: (_: any, user: lib.UserDetails) => formatLastSeen(user, instanceId),
|
||||||
// Responsive breaks defaultFilteredValue, see: https://github.com/ant-design/ant-design/issues/32847
|
|
||||||
// responsive: ["lg"],
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -185,17 +190,9 @@ export default function UsersTable(
|
|||||||
tablePagination = { ...displayPagination, ...callerPagination, ...(tableState.pagination || {}) };
|
tablePagination = { ...displayPagination, ...callerPagination, ...(tableState.pagination || {}) };
|
||||||
}
|
}
|
||||||
|
|
||||||
let tableColumns = columns.map(tableState.applyColumn);
|
|
||||||
// Seed the online-only default when nothing for the Last Seen column is in the URL yet.
|
|
||||||
if (onlyOnline && !("lastSeen" in tableState.filters)) {
|
|
||||||
tableColumns = tableColumns.map(column => (
|
|
||||||
column.key === "lastSeen" ? { ...column, filteredValue: ["online"] } : column
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table
|
<Table
|
||||||
columns={tableColumns}
|
columns={columns}
|
||||||
dataSource={data}
|
dataSource={data}
|
||||||
rowKey={(user) => user.name}
|
rowKey={(user) => user.name}
|
||||||
pagination={tablePagination}
|
pagination={tablePagination}
|
||||||
|
|||||||
@@ -44,4 +44,4 @@ export { default as Link } from "./components/Link";
|
|||||||
export { default as FactorioIcon } from "./components/FactorioIcon";
|
export { default as FactorioIcon } from "./components/FactorioIcon";
|
||||||
|
|
||||||
export { default as useTableQueryState } from "./util/useTableQueryState";
|
export { default as useTableQueryState } from "./util/useTableQueryState";
|
||||||
export { default as useColumnSearch } from "./components/useColumnSearch";
|
export { default as useColumnSearch } from "./util/useColumnSearch";
|
||||||
File renamed without changes.
@@ -1,6 +1,6 @@
|
|||||||
import { useSearchParams } from "react-router-dom";
|
import { useSearchParams } from "react-router-dom";
|
||||||
import type { TablePaginationConfig } from "antd";
|
import type { TablePaginationConfig } from "antd";
|
||||||
import type { ColumnType, FilterValue, SorterResult } from "antd/es/table/interface";
|
import type { FilterValue, SorterResult } from "antd/es/table/interface";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
applyFilters, applyPagination, applySort,
|
applyFilters, applyPagination, applySort,
|
||||||
@@ -28,12 +28,12 @@ export interface TableQueryState<T> {
|
|||||||
filters: Record<string, FilterValue | null>,
|
filters: Record<string, FilterValue | null>,
|
||||||
sorter: SorterResult<T> | SorterResult<T>[],
|
sorter: SorterResult<T> | SorterResult<T>[],
|
||||||
) => void;
|
) => void;
|
||||||
/** Wrap each column to inject controlled `sortOrder`/`filteredValue` from the URL. */
|
/** Controlled `sortOrder` for the column with this key (null unless it's the active sort). */
|
||||||
applyColumn: (column: ColumnType<T>) => ColumnType<T>;
|
sortOrder: (columnKey: string) => SortOrder | null;
|
||||||
|
/** Controlled `filteredValue` for the column with this key (null when no filter is active). */
|
||||||
|
filteredValue: (columnKey: string) => string[] | null;
|
||||||
/** Controlled pagination ({@link current}/{@link pageSize}), or `false` when disabled. */
|
/** Controlled pagination ({@link current}/{@link pageSize}), or `false` when disabled. */
|
||||||
pagination: false | TablePaginationConfig;
|
pagination: false | TablePaginationConfig;
|
||||||
/** The active column filters parsed from the URL, keyed by column key. */
|
|
||||||
filters: Record<string, string[]>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,23 +83,17 @@ export default function useTableQueryState<T>(options: TableQueryStateOptions):
|
|||||||
setParams(next);
|
setParams(next);
|
||||||
},
|
},
|
||||||
|
|
||||||
applyColumn(column) {
|
sortOrder(columnKey) {
|
||||||
const key = String(column.key ?? column.dataIndex ?? "");
|
return columnKey === sort.columnKey ? (sort.order ?? null) : null;
|
||||||
const next: ColumnType<T> = { ...column };
|
},
|
||||||
if (column.sorter) {
|
|
||||||
next.sortOrder = key === sort.columnKey ? (sort.order ?? null) : null;
|
filteredValue(columnKey) {
|
||||||
}
|
const codec = codecs[columnKey];
|
||||||
if (column.filters || column.onFilter || column.filterDropdown) {
|
return codec ? codec.decode(params, prefix) : (filters[columnKey] ?? null);
|
||||||
const codec = codecs[key];
|
|
||||||
next.filteredValue = codec ? codec.decode(params, prefix) : (filters[key] ?? null);
|
|
||||||
}
|
|
||||||
return next;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
pagination: paginationEnabled && page
|
pagination: paginationEnabled && page
|
||||||
? { current: page.page, pageSize: page.pageSize }
|
? { current: page.page, pageSize: page.pageSize }
|
||||||
: false,
|
: false,
|
||||||
|
|
||||||
filters,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useContext, useEffect, useState } from "react";
|
import { useContext, useEffect, useState } from "react";
|
||||||
import { Table } from "antd";
|
import { Table } from "antd";
|
||||||
import type { ColumnsType } from "antd/es/table";
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BaseWebPlugin, PageLayout, PageHeader, Control, ControlContext, notifyErrorHandler,
|
BaseWebPlugin, PageLayout, PageHeader, Control, ControlContext, notifyErrorHandler,
|
||||||
@@ -87,12 +86,14 @@ function StoragePage() {
|
|||||||
<PageHeader title="Storage" />
|
<PageHeader title="Storage" />
|
||||||
<Table
|
<Table
|
||||||
className="subspace-storage-storage"
|
className="subspace-storage-storage"
|
||||||
columns={([
|
columns={[
|
||||||
{
|
{
|
||||||
title: "Resource",
|
title: "Resource",
|
||||||
key: "resource",
|
key: "resource",
|
||||||
...resourceSearch,
|
...resourceSearch,
|
||||||
onFilter: matchesResource,
|
onFilter: matchesResource,
|
||||||
|
filteredValue: tableState.filteredValue("resource"),
|
||||||
|
sortOrder: tableState.sortOrder("resource"),
|
||||||
sorter: (a, b) => {
|
sorter: (a, b) => {
|
||||||
let aName = getLocaleName(a[1].name);
|
let aName = getLocaleName(a[1].name);
|
||||||
let bName = getLocaleName(b[1].name);
|
let bName = getLocaleName(b[1].name);
|
||||||
@@ -121,9 +122,10 @@ function StoragePage() {
|
|||||||
key: "quantity",
|
key: "quantity",
|
||||||
align: "right",
|
align: "right",
|
||||||
sorter: (a, b) => a[1].count - b[1].count,
|
sorter: (a, b) => a[1].count - b[1].count,
|
||||||
|
sortOrder: tableState.sortOrder("quantity"),
|
||||||
render: (_, item) => numberFormat.format(item[1].count),
|
render: (_, item) => numberFormat.format(item[1].count),
|
||||||
},
|
},
|
||||||
] satisfies ColumnsType<[string, Item]>).map(tableState.applyColumn)}
|
]}
|
||||||
dataSource={storage}
|
dataSource={storage}
|
||||||
rowKey={item => item[0]}
|
rowKey={item => item[0]}
|
||||||
pagination={tableState.pagination}
|
pagination={tableState.pagination}
|
||||||
|
|||||||
Reference in new issue
Block a user