mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-20 23:53:13 +09:00
Merge branch 'master' into feature/config-validation
This commit is contained in:
75 files changed
+1215
-593
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import React, { useContext, useState } from "react";
|
||||
import React, { useContext, useRef, useState } from "react";
|
||||
import { Input, Typography } from "antd";
|
||||
|
||||
import * as lib from "@clusterio/lib";
|
||||
@@ -17,6 +17,7 @@ export default function InstanceRcon(props: InstanceRconProps) {
|
||||
let control = useContext(ControlContext);
|
||||
let [output, setOutput] = useState<string|null>(null);
|
||||
let [running, setRunning] = useState(false);
|
||||
let resultRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
async function sendCommand(command: string) {
|
||||
if (!command) {
|
||||
@@ -31,6 +32,8 @@ export default function InstanceRcon(props: InstanceRconProps) {
|
||||
new lib.InstanceSendRconRequest(command),
|
||||
);
|
||||
setOutput(result);
|
||||
const animation = resultRef.current?.children[0]?.getAnimations()[0];
|
||||
if (animation) { animation.currentTime = 0; }
|
||||
} finally {
|
||||
setRunning(false);
|
||||
}
|
||||
@@ -39,7 +42,7 @@ export default function InstanceRcon(props: InstanceRconProps) {
|
||||
return <>
|
||||
{output && <>
|
||||
<Title level={5}>Rcon result</Title>
|
||||
<Paragraph code className="rcon-result">{output}</Paragraph>
|
||||
<Paragraph ref={resultRef} code className="rcon-result">{output}</Paragraph>
|
||||
</>}
|
||||
<Input.Search
|
||||
disabled={props.disabled}
|
||||
|
||||
@@ -82,7 +82,11 @@ function NpmPluginInstall({ setApplyAction, form, target }: NpmActionProps) {
|
||||
</>;
|
||||
}
|
||||
|
||||
export function NpmButton(props: { target: lib.AddressShorthand, canRestart?: boolean, disabled?: boolean }) {
|
||||
export function NpmButton(props: {
|
||||
target: "controller" | { hostId: number },
|
||||
canRestart?: boolean,
|
||||
disabled?: boolean
|
||||
}) {
|
||||
const control = useContext(ControlContext);
|
||||
const account = useAccount();
|
||||
const [open, setOpen] = useState(false);
|
||||
@@ -93,6 +97,7 @@ export function NpmButton(props: { target: lib.AddressShorthand, canRestart?: bo
|
||||
remoteUpdates: true, pluginUpdates: true, pluginInstall: true,
|
||||
});
|
||||
|
||||
const hostId = props.target === "controller" ? undefined : props.target.hostId;
|
||||
useEffect(() => {
|
||||
if (props.target === "controller") {
|
||||
if (!account.hasPermission("core.controller.get_config")) {
|
||||
@@ -121,7 +126,7 @@ export function NpmButton(props: { target: lib.AddressShorthand, canRestart?: bo
|
||||
});
|
||||
}).catch(notifyErrorHandler("Failed to fetch host config for remote updates"));
|
||||
}
|
||||
}, [props.target]);
|
||||
}, [hostId]);
|
||||
|
||||
function onValuesChange({ action } : { action?: string }) {
|
||||
if (action) {
|
||||
|
||||
Reference in new issue
Block a user