mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 07:33:12 +09:00
Move BaseControllerPlugin to controller/src/BaseControllerPlugin.ts Move BaseInstancePlugin to host/src/BaseInstancePlugin.ts Move BaseControlPlugin to ctl/src/BaseCtlPlugin.ts Move BaseWebPlugin to web_ui/src/BaseWebPlugin.ts This solves the circular package dependency problem of the base plugins needing types that are available only in the dependencies to lib.
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
import React, { useContext } from "react";
|
|
|
|
import * as lib from "@clusterio/lib";
|
|
|
|
import ControlContext from "./ControlContext";
|
|
import BaseWebPlugin from "../BaseWebPlugin";
|
|
import { RawUserState } from "../model/user";
|
|
import { HostState } from "../model/host";
|
|
import { InstanceState } from "../model/instance";
|
|
import { RawRoleState } from "./RoleViewPage";
|
|
|
|
|
|
type PluginExtraProps = {
|
|
component: string;
|
|
instance?: InstanceState;
|
|
user?: RawUserState;
|
|
host?: HostState;
|
|
role?: RawRoleState;
|
|
};
|
|
export default function PluginExtra(props: PluginExtraProps) {
|
|
let control = useContext(ControlContext);
|
|
|
|
let components = [];
|
|
for (let [name, plugin] of control.plugins) {
|
|
if (Object.prototype.hasOwnProperty.call(plugin.componentExtra, props.component)) {
|
|
type ComponentExtra = {[key: string]: React.ComponentType<PluginExtraProps & {plugin:BaseWebPlugin}>};
|
|
let ComponentExtra = (plugin.componentExtra as ComponentExtra)[props.component];
|
|
components.push(<ComponentExtra key={name} plugin={plugin} {...props}/>);
|
|
}
|
|
}
|
|
return components;
|
|
}
|