@@ -72,11 +78,18 @@ export function ConfigEditor({ serverId }: ConfigEditorProps) {
{SECTION_DESCRIPTIONS[currentSection]}
)}
+ {profileGated && (
+
+ These settings only apply when Forced Difficulty is set to Custom in the Server tab. Current value: {forcedDifficulty ?? "—"}
+
+ )}
+
{currentSection && (
@@ -88,19 +101,21 @@ export function ConfigEditor({ serverId }: ConfigEditorProps) {
function ConfigSectionForm({
serverId,
section,
+ sectionSchema,
isAdmin,
addNotification,
}: {
serverId: number;
section: string;
+ sectionSchema: Record
;
isAdmin: boolean;
addNotification: (n: { type: "success" | "error" | "info" | "warning"; message: string }) => void;
}) {
const { data: sectionData, isLoading } = useServerConfigSection(serverId, section);
- const { data: schema } = useServerConfigSchema(serverId);
const updateSection = useUpdateConfigSection(serverId, section);
const [editValues, setEditValues] = useState | null>(null);
const [showPassword, setShowPassword] = useState>({});
+ const [showAdvanced, setShowAdvanced] = useState(false);
if (isLoading) {
return Loading section...
;
@@ -110,12 +125,23 @@ function ConfigSectionForm({
return No data for this section.
;
}
- const sectionSchema = schema?.[section] ?? {};
- const fields = Object.entries(sectionData).filter(([key]) => {
+ const hasAdvancedFields = Object.values(sectionSchema).some((f) => f.advanced === true);
+
+ const allFields = Object.entries(sectionData).filter(([key]) => {
if (key === "_meta") return false;
if (sectionSchema[key]?.widget === "hidden") return false;
return true;
});
+
+ // When schema has advanced flags, filter by them; otherwise show everything
+ const schemaHasFlags = Object.keys(sectionSchema).length > 0 && Object.values(sectionSchema).some((f) => "advanced" in f);
+ const fields = schemaHasFlags
+ ? allFields.filter(([key]) => {
+ const fieldSchema = sectionSchema[key];
+ if (!fieldSchema || fieldSchema.advanced === undefined) return true;
+ return showAdvanced ? true : !fieldSchema.advanced;
+ })
+ : allFields;
const meta = sectionData._meta;
const displayValues = editValues ?? Object.fromEntries(fields);
const isEditing = editValues !== null;
@@ -131,7 +157,11 @@ function ConfigSectionForm({
};
const handleSave = async () => {
- if (!editValues || !meta) return;
+ if (!editValues) return;
+ if (!meta) {
+ addNotification({ type: "error", message: "Cannot save: config metadata is missing. Please refresh the page." });
+ return;
+ }
try {
await updateSection.mutateAsync({
config_version: meta.config_version,
@@ -167,9 +197,19 @@ function ConfigSectionForm({
return (
-
- Version: {meta?.config_version ?? "--"} | Schema: {meta?.schema_version ?? "--"}
-
+
+
+ Version: {meta?.config_version ?? "--"} | Schema: {meta?.schema_version ?? "--"}
+
+ {hasAdvancedFields && !isEditing && (
+
+ )}
+
{isAdmin && !isEditing && (