mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 23:33:12 +09:00
Fix code style errors
Remove extra whitespace, use more consistent spacing, add missing semicolons, using dangling commas, break up long lines, consistent multiline operator placement, add missing JSDoc strings and so on.
This commit is contained in:
1 parent
97e05c0610
commit
7314dc99c8
71 files changed
+403
-290
No files matched your search
@@ -103,7 +103,7 @@ export default function BaseConfigTree(props: BaseConfigTreeProps) {
|
||||
title="A restart is required for this setting to take effect"
|
||||
><ReloadOutlined/></Tooltip>;
|
||||
|
||||
|
||||
|
||||
type ChildNode = {
|
||||
key: string;
|
||||
children: any[];
|
||||
|
||||
@@ -41,8 +41,8 @@ export default function HostViewPage() {
|
||||
}
|
||||
|
||||
let hostButtons = <Space> {
|
||||
account.hasPermission("core.host.revoke_access") &&
|
||||
<Popconfirm
|
||||
account.hasPermission("core.host.revoke_access")
|
||||
&& <Popconfirm
|
||||
title={`Revoke tokens of ${host.name}?`}
|
||||
placement="bottomRight"
|
||||
okText="Revoke Tokens"
|
||||
@@ -50,15 +50,15 @@ export default function HostViewPage() {
|
||||
onConfirm={() => {
|
||||
control.send(new lib.HostRevokeTokensRequest(host.id!))
|
||||
.then(() => notify("Host tokens revoked"))
|
||||
.catch(notifyErrorHandler(`Error revoking tokens for host id:${host.id}`))
|
||||
.catch(notifyErrorHandler(`Error revoking tokens for host id:${host.id}`));
|
||||
}}
|
||||
>
|
||||
<Button danger>
|
||||
Revoke tokens
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
}
|
||||
</Space>
|
||||
}
|
||||
</Space>;
|
||||
|
||||
return <PageLayout nav={nav}>
|
||||
<PageHeader
|
||||
@@ -75,9 +75,9 @@ export default function HostViewPage() {
|
||||
<Descriptions.Item label="Agent">{host["agent"]}</Descriptions.Item>
|
||||
<Descriptions.Item label="Version">{host["version"]}</Descriptions.Item>
|
||||
{
|
||||
host.tokenValidAfter &&
|
||||
<Descriptions.Item label="Tokens valid after:">
|
||||
{formatTimestamp(host.tokenValidAfter*1000)}
|
||||
host.tokenValidAfter
|
||||
&& <Descriptions.Item label="Tokens valid after:">
|
||||
{formatTimestamp(host.tokenValidAfter*1000)}
|
||||
</Descriptions.Item>
|
||||
}
|
||||
</Descriptions>
|
||||
|
||||
@@ -37,7 +37,7 @@ function GenerateHostTokenButton() {
|
||||
}, []);
|
||||
|
||||
async function generateToken() {
|
||||
let id = undefined;
|
||||
let id;
|
||||
let values = form.getFieldsValue();
|
||||
if (values.hostId) {
|
||||
id = Number.parseInt(values.hostId, 10);
|
||||
@@ -114,12 +114,12 @@ function GenerateHostTokenButton() {
|
||||
<div className="codeblock">
|
||||
<CopyButton
|
||||
message={"Copied host setup commands to clipboard"}
|
||||
text={`
|
||||
mkdir clusterio
|
||||
cd clusterio
|
||||
`+
|
||||
// eslint-disable-next-line max-len
|
||||
`npm init "@clusterio" -- --controller-token ${token} --mode "host" --download-headless --controller-url ${document.location.origin}/ --host-name "Host ${hostId || "?"}" --public-address localhost ${pluginString.length ? "--plugins" : ""} ${pluginString}`
|
||||
text={`\
|
||||
mkdir clusterio
|
||||
cd clusterio
|
||||
npm init "@clusterio" -- --controller-token ${token} --mode "host" --download-headless \
|
||||
--controller-url ${document.location.origin}/ --host-name "Host ${hostId || "?"}" \
|
||||
--public-address localhost ${pluginString.length ? "--plugins" : ""} ${pluginString}`
|
||||
}/>
|
||||
<p>> mkdir clusterio</p>
|
||||
<p>> cd clusterio</p>
|
||||
@@ -166,7 +166,7 @@ function CopyButton({ text, message }: { text:string, message:string }) {
|
||||
return result.state === "granted";
|
||||
|
||||
} catch (err: any) {
|
||||
//If it fail because "clipboard-write" is not supported.
|
||||
// If it fail because "clipboard-write" is not supported.
|
||||
return err.name === "TypeError";
|
||||
}
|
||||
}
|
||||
@@ -229,7 +229,7 @@ export default function HostsPage() {
|
||||
{host.connected ? "Connected" : "Disconnected"}
|
||||
</Tag>,
|
||||
sorter: (a, b) => Number(a.connected) - Number(b.connected),
|
||||
}
|
||||
},
|
||||
]}
|
||||
dataSource={hostList}
|
||||
rowKey={host => host.id}
|
||||
|
||||
@@ -99,7 +99,7 @@ export default function InstanceList(props: InstanceListProps) {
|
||||
responsive: ["sm"],
|
||||
align: "right",
|
||||
width: 100,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
if (props.hideAssignedHost) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useContext, useState } from "react";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { Alert, Button, Descriptions, Dropdown, Menu, MenuProps, Modal, Space, Spin, Typography } from "antd";
|
||||
import type { ItemType } from 'antd/es/menu/hooks/useItems';
|
||||
import type { ItemType } from "antd/es/menu/hooks/useItems";
|
||||
import DeleteOutlined from "@ant-design/icons/DeleteOutlined";
|
||||
import DownOutlined from "@ant-design/icons/DownOutlined";
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export default function ModDetails(props: ModDetailsProps) {
|
||||
{`https://mods.factorio.com/mod/${mod.name}`}
|
||||
</Typography.Link>
|
||||
</Descriptions.Item>
|
||||
|
||||
|
||||
{ (mod instanceof lib.ModInfo) && <>
|
||||
{mod.contact && <Descriptions.Item label="Contact" span={2}>{mod.contact}</Descriptions.Item>}
|
||||
{mod.homepage && <Descriptions.Item label="Homepage" span={2}>{mod.homepage}</Descriptions.Item>}
|
||||
|
||||
@@ -70,7 +70,7 @@ function SearchModsTable(props: SearchModsTableProps) {
|
||||
const [modResultPage, setModResultPage] = useState<number>(1);
|
||||
const [modResultPageSize, setModResultPageSize] = useState<number>(10);
|
||||
const [modResultCount, setModResultCount] = useState<number>(2);
|
||||
const [modResultSelectedVersion, setModResultSelectedVersion] = useState<Map<string,number>>(new Map());
|
||||
const [modResultSelectedVersion, setModResultSelectedVersion] = useState<Map<string, number>>(new Map());
|
||||
|
||||
const factorioVersion = props.modPack.factorioVersion.split(".").slice(0, 2).join(".");
|
||||
|
||||
@@ -216,7 +216,9 @@ function SearchModsTable(props: SearchModsTableProps) {
|
||||
title: "Action",
|
||||
key: "action",
|
||||
responsive: ["lg"],
|
||||
render: (result:ModResult) => actions(result.versions[modResultSelectedVersion.get(result.name) || 0]),
|
||||
render: (result:ModResult) => (
|
||||
actions(result.versions[modResultSelectedVersion.get(result.name) || 0])
|
||||
),
|
||||
},
|
||||
]}
|
||||
expandable={{
|
||||
@@ -294,11 +296,13 @@ function ModsTable(props: ModsTableProps) {
|
||||
>remove</Typography.Link>}
|
||||
{(deletedMods.has(mod.name) || changedMods.has(mod.name)) && <Typography.Link
|
||||
onClick={() => {
|
||||
props.onRevert && props.onRevert({
|
||||
type: deletedMods.has(mod.name) ? "mods.delete" : "mods.set",
|
||||
name: mod.name,
|
||||
value: mod,
|
||||
});
|
||||
if (props.onRevert) {
|
||||
props.onRevert({
|
||||
type: deletedMods.has(mod.name) ? "mods.delete" : "mods.set",
|
||||
name: mod.name,
|
||||
value: mod,
|
||||
});
|
||||
}
|
||||
}}
|
||||
>revert</Typography.Link>}
|
||||
</Space>;
|
||||
@@ -337,7 +341,9 @@ function ModsTable(props: ModsTableProps) {
|
||||
});
|
||||
}
|
||||
}
|
||||
const added = selectedRowKeys.filter(key => !props.modPack.mods.get(key as string)?.enabled) as string[];
|
||||
const added = selectedRowKeys.filter(
|
||||
key => !props.modPack.mods.get(key as string)?.enabled
|
||||
) as string[];
|
||||
const removed = [...props.modPack.mods.values()].filter(
|
||||
mod => mod.enabled && selectedRowKeys.indexOf(mod.name) === -1
|
||||
).map(mod => mod.name);
|
||||
|
||||
@@ -14,9 +14,9 @@ import { notifyErrorHandler } from "../util/notify";
|
||||
|
||||
|
||||
export type RawRoleState = Partial<lib.RawRole> & {
|
||||
loading?: Boolean;
|
||||
missing?: Boolean;
|
||||
present?: Boolean;
|
||||
loading?: boolean;
|
||||
missing?: boolean;
|
||||
present?: boolean;
|
||||
};
|
||||
function useRole(id: number): [RawRoleState, () => void] {
|
||||
let control = useContext(ControlContext);
|
||||
|
||||
@@ -17,7 +17,6 @@ import { useSaves } from "../model/saves";
|
||||
import { notifyErrorHandler } from "../util/notify";
|
||||
|
||||
|
||||
|
||||
type ModalProps = {
|
||||
disabled: boolean;
|
||||
save: lib.SaveDetails;
|
||||
@@ -150,7 +149,9 @@ function TransferModal(props: ModalProps) {
|
||||
<Select
|
||||
autoFocus
|
||||
showSearch
|
||||
filterOption={(input, option) => (option?.title.toLowerCase().indexOf(input.toLowerCase())??-1) >= 0}
|
||||
filterOption={(input, option) => (
|
||||
(option?.title.toLowerCase().indexOf(input.toLowerCase())??-1) >= 0
|
||||
)}
|
||||
>
|
||||
{instanceList.filter(
|
||||
instance => instance["id"] !== props.instanceId
|
||||
|
||||
@@ -17,7 +17,7 @@ export default function StartStopInstanceButton(props: StartStopInstanceButtonPr
|
||||
let control = useContext(ControlContext);
|
||||
let [switching, setSwitching] = useState<boolean>(false);
|
||||
|
||||
const onClick: React.MouseEventHandler<HTMLElement> = function(event) {
|
||||
function onClick(event: React.MouseEvent<HTMLElement>) {
|
||||
event.stopPropagation();
|
||||
setSwitching(true);
|
||||
let action;
|
||||
@@ -48,7 +48,7 @@ export default function StartStopInstanceButton(props: StartStopInstanceButtonPr
|
||||
props.onFinish();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return <Button
|
||||
{...(props.buttonProps || {})}
|
||||
|
||||
@@ -96,7 +96,9 @@ export default function UsersPage() {
|
||||
{
|
||||
title: "Roles",
|
||||
key: "roles",
|
||||
render: (user: lib.RawUser) => user.roles.map(id => <Tag key={id}>{(roles.get(id) || { name: id }).name}</Tag>),
|
||||
render: (user: lib.RawUser) => (
|
||||
user.roles.map(id => <Tag key={id}>{(roles.get(id) || { name: id }).name}</Tag>)
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "Online time",
|
||||
|
||||
Reference in new issue
Block a user