mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-25 00:23:12 +09:00
Merge pull request #701 from Cooldude2606/feature/enum-config-input
This commit is contained in:
1 parent
45ae20051f
commit
583d484573
7 files changed
+21
-10
No files matched your search
@@ -77,13 +77,14 @@ export default function AssignInstanceModal(props: AssignInstanceModalProps) {
|
|||||||
</Paragraph>
|
</Paragraph>
|
||||||
<Form form={form} initialValues={{ host: props.hostId ?? "null" }}>
|
<Form form={form} initialValues={{ host: props.hostId ?? "null" }}>
|
||||||
<Form.Item name="host" label="Host">
|
<Form.Item name="host" label="Host">
|
||||||
<Select>
|
<Select showSearch optionFilterProp="name">
|
||||||
<Select.Option value={"null"}>
|
<Select.Option value={"null"}>
|
||||||
<Typography.Text italic>Unassigned</Typography.Text>
|
<Typography.Text italic>Unassigned</Typography.Text>
|
||||||
</Select.Option>
|
</Select.Option>
|
||||||
{[...hosts.values()].sort((a, b) => strcmp(a.name, b.name)).map((host) => <Select.Option
|
{[...hosts.values()].sort((a, b) => strcmp(a.name, b.name)).map((host) => <Select.Option
|
||||||
key={host["id"]}
|
key={host["id"]}
|
||||||
value={host["id"]}
|
value={host["id"]}
|
||||||
|
name={host["name"]}
|
||||||
disabled={!host["connected"]}
|
disabled={!host["connected"]}
|
||||||
>
|
>
|
||||||
{host["name"]}
|
{host["name"]}
|
||||||
@@ -95,4 +96,3 @@ export default function AssignInstanceModal(props: AssignInstanceModalProps) {
|
|||||||
</Modal>
|
</Modal>
|
||||||
</>;
|
</>;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import React, { useContext, useEffect, useState } from "react";
|
import React, { useContext, useEffect, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Button, Card, Checkbox, Form, FormInstance, Input, InputNumber, Space, Spin, Tooltip, Tree, Typography,
|
Button, Card, Checkbox, Form, FormInstance, Input, InputNumber, Select, Space, Spin, Tooltip, Tree, Typography,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import ReloadOutlined from "@ant-design/icons/ReloadOutlined";
|
import ReloadOutlined from "@ant-design/icons/ReloadOutlined";
|
||||||
|
|
||||||
@@ -46,6 +46,15 @@ function renderInput(inputComponents: Record<string, InputComponent>, def: lib.F
|
|||||||
if (def.credential) {
|
if (def.credential) {
|
||||||
return <Input.Password autoComplete={def.autoComplete ?? "new-password"} disabled={readonly} />;
|
return <Input.Password autoComplete={def.autoComplete ?? "new-password"} disabled={readonly} />;
|
||||||
}
|
}
|
||||||
|
if (def.enum) {
|
||||||
|
return <Select
|
||||||
|
showSearch
|
||||||
|
style={{ minWidth: 175 }}
|
||||||
|
options={def.enum.map(value => ({ label: value, value: value }))}
|
||||||
|
allowClear={def.optional}
|
||||||
|
disabled={readonly}
|
||||||
|
/>;
|
||||||
|
}
|
||||||
return <Input autoComplete={def.autoComplete} disabled={readonly} />;
|
return <Input autoComplete={def.autoComplete} disabled={readonly} />;
|
||||||
}
|
}
|
||||||
if (def.type === "number") {
|
if (def.type === "number") {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import { InputComponentProps } from "../BaseWebPlugin";
|
|||||||
export default function InputModPack(props: InputComponentProps) {
|
export default function InputModPack(props: InputComponentProps) {
|
||||||
const [modPacks] = useModPacks();
|
const [modPacks] = useModPacks();
|
||||||
return <Select
|
return <Select
|
||||||
|
showSearch
|
||||||
|
optionFilterProp="label"
|
||||||
style={{ minWidth: 175 }}
|
style={{ minWidth: 175 }}
|
||||||
onChange={(value) => props.onChange(value ?? null)}
|
onChange={(value) => props.onChange(value ?? null)}
|
||||||
value={props.value}
|
value={props.value}
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ export default function InputRole(props: InputComponentProps) {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return <Select
|
return <Select
|
||||||
|
showSearch
|
||||||
|
optionFilterProp="label"
|
||||||
style={{ minWidth: 175 }}
|
style={{ minWidth: 175 }}
|
||||||
onChange={(value) => props.onChange(value ?? null)}
|
onChange={(value) => props.onChange(value ?? null)}
|
||||||
value={props.value}
|
value={props.value}
|
||||||
|
|||||||
@@ -201,8 +201,10 @@ function SearchModsTable(props: SearchModsTableProps) {
|
|||||||
key: "version",
|
key: "version",
|
||||||
align: "right",
|
align: "right",
|
||||||
render: (_, result) => <Select
|
render: (_, result) => <Select
|
||||||
|
showSearch
|
||||||
size="small"
|
size="small"
|
||||||
variant="borderless"
|
variant="borderless"
|
||||||
|
optionFilterProp="label"
|
||||||
value={modResultSelectedVersion.get(result.name) || 0}
|
value={modResultSelectedVersion.get(result.name) || 0}
|
||||||
onChange={index => {
|
onChange={index => {
|
||||||
const newVersions = new Map(modResultSelectedVersion);
|
const newVersions = new Map(modResultSelectedVersion);
|
||||||
|
|||||||
@@ -151,9 +151,7 @@ function TransferModal(props: ModalProps) {
|
|||||||
<Select
|
<Select
|
||||||
autoFocus
|
autoFocus
|
||||||
showSearch
|
showSearch
|
||||||
filterOption={(input, option) => (
|
optionFilterProp="title"
|
||||||
(option?.title!.toLowerCase().indexOf(input.toLowerCase()) ?? -1) >= 0
|
|
||||||
)}
|
|
||||||
>
|
>
|
||||||
{[...instances.values()].filter(
|
{[...instances.values()].filter(
|
||||||
instance => instance["id"] !== props.instanceId
|
instance => instance["id"] !== props.instanceId
|
||||||
|
|||||||
@@ -88,14 +88,12 @@ export default function UserViewPage() {
|
|||||||
onChange={() => setRolesDirty(true)}
|
onChange={() => setRolesDirty(true)}
|
||||||
loading={!roles}
|
loading={!roles}
|
||||||
mode="multiple"
|
mode="multiple"
|
||||||
filterOption={(inputValue:string, option: any): boolean => {
|
optionFilterProp="name"
|
||||||
let role = roles.get(option.value);
|
|
||||||
return role?.name.toLowerCase().includes(inputValue.toLowerCase()) ?? false;
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{[...roles.values()].map(r => <Select.Option
|
{[...roles.values()].map(r => <Select.Option
|
||||||
key={r.id}
|
key={r.id}
|
||||||
value={r.id}
|
value={r.id}
|
||||||
|
name={r.name}
|
||||||
>{r.name}</Select.Option>)}
|
>{r.name}</Select.Option>)}
|
||||||
</Select>
|
</Select>
|
||||||
</Form.Item>;
|
</Form.Item>;
|
||||||
|
|||||||
Reference in new issue
Block a user