mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-11 15:04:52 +09:00
The plugin syncs more than inventories now (settings, appearance, recipe notifications), so name it for what it does. The package becomes @clusterio/plugin-player_sync and every inventory_sync identifier follows. A migration entrypoint renames the inventory_sync config fields, including load_plugin, and the inventory view permission. The plugin moves inventories.json in the database directory to player_sync.json and storage.inventory_sync in saves to storage.player_sync itself, and closes dialogs left open under the old GUI names on startup. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import React, { useContext, useEffect, useState } from "react";
|
|
|
|
import { PageLayout, PageHeader, ControlContext, type WebPluginContext } from "@clusterio/web_ui";
|
|
import { DatabaseStatsRequest, DatabaseStatsResponse } from "../messages.js";
|
|
|
|
import "./style.css";
|
|
|
|
function InventoryPage() {
|
|
let control = useContext(ControlContext);
|
|
|
|
let [statsData, updateStatsData] = useState<DatabaseStatsResponse>();
|
|
|
|
useEffect(() => {
|
|
(async () => {
|
|
// Get statistics
|
|
updateStatsData(await control.send(new DatabaseStatsRequest()));
|
|
})();
|
|
}, []);
|
|
|
|
return <PageLayout nav={[{ name: "Player sync" }]}>
|
|
<PageHeader title="Player sync" />
|
|
{statsData && <>
|
|
<p>Database size: {Math.round(statsData.databaseSize / 1000)}kB</p>
|
|
<p>Database entries: {statsData.databaseEntries}</p>
|
|
<p>Largest entry is {statsData.largestEntry.name} with {(statsData.largestEntry.size / 1000)}kB</p>
|
|
</>}
|
|
</PageLayout>;
|
|
}
|
|
|
|
export default async function(context: WebPluginContext) {
|
|
const { control, plugin } = context;
|
|
|
|
control.hooks.pages.attach(plugin.name, () => [
|
|
{
|
|
path: "/inventory",
|
|
sidebarName: "Player sync",
|
|
permission: "player_sync.inventory.view",
|
|
content: <InventoryPage />,
|
|
},
|
|
]);
|
|
}
|