Implement custom input for mod pack config (#547)

Add custom input component support to the Web UI config in order to
provide a user friendly dropdown selector for the Mod Pack that is
configured as default on the controller and overridden instances.
This commit is contained in:
Hornwitser authored and GitHub committed 2024-01-17 20:29:04 +01:00
1 parent 80f0c63113
commit 863d90c7fb
8 files changed
+86 -13

No files matched your search

+14 -2
View File
@@ -1,5 +1,5 @@
import type React from "react";
import type { AccountRole, Logger, PluginWebpackEnvInfo } from "@clusterio/lib";
import type { AccountRole, FieldDefinition, Logger, PluginWebpackEnvInfo } from "@clusterio/lib";
import type { Control } from "./util/websocket";
/**
@@ -21,7 +21,14 @@ export interface PluginLoginForm {
* when an authentication token is aquired via this form.
*/
Component: React.ComponentType<{ setToken(token: string): void }>;
};
}
export interface InputComponentProps {
fieldDefinition: FieldDefinition,
value: null | boolean | number | string,
onChange: (value: null | boolean | number | string) => void,
}
export type InputComponent = React.ComponentType<InputComponentProps>;
export type UserAccount = {
/** Name of the currently logged in account. */
@@ -94,6 +101,11 @@ export default class BaseWebPlugin {
* List of pages provided by this plugin
*/
pages: PluginPage[] = [];
/**
* Additional Config inputComponent types available to render config
* entries with.
*/
inputComponents: Record<string, InputComponent> = {};
/**
* Extra react component to add to core components
*