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}]`, {
hostPort: "",
containerPort: "",
protocol: "tcp"
protocol: ""
});
}, [formik]);

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

Loading…
Cancel
Save