Merge pull request #79 from nuxxapp/feat/protocol-update

Make protocol optional
pull/80/head
Samuel Rowe 3 years ago committed by GitHub
commit c8c298ac3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -63,7 +63,7 @@ const General = () => {
formik.setFieldValue(`ports[${ports.length}]`, { formik.setFieldValue(`ports[${ports.length}]`, {
hostPort: "", hostPort: "",
containerPort: "", containerPort: "",
protocol: "tcp" protocol: ""
}); });
}, [formik]); }, [formik]);

@ -1,6 +1,6 @@
import lodash from "lodash"; import lodash from "lodash";
import { useFormikContext } from "formik"; import { useFormikContext } from "formik";
import { FunctionComponent, ReactElement, useCallback } from "react"; import { Fragment, FunctionComponent, ReactElement, useCallback } from "react";
import { Button, styled } from "@mui/joy"; import { Button, styled } from "@mui/joy";
export interface IToggleProps { export interface IToggleProps {
@ -33,6 +33,10 @@ const ToggleButton = styled(Button)<IToggleButtonProps>(({ index, total }) => ({
fontSize: 11 fontSize: 11
})); }));
const ButtonBorder = styled("div")`
border-right: 1px solid white;
`;
const Toggle: FunctionComponent<IToggleProps> = ( const Toggle: FunctionComponent<IToggleProps> = (
props: IToggleProps props: IToggleProps
): ReactElement => { ): ReactElement => {
@ -42,23 +46,26 @@ const Toggle: FunctionComponent<IToggleProps> = (
lodash.get(formik.touched, name) && lodash.get(formik.errors, name); lodash.get(formik.touched, name) && lodash.get(formik.errors, name);
const value = lodash.get(formik.values, name); const value = lodash.get(formik.values, name);
const handleChange = (value: string) => () => { const handleChange = (newValue: string) => () => {
formik.setFieldValue(name, value); formik.setFieldValue(name, newValue === value ? "" : newValue);
}; };
return ( return (
<Root> <Root>
{options.map((option, index) => ( {options.map((option, index) => (
<ToggleButton <Fragment key={option.value}>
variant={value === option.value ? "solid" : "soft"} <ToggleButton
size="sm" variant={value === option.value ? "solid" : "soft"}
color="primary" size="sm"
index={index} color="primary"
total={options.length} index={index}
onClick={handleChange(option.value)} total={options.length}
> onClick={handleChange(option.value)}
{option.text} >
</ToggleButton> {option.text}
</ToggleButton>
{index + 1 < options.length && <ButtonBorder />}
</Fragment>
))} ))}
<div className="mt-1 text-xs text-red-600"> <div className="mt-1 text-xs text-red-600">

Loading…
Cancel
Save