mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 07:43:12 +09:00
Merge pull request #434 from Danielv123/small-changes-for-plugins
Small changes for plugins
This commit is contained in:
6 files changed
+43
-2
No files matched your search
@@ -25,6 +25,8 @@ module.exports = (env = {}) => merge(common(env), {
|
|||||||
"antd": { singleton: true },
|
"antd": { singleton: true },
|
||||||
"react": { singleton: true },
|
"react": { singleton: true },
|
||||||
"react-dom": { singleton: true },
|
"react-dom": { singleton: true },
|
||||||
|
"react-router": { singleton: true },
|
||||||
|
"react-router-dom": { singleton: true },
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -16,8 +40,13 @@ export default function BaseConfigTree(props) {
|
|||||||
let newConfig = new props.ConfigClass("control");
|
let newConfig = new props.ConfigClass("control");
|
||||||
await newConfig.load(serializedConfig);
|
await newConfig.load(serializedConfig);
|
||||||
setConfig(newConfig);
|
setConfig(newConfig);
|
||||||
|
return newConfig;
|
||||||
}
|
}
|
||||||
useEffect(() => { updateConfig(); }, [props.id]);
|
useEffect(() => {
|
||||||
|
updateConfig().then(updatedConfig => {
|
||||||
|
form.setFieldsValue(getInitialValues(updatedConfig, props));
|
||||||
|
});
|
||||||
|
}, [props.id]);
|
||||||
|
|
||||||
function renderInput(def) {
|
function renderInput(def) {
|
||||||
if (def.type === "boolean") {
|
if (def.type === "boolean") {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Tag } from "antd";
|
import { Tag } from "antd";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const statusColors = {
|
export const statusColors = {
|
||||||
unknown: "#8c8c8c",
|
unknown: "#8c8c8c",
|
||||||
unassigned: "#eb2f96",
|
unassigned: "#eb2f96",
|
||||||
stopped: "#cf1322",
|
stopped: "#cf1322",
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ export default function LogConsole(props) {
|
|||||||
parent.scrollTop = parent.scrollHeight - parent.clientHeight;
|
parent.scrollTop = parent.scrollHeight - parent.clientHeight;
|
||||||
|
|
||||||
if (account.hasPermission("core.log.query")) {
|
if (account.hasPermission("core.log.query")) {
|
||||||
|
setPastLines([<span key={0}>{"Loading past entries..."}<br/></span>]);
|
||||||
libLink.messages.queryLog.send(control, {
|
libLink.messages.queryLog.send(control, {
|
||||||
...logFilter,
|
...logFilter,
|
||||||
max_level: null,
|
max_level: null,
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ export * from "./model/instance.jsx";
|
|||||||
export * from "./model/slave.jsx";
|
export * from "./model/slave.jsx";
|
||||||
export * from "./model/locale.jsx";
|
export * from "./model/locale.jsx";
|
||||||
export * from "./model/item_metadata.jsx";
|
export * from "./model/item_metadata.jsx";
|
||||||
|
export * from "./model/account.jsx";
|
||||||
|
|
||||||
|
|
||||||
export { default as ControlContext } from "./components/ControlContext";
|
export { default as ControlContext } from "./components/ControlContext";
|
||||||
@@ -18,6 +19,9 @@ export { default as LogConsole } from "./components/LogConsole";
|
|||||||
export { default as AssignInstanceModal } from "./components/AssignInstanceModal";
|
export { default as AssignInstanceModal } from "./components/AssignInstanceModal";
|
||||||
export { default as InstanceList } from "./components/InstanceList";
|
export { default as InstanceList } from "./components/InstanceList";
|
||||||
export { default as InstanceRcon } from "./components/InstanceRcon";
|
export { default as InstanceRcon } from "./components/InstanceRcon";
|
||||||
|
export { default as InstanceStatusTag } from "./components/InstanceStatusTag";
|
||||||
|
export { default as StartStopInstanceButton } from "./components/StartStopInstanceButton";
|
||||||
|
export { statusColors } from "./components/InstanceStatusTag";
|
||||||
|
|
||||||
export { default as PageLayout } from "./components/PageLayout";
|
export { default as PageLayout } from "./components/PageLayout";
|
||||||
export { default as SavesList } from "./components/SavesList";
|
export { default as SavesList } from "./components/SavesList";
|
||||||
|
|||||||
@@ -14,10 +14,15 @@ export function useSaves(instanceId) {
|
|||||||
setSaves(result.list);
|
setSaves(result.list);
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
logger.error(`Failed to list instance saves: ${err}`);
|
logger.error(`Failed to list instance saves: ${err}`);
|
||||||
|
setSaves([]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (!Number.isInteger(instanceId)) {
|
||||||
|
setSaves([]);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
updateSaves();
|
updateSaves();
|
||||||
|
|
||||||
function updateHandler(data) {
|
function updateHandler(data) {
|
||||||
|
|||||||
Reference in new issue
Block a user