[FEATURE] Safely allow modifications

This commit is contained in:
Dunemask 2024-02-12 21:47:35 -07:00
parent 11f70087f1
commit f277764cc0
3 changed files with 17 additions and 4 deletions

View file

@ -3,7 +3,8 @@ import TextField from "@mui/material/TextField";
import Autocomplete from "@mui/material/Autocomplete"; import Autocomplete from "@mui/material/Autocomplete";
import Chip from "@mui/material/Chip"; import Chip from "@mui/material/Chip";
const validatePort = (p) => p !== "25565" && p !== "25575" && p.length < 6; const validatePort = (p) =>
p !== "25565" && p !== "25575" && p.length < 6 && parseInt(p) < 60_000;
export default function ExtraPortsOption(props) { export default function ExtraPortsOption(props) {
const { extraPorts: initExtraPorts } = props; const { extraPorts: initExtraPorts } = props;
@ -30,7 +31,14 @@ export default function ExtraPortsOption(props) {
value={extraPorts} value={extraPorts}
onChange={portChange} onChange={portChange}
freeSolo freeSolo
renderInput={(p) => <TextField {...p} label="Extra Ports" />} renderInput={(p) => (
<TextField
{...p}
label="Extra Ports"
helperText="Remember to press enter to add the port!"
FormHelperTextProps={{ sx: { ml: 0 } }}
/>
)}
renderTags={(value, getTagProps) => renderTags={(value, getTagProps) =>
value.map((option, index) => { value.map((option, index) => {
const defaultChipProps = getTagProps({ index }); const defaultChipProps = getTagProps({ index });

View file

@ -1,6 +1,6 @@
import TextField from "@mui/material/TextField"; import TextField from "@mui/material/TextField";
export default function HostOption(props) { export default function HostOption(props) {
const { value, onChange } = props; const { value, onChange, disabled } = props;
return ( return (
<TextField <TextField
@ -10,6 +10,7 @@ export default function HostOption(props) {
helperText="Example: host.mydomain.com" helperText="Example: host.mydomain.com"
FormHelperTextProps={{ sx: { ml: 0 } }} FormHelperTextProps={{ sx: { ml: 0 } }}
required required
disabled={disabled}
/> />
); );
} }

View file

@ -73,7 +73,11 @@ export default function EditCoreOptions(props) {
> >
<FormControl fullWidth sx={{ mt: "2rem", display: "flex", gap: ".5rem" }}> <FormControl fullWidth sx={{ mt: "2rem", display: "flex", gap: ".5rem" }}>
<NameOption value={spec.name} onChange={coreUpdate("name")} /> <NameOption value={spec.name} onChange={coreUpdate("name")} />
<HostOption value={spec.host} onChange={coreUpdate("host")} /> <HostOption
value={spec.host}
onChange={coreUpdate("host")}
disabled={true}
/>
<VersionOption value={spec.version} onChange={coreUpdate("version")} /> <VersionOption value={spec.version} onChange={coreUpdate("version")} />
<ServerTypeOption <ServerTypeOption
value={spec.serverType} value={spec.serverType}