diff --git a/CHANGELOG.md b/CHANGELOG.md index 64951976..071647c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,7 @@ Many thanks to the following for contributing to this release: - Monorepos are now supported for external plugins [#654](https://github.com/clusterio/clusterio/pull/654). - Changed default role selection to be a dropdown menu rather than id [#664](https://github.com/clusterio/clusterio/pull/664). - Added credential option to config entries to allow writing sensitive data that can't be read back remotely. +- Allow hidden and readonly graphical representations of config values. [#665](https://github.com/clusterio/clusterio/pull/665). ### Changes diff --git a/packages/lib/src/config/classes.ts b/packages/lib/src/config/classes.ts index 8e3a16ee..ac1c4261 100644 --- a/packages/lib/src/config/classes.ts +++ b/packages/lib/src/config/classes.ts @@ -122,6 +122,15 @@ export interface FieldDefinition { * from the locations specified. */ credential?: ConfigLocation[]; + /** + * True if graphical interfaces should prevent the user modifying the value + * This is client side and does not provide any validation logic + */ + readonly?: boolean; + /** + * True if graphical interfaces should hide the config value + */ + hidden?: boolean; } export type ConfigDefs = { diff --git a/packages/lib/src/config/definitions.ts b/packages/lib/src/config/definitions.ts index f9f9dc47..132d0727 100644 --- a/packages/lib/src/config/definitions.ts +++ b/packages/lib/src/config/definitions.ts @@ -223,6 +223,7 @@ export class HostConfig extends classes.Config { description: "ID of the host", type: "number", initialValue: () => Math.random() * 2**31 | 0, + hidden: true, }, "host.factorio_directory": { description: "Path to directory to look for factorio installs", @@ -345,10 +346,12 @@ export class InstanceConfig extends classes.Config { description: "ID of the instance", type: "number", initialValue: () => Math.random() * 2**31 | 0, + hidden: true, }, "instance.assigned_host": { type: "number", optional: true, + hidden: true, }, "instance.auto_start": { description: "Automatically start this instance when the host hosting it is started up", diff --git a/packages/web_ui/src/components/BaseConfigTree.tsx b/packages/web_ui/src/components/BaseConfigTree.tsx index b7a309f3..6cd5174b 100644 --- a/packages/web_ui/src/components/BaseConfigTree.tsx +++ b/packages/web_ui/src/components/BaseConfigTree.tsx @@ -40,16 +40,16 @@ function renderInput(inputComponents: Record, def: lib.F return ; } if (def.type === "boolean") { - return ; + return ; } if (def.type === "string") { if (def.credential) { - return ; + return ; } - return ; + return ; } if (def.type === "number") { - return ; + return ; } return `Unknown type ${def.type}`; @@ -269,6 +269,9 @@ function computeTreeData( if (!canWrite && !canRead) { continue; } + if (def.hidden === true) { + continue; + } let fieldName = `${groupName}.${field}`; let value = config.get(fieldName) as any;