fix: random form fixes

pull/96/head
corpulent 3 years ago
parent a7ed667686
commit d5f8987e1c

@ -87,9 +87,15 @@ export default function App() {
<Toaster /> <Toaster />
<SideBar isAuthenticated={isAuthenticated} state={state} /> <SideBar isAuthenticated={isAuthenticated} state={state} />
<Routes> <Routes>
<Route path="/projects/:uuid" element={<Project />} /> <Route
path="/projects/:uuid"
element={<Project isAuthenticated={isAuthenticated} />}
/>
<Route path="/projects/new" element={<Project />} /> <Route
path="/projects/new"
element={<Project isAuthenticated={isAuthenticated} />}
/>
<Route <Route
path="/" path="/"

@ -58,7 +58,7 @@ const Login = (props: IProfileProps) => {
return ( return (
<> <>
<div className="flex flex-col"> <div className="flex flex-col">
<main className="py-6 md:w-2/3 lg:w-1/4 mx-auto"> <main className="py-6 md:w-1/3 lg:w-1/4 mx-auto">
<h2 className="mb-4 px-4 sm:px-6 md:flex-row md:px-8 text-xl font-extrabold dark:text-white text-gray-900"> <h2 className="mb-4 px-4 sm:px-6 md:flex-row md:px-8 text-xl font-extrabold dark:text-white text-gray-900">
Sign in Sign in
</h2> </h2>

@ -62,7 +62,7 @@ const Signup = (props: IProfileProps) => {
return ( return (
<> <>
<div className="flex flex-col"> <div className="flex flex-col">
<main className="py-6 md:w-2/3 lg:w-1/4 mx-auto"> <main className="py-6 md:w-1/3 lg:w-1/4 mx-auto">
<h2 className="mb-4 px-4 sm:px-6 md:flex-row md:px-8 text-xl font-extrabold dark:text-white text-gray-900"> <h2 className="mb-4 px-4 sm:px-6 md:flex-row md:px-8 text-xl font-extrabold dark:text-white text-gray-900">
Create account Create account
</h2> </h2>

@ -25,13 +25,14 @@ const General = () => {
<TextField label="Service name" name="serviceName" required={true} /> <TextField label="Service name" name="serviceName" required={true} />
<Group> <Group>
<TextField label="Image name" name="imageName" required={true} /> <TextField label="Image name" name="imageName" required={false} />
<TextField label="Image tag" name="imageTag" /> <TextField label="Image tag" name="imageTag" />
</Group> </Group>
<TextField label="Container name" name="containerName" required={true} /> <TextField label="Container name" name="containerName" required={false} />
<TextField label="Command" name="command" required={false} /> <TextField label="Command" name="command" required={false} />
<TextField label="Entrypoint" name="entrypoint" required={false} /> <TextField label="Entrypoint" name="entrypoint" required={false} />
<TextField label="Env file" name="envFile" required={false} />
<TextField label="Working directory" name="workingDir" required={false} /> <TextField label="Working directory" name="workingDir" required={false} />
<Toggle <Toggle

@ -105,6 +105,7 @@ const initialValues: IEditServiceForm = {
}, },
dependsOn: [], dependsOn: [],
entrypoint: "", entrypoint: "",
envFile: "",
imageName: "", imageName: "",
imageTag: "", imageTag: "",
serviceName: "", serviceName: "",
@ -236,13 +237,11 @@ export const validationSchema = yup.object({
.required("Service name is required"), .required("Service name is required"),
imageName: yup imageName: yup
.string() .string()
.max(256, "Image name should be 256 characters or less") .max(256, "Image name should be 256 characters or less"),
.required("Image name is required"),
imageTag: yup.string().max(256, "Image tag should be 256 characters or less"), imageTag: yup.string().max(256, "Image tag should be 256 characters or less"),
containerName: yup containerName: yup
.string() .string()
.max(256, "Container name should be 256 characters or less") .max(256, "Container name should be 256 characters or less"),
.required("Container name is required"),
profiles: yup.array( profiles: yup.array(
yup yup
.string() .string()
@ -297,6 +296,7 @@ export const getInitialValues = (node?: IServiceNodeItem): IEditServiceForm => {
deploy, deploy,
depends_on, depends_on,
entrypoint, entrypoint,
env_file,
image, image,
container_name = "", container_name = "",
environment, environment,
@ -459,6 +459,7 @@ export const getInitialValues = (node?: IServiceNodeItem): IEditServiceForm => {
dependsOn: dependsOn:
(depends_on as string[]) ?? (initialValues.dependsOn as string[]), (depends_on as string[]) ?? (initialValues.dependsOn as string[]),
entrypoint: (entrypoint as string) ?? (initialValues.entrypoint as string), entrypoint: (entrypoint as string) ?? (initialValues.entrypoint as string),
envFile: (env_file as string) ?? (initialValues.envFile as string),
imageName, imageName,
imageTag, imageTag,
serviceName: node_name, serviceName: node_name,
@ -478,9 +479,10 @@ export const getInitialValues = (node?: IServiceNodeItem): IEditServiceForm => {
ports: ports0.map((port) => { ports: ports0.map((port) => {
const slashIndex = port.lastIndexOf("/"); const slashIndex = port.lastIndexOf("/");
const protocol = slashIndex >= 0 ? port.substring(slashIndex + 1) : ""; const protocol = slashIndex >= 0 ? port.substring(slashIndex + 1) : "";
const [hostPort, containerPort] = port const [hostPort, containerPort] =
.substring(0, slashIndex) slashIndex >= 0
.split(":"); ? port.substring(0, slashIndex).split(":")
: port.split(":");
if (!["", "tcp", "udp"].includes(protocol)) { if (!["", "tcp", "udp"].includes(protocol)) {
throw new Error( throw new Error(
@ -508,6 +510,7 @@ export const getFinalValues = (
deploy, deploy,
dependsOn, dependsOn,
entrypoint, entrypoint,
envFile,
environmentVariables, environmentVariables,
volumes, volumes,
networks, networks,
@ -605,10 +608,11 @@ export const getFinalValues = (
}), }),
depends_on: pruneArray(dependsOn), depends_on: pruneArray(dependsOn),
entrypoint: pruneString(entrypoint), entrypoint: pruneString(entrypoint),
image: `${values.imageName}${ env_file: pruneString(envFile),
values.imageTag ? `:${values.imageTag}` : "" image: pruneString(
}`, `${values.imageName}${values.imageTag ? `:${values.imageTag}` : ""}`
container_name: values.containerName, ),
container_name: pruneString(values.containerName),
environment: packArrayAsObject(environmentVariables, "key", "value"), environment: packArrayAsObject(environmentVariables, "key", "value"),
volumes: pruneArray( volumes: pruneArray(
volumes.map( volumes.map(

@ -42,7 +42,12 @@ import CodeEditor from "../CodeEditor";
import { useTitle } from "../../hooks"; import { useTitle } from "../../hooks";
import VisibilitySwitch from "../global/VisibilitySwitch"; import VisibilitySwitch from "../global/VisibilitySwitch";
export default function Project() { interface IProjectProps {
isAuthenticated: boolean;
}
export default function Project(props: IProjectProps) {
const { isAuthenticated } = props;
const { uuid } = useParams<{ uuid: string }>(); const { uuid } = useParams<{ uuid: string }>();
const { height } = useWindowDimensions(); const { height } = useWindowDimensions();
const { data, error, isFetching } = useProject(uuid); const { data, error, isFetching } = useProject(uuid);
@ -467,12 +472,14 @@ export default function Project() {
/> />
<div className="flex flex-col space-y-2 w-full justify-end mb-4 md:flex-row md:space-y-0 md:space-x-2 md:mb-0"> <div className="flex flex-col space-y-2 w-full justify-end mb-4 md:flex-row md:space-y-0 md:space-x-2 md:mb-0">
{isAuthenticated && (
<VisibilitySwitch <VisibilitySwitch
isVisible={isVisible} isVisible={isVisible}
onToggle={() => { onToggle={() => {
setIsVisible(!isVisible); setIsVisible(!isVisible);
}} }}
/> />
)}
<button <button
onClick={() => onSave()} onClick={() => onSave()}

@ -19,13 +19,15 @@ export default function SideBar(props: ISideBarProps) {
name: "Projects", name: "Projects",
href: "/projects", href: "/projects",
icon: BookOpenIcon, icon: BookOpenIcon,
current: pathname.match(projRegex) ? true : false current: pathname.match(projRegex) ? true : false,
visible: isAuthenticated
}, },
{ {
name: "New project", name: "New project",
href: "/projects/new", href: "/projects/new",
icon: PlusIcon, icon: PlusIcon,
current: false current: false,
visible: true
} }
]; ];
@ -36,14 +38,16 @@ export default function SideBar(props: ISideBarProps) {
<div className="md:flex md:w-16 md:flex-col md:fixed md:inset-y-0"> <div className="md:flex md:w-16 md:flex-col md:fixed md:inset-y-0">
<div className="flex justify-between flex-col sm:flex-row md:flex-col md:flex-grow md:pt-5 bg-blue-700 overflow-y-auto"> <div className="flex justify-between flex-col sm:flex-row md:flex-col md:flex-grow md:pt-5 bg-blue-700 overflow-y-auto">
<div className="flex items-center flex-shrink-0 mx-auto p-2 "> <div className="flex items-center flex-shrink-0 mx-auto p-2 ">
<Link to={isAuthenticated ? "/" : "projects/new"}> <Link to={isAuthenticated ? "/" : "login"}>
<Logo /> <Logo />
</Link> </Link>
</div> </div>
<div className="md:mt-5 flex-1 flex flex-col items-center sm:flex-row md:flex-col justify-end"> <div className="md:mt-5 flex-1 flex flex-col items-center sm:flex-row md:flex-col justify-end">
<nav className="flex md:flex-1 md:flex-col items-center md:space-y-1"> <nav className="flex md:flex-1 md:flex-col items-center md:space-y-1">
{navigation.map((item) => ( {navigation.map((item) => {
if (item.visible) {
return (
<a <a
key={item.name} key={item.name}
href={item.href} href={item.href}
@ -60,7 +64,9 @@ export default function SideBar(props: ISideBarProps) {
/> />
<span className="sm:hidden">{item.name}</span> <span className="sm:hidden">{item.name}</span>
</a> </a>
))} );
}
})}
</nav> </nav>
<UserMenu <UserMenu

@ -454,6 +454,7 @@ export interface IEditServiceForm {
}[]; }[];
}; };
entrypoint: string; entrypoint: string;
envFile: string;
serviceName: string; serviceName: string;
imageName: string; imageName: string;
imageTag: string; imageTag: string;

Loading…
Cancel
Save