mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 23:33:13 +09:00
Fix linter errors
This commit is contained in:
1 file changed
+26
-27
@@ -3,6 +3,30 @@ import { Button, Card, Checkbox, Form, Input, InputNumber, Space, Spin, Tree, Ty
|
|||||||
|
|
||||||
const { Title } = Typography;
|
const { Title } = Typography;
|
||||||
|
|
||||||
|
function getInitialValues(config, props) {
|
||||||
|
let initialValues = {};
|
||||||
|
for (let [name, GroupClass] of props.ConfigClass.groups) {
|
||||||
|
let group = config.group(name);
|
||||||
|
for (let def of GroupClass.definitions.values()) {
|
||||||
|
if (!group.canAccess(def.name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let value = group.get(def.name);
|
||||||
|
let fieldName = `${group.name}.${def.name}`;
|
||||||
|
|
||||||
|
if (def.type === "object") {
|
||||||
|
for (let prop of Object.keys(value)) {
|
||||||
|
let propPath = `${group.name}.${def.name}.${prop}`;
|
||||||
|
initialValues[propPath] = JSON.stringify(value[prop]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
initialValues[fieldName] = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return initialValues;
|
||||||
|
}
|
||||||
|
|
||||||
export default function BaseConfigTree(props) {
|
export default function BaseConfigTree(props) {
|
||||||
let [config, setConfig] = useState(null);
|
let [config, setConfig] = useState(null);
|
||||||
@@ -19,8 +43,8 @@ export default function BaseConfigTree(props) {
|
|||||||
return newConfig;
|
return newConfig;
|
||||||
}
|
}
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateConfig().then(config => {
|
updateConfig().then(updatedConfig => {
|
||||||
form.setFieldsValue(getInitialValues(config, props));
|
form.setFieldsValue(getInitialValues(updatedConfig, props));
|
||||||
});
|
});
|
||||||
}, [props.id]);
|
}, [props.id]);
|
||||||
|
|
||||||
@@ -255,28 +279,3 @@ export default function BaseConfigTree(props) {
|
|||||||
</Card>
|
</Card>
|
||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInitialValues(config, props) {
|
|
||||||
let initialValues = {};
|
|
||||||
for (let [name, GroupClass] of props.ConfigClass.groups) {
|
|
||||||
let group = config.group(name);
|
|
||||||
for (let def of GroupClass.definitions.values()) {
|
|
||||||
if (!group.canAccess(def.name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
let value = group.get(def.name);
|
|
||||||
let fieldName = `${group.name}.${def.name}`;
|
|
||||||
|
|
||||||
if (def.type === "object") {
|
|
||||||
for (let prop of Object.keys(value)) {
|
|
||||||
let propPath = `${group.name}.${def.name}.${prop}`;
|
|
||||||
initialValues[propPath] = JSON.stringify(value[prop]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
initialValues[fieldName] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return initialValues;
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user