mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Add warnings to web ui
This commit is contained in:
3 files changed
+15
-3
No files matched your search
@@ -3,7 +3,7 @@ import * as classes from "./classes";
|
||||
import * as validate from "./validators";
|
||||
import type { PluginNodeEnvInfo, PluginWebpackEnvInfo } from "../plugin";
|
||||
import { Static } from "@sinclair/typebox";
|
||||
import { isTargetVersion } from "../data";
|
||||
import { isTargetVersion } from "../data/version";
|
||||
|
||||
type configFromJSON<T> = (...args: Parameters<typeof classes.Config.fromJSON>) => T;
|
||||
type configFromFile<T> = (...args: Parameters<typeof classes.Config.fromFile>) => Promise<T>;
|
||||
@@ -574,7 +574,7 @@ export class InstanceConfig extends classes.Config<InstanceConfigFields> {
|
||||
initialValue: 5,
|
||||
extendedValidation: function(value, config) {
|
||||
const factorioSettings = config.get("factorio.settings");
|
||||
const autosaveSlots = factorioSettings.autosave_slot;
|
||||
const autosaveSlots = factorioSettings.autosave_slots;
|
||||
if (typeof autosaveSlots === "number" && value < autosaveSlots) {
|
||||
throw new Error("Value cannot be less than the number of autosave slots");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import path from "node:path";
|
||||
import path from "path";
|
||||
|
||||
/** Combine multiple validators into a single one. */
|
||||
export function all<V, C> (
|
||||
|
||||
@@ -391,6 +391,18 @@ function computeTreeData(
|
||||
help={errorFields.get(fieldName)}
|
||||
tooltip={def.description}
|
||||
valuePropName={def.type === "boolean" ? "checked" : "value"}
|
||||
rules={[{
|
||||
validator: function(_, fieldValue) {
|
||||
if (def.extendedValidation) {
|
||||
try {
|
||||
def.extendedValidation(fieldValue, config);
|
||||
} catch (err: any) {
|
||||
return Promise.reject(err);
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
},
|
||||
}]}
|
||||
>
|
||||
{renderInput(control.inputComponents, def, !canWrite)}
|
||||
</Form.Item>;
|
||||
|
||||
Reference in new issue
Block a user