Files
factorio-scenario-ExpCluster/exp_scenario/web/components/Seed.tsx
T
bbassieandClaude Fable 5.1 7fd66c6ac7 Migrate to ES modules
Clusterio #984 converted its packages to ESM, so a CommonJS plugin can
no longer import @clusterio/lib and plugin entrypoints must name the
full file. Every package gets "type": "module", entrypoints and relative
imports carry the .js extension, and the webpack configs become .cjs as
webpack-cli loads them with require. tsconfig.node.json moves from
node16 to nodenext to match clusterio, which needs it for the JSON
import attributes in its sources.

The tap tests and the shared test helpers use import and
import.meta.dirname. The test scripts pass --type-strip-only so tap
leaves lib's .ts subpath imports to Node's own type stripping, as its
TypeScript loader compiled them without a default export. The lua
runner resolves fengari from the test file it is given, since a bare
import from the shared test directory does not reach the plugin's
devDependencies.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-12 01:10:02 +01:00

34 lines
1.1 KiB
TypeScript

import React, { useContext, useState } from "react";
import { Button, Popconfirm } from "antd";
import { ControlContext, SectionHeader, useAccount, notifyErrorHandler } from "@clusterio/web_ui";
import { SeedRequest } from "../../messages.js";
/** Button on the roles page which creates the roles and permission groups the scenario shipped with. */
export default function Seed() {
const control = useContext(ControlContext);
const account = useAccount();
const [seeding, setSeeding] = useState(false);
if (!account.hasPermission("exp_scenario.seed")) {
return null;
}
return <SectionHeader
title="ExpGaming Roles"
extra={<Popconfirm
title="Create the ExpGaming roles and permission groups?"
description="Roles which already exist by name only gain permissions, groups are reset to the defaults."
onConfirm={() => {
setSeeding(true);
control.send(new SeedRequest())
.catch(notifyErrorHandler("Error seeding roles and groups"))
.finally(() => setSeeding(false));
}}
>
<Button loading={seeding}>Seed roles and groups</Button>
</Popconfirm>}
/>;
}