mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-11 23:54:52 +09:00
clusterio logs "using deprecated class export" for every node entrypoint that exports a Base*Plugin subclass, and the web UI logs "using deprecated class hooks" for WebPlugin classes. Every entrypoint now has a default export function, like exp_auto_restart and the exp_roles web plugin. The classes stay where they hold state, but no longer extend the base classes. The constructor takes the load context and init() attaches the hooks the base class used to attach from the on* methods, so the tests can still call those methods directly. exp_server_ups sends its RCON command through instance.sendRcon with the plugin name, which is what the removed BaseInstancePlugin.sendRcon did. The instance entrypoints of exp_commands, exp_gui, exp_legacy, exp_util and exp_scenario were empty classes, kept only so the host loads the plugin and patches its module into the save. An empty function does the same. The exp_groups web components read the subscriptions through exported useGroups, useAssignments and useRoleMappings hooks instead of looking the plugin up in control.plugins, which only holds class plugins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
74 lines
1.8 KiB
TypeScript
74 lines
1.8 KiB
TypeScript
import React, { useContext, useEffect } from "react";
|
|
import { Modal, Form, Select } from "antd";
|
|
|
|
import { ControlContext, useUsers } from "@clusterio/web_ui";
|
|
import * as messages from "../../messages.js";
|
|
import { useGroups } from "..";
|
|
|
|
export default function AssignmentForm({ open, setOpen, initial }: {
|
|
open: boolean,
|
|
setOpen: (open: boolean) => void,
|
|
initial?: messages.AssignmentRecord,
|
|
}) {
|
|
const control = useContext(ControlContext);
|
|
|
|
const [groups] = useGroups();
|
|
const [users] = useUsers();
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
function submit(values: any) {
|
|
if (initial) {
|
|
control.send(new messages.AssignmentUpdateRequest(
|
|
new messages.AssignmentRecord(
|
|
values.name,
|
|
values.groupId,
|
|
)
|
|
));
|
|
} else {
|
|
control.send(new messages.AssignmentCreateRequest(
|
|
values.name,
|
|
values.groupId,
|
|
));
|
|
}
|
|
|
|
setOpen(false);
|
|
}
|
|
|
|
useEffect(() => {
|
|
if (open) {
|
|
form.resetFields();
|
|
form.setFieldsValue(initial);
|
|
}
|
|
}, [open, initial]);
|
|
|
|
return <Modal
|
|
title={initial ? "Edit Assignment" : "Create Assignment"}
|
|
open={open}
|
|
onCancel={() => setOpen(false)}
|
|
onOk={() => form.submit()}
|
|
>
|
|
<Form form={form} onFinish={submit}>
|
|
<Form.Item name="name" label="Player" rules={[{ required: true }]}>
|
|
<Select disabled={Boolean(initial)} showSearch>
|
|
{[...users.values()].map(u => (
|
|
<Select.Option key={u.name} value={u.name}>
|
|
{u.name}
|
|
</Select.Option>
|
|
))}
|
|
</Select>
|
|
</Form.Item>
|
|
|
|
<Form.Item name="groupId" label="Group" rules={[{ required: true }]}>
|
|
<Select>
|
|
{[...groups.values()].map(g => (
|
|
<Select.Option key={g.id} value={g.id}>
|
|
{g.name}
|
|
</Select.Option>
|
|
))}
|
|
</Select>
|
|
</Form.Item>
|
|
</Form>
|
|
</Modal>;
|
|
}
|