mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-18 21:55:24 +02:00
Fix health check form to properly sync test commands with form state
Co-authored-by: Siumauricio <47042324+Siumauricio@users.noreply.github.com>
This commit is contained in:
@@ -31,7 +31,6 @@ interface HealthCheckFormProps {
|
||||
|
||||
export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [testCommands, setTestCommands] = useState<string[]>([]);
|
||||
|
||||
const queryMap = {
|
||||
postgres: () =>
|
||||
@@ -72,6 +71,8 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
|
||||
},
|
||||
});
|
||||
|
||||
const testCommands = form.watch("Test") || [];
|
||||
|
||||
useEffect(() => {
|
||||
if (data?.healthCheckSwarm) {
|
||||
const hc = data.healthCheckSwarm;
|
||||
@@ -82,7 +83,6 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
|
||||
StartPeriod: hc.StartPeriod,
|
||||
Retries: hc.Retries,
|
||||
});
|
||||
setTestCommands(hc.Test || []);
|
||||
}
|
||||
}, [data, form]);
|
||||
|
||||
@@ -117,17 +117,20 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => {
|
||||
};
|
||||
|
||||
const addTestCommand = () => {
|
||||
setTestCommands([...testCommands, ""]);
|
||||
form.setValue("Test", [...testCommands, ""]);
|
||||
};
|
||||
|
||||
const updateTestCommand = (index: number, value: string) => {
|
||||
const newCommands = [...testCommands];
|
||||
newCommands[index] = value;
|
||||
setTestCommands(newCommands);
|
||||
form.setValue("Test", newCommands);
|
||||
};
|
||||
|
||||
const removeTestCommand = (index: number) => {
|
||||
setTestCommands(testCommands.filter((_, i) => i !== index));
|
||||
form.setValue(
|
||||
"Test",
|
||||
testCommands.filter((_, i) => i !== index),
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
export { HealthCheckForm } from "./health-check-form";
|
||||
export { RestartPolicyForm } from "./restart-policy-form";
|
||||
export { PlacementForm } from "./placement-form";
|
||||
export { UpdateConfigForm } from "./update-config-form";
|
||||
export { RollbackConfigForm } from "./rollback-config-form";
|
||||
export { ModeForm } from "./mode-form";
|
||||
export { LabelsForm } from "./labels-form";
|
||||
export { StopGracePeriodForm } from "./stop-grace-period-form";
|
||||
export { EndpointSpecForm } from "./endpoint-spec-form";
|
||||
export { HealthCheckForm } from "./health-check-form";
|
||||
export { LabelsForm } from "./labels-form";
|
||||
export { ModeForm } from "./mode-form";
|
||||
export { PlacementForm } from "./placement-form";
|
||||
export { RestartPolicyForm } from "./restart-policy-form";
|
||||
export { RollbackConfigForm } from "./rollback-config-form";
|
||||
export { StopGracePeriodForm } from "./stop-grace-period-form";
|
||||
export { UpdateConfigForm } from "./update-config-form";
|
||||
export { filterEmptyValues, hasValues } from "./utils";
|
||||
|
||||
Reference in New Issue
Block a user