From d5f8987e1c931cdfb2c6bb0a7cecbc41b006f1c3 Mon Sep 17 00:00:00 2001 From: corpulent Date: Thu, 4 Aug 2022 14:32:56 +0300 Subject: [PATCH] fix: random form fixes --- services/frontend/src/App.tsx | 10 +++- .../src/components/Auth/Login/index.tsx | 2 +- .../src/components/Auth/Signup/index.tsx | 2 +- .../src/components/Modal/service/General.tsx | 5 +- .../components/Modal/service/form-utils.ts | 26 +++++----- .../frontend/src/components/Project/index.tsx | 21 +++++--- .../src/components/global/SideBar.tsx | 48 +++++++++++-------- services/frontend/src/types/index.ts | 1 + 8 files changed, 70 insertions(+), 45 deletions(-) diff --git a/services/frontend/src/App.tsx b/services/frontend/src/App.tsx index 6e152d7..e9a2176 100644 --- a/services/frontend/src/App.tsx +++ b/services/frontend/src/App.tsx @@ -87,9 +87,15 @@ export default function App() { - } /> + } + /> - } /> + } + /> { return ( <>
-
+

Sign in

diff --git a/services/frontend/src/components/Auth/Signup/index.tsx b/services/frontend/src/components/Auth/Signup/index.tsx index ec85521..a2a36aa 100644 --- a/services/frontend/src/components/Auth/Signup/index.tsx +++ b/services/frontend/src/components/Auth/Signup/index.tsx @@ -62,7 +62,7 @@ const Signup = (props: IProfileProps) => { return ( <>
-
+

Create account

diff --git a/services/frontend/src/components/Modal/service/General.tsx b/services/frontend/src/components/Modal/service/General.tsx index 0a144db..4f556fd 100644 --- a/services/frontend/src/components/Modal/service/General.tsx +++ b/services/frontend/src/components/Modal/service/General.tsx @@ -25,13 +25,14 @@ const General = () => { - + - + + { deploy, depends_on, entrypoint, + env_file, image, container_name = "", environment, @@ -459,6 +459,7 @@ export const getInitialValues = (node?: IServiceNodeItem): IEditServiceForm => { dependsOn: (depends_on as string[]) ?? (initialValues.dependsOn as string[]), entrypoint: (entrypoint as string) ?? (initialValues.entrypoint as string), + envFile: (env_file as string) ?? (initialValues.envFile as string), imageName, imageTag, serviceName: node_name, @@ -478,9 +479,10 @@ export const getInitialValues = (node?: IServiceNodeItem): IEditServiceForm => { ports: ports0.map((port) => { const slashIndex = port.lastIndexOf("/"); const protocol = slashIndex >= 0 ? port.substring(slashIndex + 1) : ""; - const [hostPort, containerPort] = port - .substring(0, slashIndex) - .split(":"); + const [hostPort, containerPort] = + slashIndex >= 0 + ? port.substring(0, slashIndex).split(":") + : port.split(":"); if (!["", "tcp", "udp"].includes(protocol)) { throw new Error( @@ -508,6 +510,7 @@ export const getFinalValues = ( deploy, dependsOn, entrypoint, + envFile, environmentVariables, volumes, networks, @@ -605,10 +608,11 @@ export const getFinalValues = ( }), depends_on: pruneArray(dependsOn), entrypoint: pruneString(entrypoint), - image: `${values.imageName}${ - values.imageTag ? `:${values.imageTag}` : "" - }`, - container_name: values.containerName, + env_file: pruneString(envFile), + image: pruneString( + `${values.imageName}${values.imageTag ? `:${values.imageTag}` : ""}` + ), + container_name: pruneString(values.containerName), environment: packArrayAsObject(environmentVariables, "key", "value"), volumes: pruneArray( volumes.map( diff --git a/services/frontend/src/components/Project/index.tsx b/services/frontend/src/components/Project/index.tsx index 80f9233..4126f81 100644 --- a/services/frontend/src/components/Project/index.tsx +++ b/services/frontend/src/components/Project/index.tsx @@ -42,7 +42,12 @@ import CodeEditor from "../CodeEditor"; import { useTitle } from "../../hooks"; 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 { height } = useWindowDimensions(); const { data, error, isFetching } = useProject(uuid); @@ -467,12 +472,14 @@ export default function Project() { />
- { - setIsVisible(!isVisible); - }} - /> + {isAuthenticated && ( + { + setIsVisible(!isVisible); + }} + /> + )}