From 8262cb858efe990502afade6a7a3bd5fdc44401a Mon Sep 17 00:00:00 2001 From: mbecker20 Date: Sun, 7 Apr 2024 03:40:02 -0700 Subject: [PATCH] look into deployment term signal --- .../resources/deployment/actions.tsx | 13 +- .../config/components/term-signal.tsx | 121 +++++++++++++++--- .../resources/deployment/config/index.tsx | 20 ++- 3 files changed, 121 insertions(+), 33 deletions(-) diff --git a/frontend/src/components/resources/deployment/actions.tsx b/frontend/src/components/resources/deployment/actions.tsx index f8d768839..4be8d38d0 100644 --- a/frontend/src/components/resources/deployment/actions.tsx +++ b/frontend/src/components/resources/deployment/actions.tsx @@ -22,8 +22,10 @@ export const RedeployContainer = ({ id }: DeploymentId) => { const deploying = useRead("GetDeploymentActionState", { deployment: id }).data ?.deploying; const pending = isPending || deploying; + if (!deployment) return null; return ( - { const pending = isPending || starting; if (!d) return null; - + return ( - } onClick={() => mutate({ deployment: id })} disabled={pending} @@ -76,7 +76,6 @@ const StopContainer = ({ id }: DeploymentId) => { } onClick={() => mutate({ deployment: id })} disabled={pending} diff --git a/frontend/src/components/resources/deployment/config/components/term-signal.tsx b/frontend/src/components/resources/deployment/config/components/term-signal.tsx index 9b4abd5cd..7bb47862c 100644 --- a/frontend/src/components/resources/deployment/config/components/term-signal.tsx +++ b/frontend/src/components/resources/deployment/config/components/term-signal.tsx @@ -1,5 +1,6 @@ import { ConfigItem } from "@components/config/util"; import { Types } from "@monitor/client"; +import { Button } from "@ui/button"; import { Input } from "@ui/input"; import { Select, @@ -10,26 +11,9 @@ import { SelectValue, } from "@ui/select"; import { useToast } from "@ui/use-toast"; +import { MinusCircle, PlusCircle } from "lucide-react"; import { useEffect, useState } from "react"; -// export const TerminationSignals = ({ -// args, -// set, -// }: { -// args: Types.TerminationSignalLabel[]; -// set: (input: Partial) => void; -// }) => { -// return ( -// -//
-// {args.map((arg, i) => { -// return <>; -// })} -//
-//
-// ); -// }; - export const DefaultTerminationSignal = ({ arg, set, @@ -45,7 +29,7 @@ export const DefaultTerminationSignal = ({ set({ termination_signal: value as Types.TerminationSignal }) } > - + @@ -53,7 +37,11 @@ export const DefaultTerminationSignal = ({ {Object.values(Types.TerminationSignal) .reverse() .map((term_signal) => ( - + {term_signal} ))} @@ -99,3 +87,96 @@ export const TerminationTimeout = ({ ); }; + +export const TermSignalLabels = ({ + args, + set, +}: { + args: Types.TerminationSignalLabel[]; + set: (input: Partial) => void; +}) => { + const signals = Object.values(Types.TerminationSignal) + .filter((signal) => args.every((arg) => arg.signal !== signal)) + .reverse(); + return ( + +
+ {args.map((label, i) => ( +
+ + set({ + term_signal_labels: args.map((item, index) => + index === i ? { ...item, label: e.target.value } : item + ), + }) + } + /> + + + + +
+ ))} + {signals.length > 0 && ( + + )} +
+
+ ); +}; diff --git a/frontend/src/components/resources/deployment/config/index.tsx b/frontend/src/components/resources/deployment/config/index.tsx index 0e851968b..171bd6d0c 100644 --- a/frontend/src/components/resources/deployment/config/index.tsx +++ b/frontend/src/components/resources/deployment/config/index.tsx @@ -17,6 +17,7 @@ import { ExtraArgs } from "./components/extra-args"; import { Config } from "@components/config"; import { DefaultTerminationSignal, + TermSignalLabels, TerminationTimeout, } from "./components/term-signal"; @@ -96,12 +97,6 @@ export const DeploymentConfig = ({ id }: { id: string }) => { extra_args: (value, set) => ( ), - termination_signal: (value, set) => ( - - ), - termination_timeout: (value, set) => ( - - ), }, settings: { send_alerts: true, @@ -120,6 +115,19 @@ export const DeploymentConfig = ({ id }: { id: string }) => { skip_secret_interp: true, }, }, + termination: { + termination: { + termination_signal: (value, set) => ( + + ), + termination_timeout: (value, set) => ( + + ), + term_signal_labels: (value, set) => ( + + ), + }, + }, }} /> );