From 2306804aaf55aafc20efbef6484c35f2161c375a Mon Sep 17 00:00:00 2001 From: Feroze Mohideen Date: Tue, 5 Mar 2024 10:05:15 -0500 Subject: [PATCH] make it more obvious that start command is required (#4374) --- .../services-settings/tabs/Main.tsx | 126 ++++++++++-------- 1 file changed, 72 insertions(+), 54 deletions(-) diff --git a/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Main.tsx b/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Main.tsx index c9b7bc3fe6..600944f315 100644 --- a/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Main.tsx +++ b/dashboard/src/main/home/app-dashboard/validate-apply/services-settings/tabs/Main.tsx @@ -1,16 +1,17 @@ import React, { useCallback, useMemo } from "react"; import cronstrue from "cronstrue"; -import {Controller, useFormContext} from "react-hook-form"; +import { Controller, useFormContext } from "react-hook-form"; +import { match } from "ts-pattern"; +import Checkbox from "components/porter/Checkbox"; +import Container from "components/porter/Container"; import { ControlledInput } from "components/porter/ControlledInput"; +import Link from "components/porter/Link"; import Spacer from "components/porter/Spacer"; -import { PorterAppFormData } from "lib/porter-apps"; -import { ClientService } from "lib/porter-apps/services"; import Text from "components/porter/Text"; -import Link from "components/porter/Link"; -import Checkbox from "components/porter/Checkbox"; -import { match } from "ts-pattern"; import Tooltip from "components/porter/Tooltip"; +import { type PorterAppFormData } from "lib/porter-apps"; +import { type ClientService } from "lib/porter-apps/services"; type MainTabProps = { index: number; @@ -18,7 +19,11 @@ type MainTabProps = { isPredeploy?: boolean; }; -const MainTab: React.FC = ({ index, service, isPredeploy = false }) => { +const MainTab: React.FC = ({ + index, + service, + isPredeploy = false, +}) => { const { register, control, watch } = useFormContext(); const cron = watch(`app.services.${index}.config.cron.value`); const run = watch(`app.services.${index}.run.value`); @@ -56,16 +61,22 @@ const MainTab: React.FC = ({ index, service, isPredeploy = false } return ( <> - {isRunCommandOptional ? + {isRunCommandOptional ? ( Start command (optional) - : - Start command (required) - } + ) : ( + + Start command + + * + + )} = ({ index, service, isPredeploy = false } width="300px" disabled={service.run.readOnly} disabledTooltip={"You may only edit this field in your porter.yaml."} - {...register(isPredeploy ? `app.predeploy.${index}.run.value` : `app.services.${index}.run.value`)} + {...register( + isPredeploy + ? `app.predeploy.${index}.run.value` + : `app.services.${index}.run.value` + )} /> - {isStartCommandValid && - <> - - Chained commands are not supported at this time. To run multiple commands, move all commands into a script that can be run from a single endpoint (e.g. bash ./run.sh). - - } - {match(service.config) - .with({ type: "job" }, (jobConfig) => ( + {isStartCommandValid && ( <> - - - - - {getScheduleDescription(cron)} - + Chained commands are not supported at this time. To run multiple + commands, move all commands into a script that can be run from a + single endpoint (e.g. bash ./run.sh). + + + )} + {match(service.config) + .with({ type: "job" }, (jobConfig) => ( + <> + + + + + {getScheduleDescription(cron)} + + ( - { - onChange(!value); - }} - disabledTooltip={ - "You may only edit this field in your porter.yaml." - } - > - Suspend cron job - + { + onChange(!value); + }} + disabledTooltip={ + "You may only edit this field in your porter.yaml." + } + > + Suspend cron job + )} - /> - - )) - .otherwise(() => null) - } + /> + + )) + .otherwise(() => null)} ); };