Unified · Split
| @@ -82,7 +82,10 @@ export const EndpointSpecForm = ({ id, type }: EndpointSpecFormProps) => { · 81 unmodified lines | |||
| 82 | setIsLoading(true); | 82 | setIsLoading(true); |
| 83 | try { | 83 | try { |
| 84 | // Check if all values are empty, if so, send null to clear the database | 84 | // Check if all values are empty, if so, send null to clear the database |
| 85 | const hasAnyValue = formData.Mode !== undefined && formData.Mode !== null && formData.Mode !== ""; | 85 | const hasAnyValue = |
| 86 | formData.Mode !== undefined && | ||
| 87 | formData.Mode !== null && | ||
| 88 | formData.Mode !== ""; | ||
| 86 | 89 | ||
| 87 | await mutateAsync({ | 90 | await mutateAsync({ |
| 88 | applicationId: id || "", | 91 | applicationId: id || "", |
| @@ -90,7 +90,7 @@ export const HealthCheckForm = ({ id, type }: HealthCheckFormProps) => { · 89 unmodified lines | |||
| 90 | setIsLoading(true); | 90 | setIsLoading(true); |
| 91 | try { | 91 | try { |
| 92 | // Check if all values are empty, if so, send null to clear the database | 92 | // Check if all values are empty, if so, send null to clear the database |
| 93 | const hasAnyValue = | 93 | const hasAnyValue = |
| 94 | (formData.Test && formData.Test.length > 0) || | 94 | (formData.Test && formData.Test.length > 0) || |
| 95 | formData.Interval !== undefined || | 95 | formData.Interval !== undefined || |
| 96 | formData.Timeout !== undefined || | 96 | formData.Timeout !== undefined || |
| @@ -103,7 +103,7 @@ export const PlacementForm = ({ id, type }: PlacementFormProps) => { · 102 unmodified lines | |||
| 103 | setIsLoading(true); | 103 | setIsLoading(true); |
| 104 | try { | 104 | try { |
| 105 | // Check if all values are empty, if so, send null to clear the database | 105 | // Check if all values are empty, if so, send null to clear the database |
| 106 | const hasAnyValue = | 106 | const hasAnyValue = |
| 107 | (formData.Constraints && formData.Constraints.length > 0) || | 107 | (formData.Constraints && formData.Constraints.length > 0) || |
| 108 | (formData.Preferences && formData.Preferences.length > 0) || | 108 | (formData.Preferences && formData.Preferences.length > 0) || |
| 109 | (formData.Platforms && formData.Platforms.length > 0) || | 109 | (formData.Platforms && formData.Platforms.length > 0) || |
| @@ -94,7 +94,7 @@ export const RestartPolicyForm = ({ id, type }: RestartPolicyFormProps) => { · 93 unmodified lines | |||
| 94 | try { | 94 | try { |
| 95 | // Check if all values are empty, if so, send null to clear the database | 95 | // Check if all values are empty, if so, send null to clear the database |
| 96 | const hasAnyValue = Object.values(formData).some( | 96 | const hasAnyValue = Object.values(formData).some( |
| 97 | value => value !== undefined && value !== null && value !== "" | 97 | (value) => value !== undefined && value !== null && value !== "", |
| 98 | ); | 98 | ); |
| 99 | 99 | ||
| 100 | await mutateAsync({ | 100 | await mutateAsync({ |
| @@ -93,7 +93,7 @@ export const RollbackConfigForm = ({ id, type }: RollbackConfigFormProps) => { · 92 unmodified lines | |||
| 93 | try { | 93 | try { |
| 94 | // Check if all values are empty, if so, send null to clear the database | 94 | // Check if all values are empty, if so, send null to clear the database |
| 95 | const hasAnyValue = Object.values(formData).some( | 95 | const hasAnyValue = Object.values(formData).some( |
| 96 | value => value !== undefined && value !== null && value !== "" | 96 | (value) => value !== undefined && value !== null && value !== "", |
| 97 | ); | 97 | ); |
| 98 | 98 | ||
| 99 | await mutateAsync({ | 99 | await mutateAsync({ |
| @@ -119,9 +119,15 @@ export const StopGracePeriodForm = ({ id, type }: StopGracePeriodFormProps) => { · 118 unmodified lines | |||
| 119 | type="number" | 119 | type="number" |
| 120 | placeholder="30000000000" | 120 | placeholder="30000000000" |
| 121 | {...field} | 121 | {...field} |
| 122 | value={field?.value !== null && field?.value !== undefined ? field.value.toString() : ""} | 122 | value={ |
| 123 | field?.value !== null && field?.value !== undefined | ||
| 124 | ? field.value.toString() | ||
| 125 | : "" | ||
| 126 | } | ||
| 123 | onChange={(e) => | 127 | onChange={(e) => |
| 124 | field.onChange(e.target.value ? BigInt(e.target.value) : null) | 128 | field.onChange( |
| 129 | e.target.value ? BigInt(e.target.value) : null, | ||
| 130 | ) | ||
| 125 | } | 131 | } |
| 126 | /> | 132 | /> |
| 127 | </FormControl> | 133 | </FormControl> |
| @@ -99,7 +99,7 @@ export const UpdateConfigForm = ({ id, type }: UpdateConfigFormProps) => { · 98 unmodified lines | |||
| 99 | try { | 99 | try { |
| 100 | // Check if all values are empty, if so, send null to clear the database | 100 | // Check if all values are empty, if so, send null to clear the database |
| 101 | const hasAnyValue = Object.values(formData).some( | 101 | const hasAnyValue = Object.values(formData).some( |
| 102 | value => value !== undefined && value !== null && value !== "" | 102 | (value) => value !== undefined && value !== null && value !== "", |
| 103 | ); | 103 | ); |
| 104 | 104 | ||
| 105 | await mutateAsync({ | 105 | await mutateAsync({ |
| @@ -2,20 +2,25 @@ · 1 unmodified line | |||
| 2 | * Filters out undefined, null, and empty string values from form data | 2 | * Filters out undefined, null, and empty string values from form data |
| 3 | * Only returns fields that have actual values | 3 | * Only returns fields that have actual values |
| 4 | */ | 4 | */ |
| 5 | export const filterEmptyValues = (formData: Record<string, any>): Record<string, any> => { | 5 | export const filterEmptyValues = ( |
| 6 | return Object.entries(formData).reduce((acc, [key, value]) => { | 6 | formData: Record<string, any>, |
| 7 | // Keep arrays even if empty (they might be intentionally cleared) | 7 | ): Record<string, any> => { |
| 8 | if (Array.isArray(value)) { | 8 | return Object.entries(formData).reduce( |
| 9 | if (value.length > 0) { | 9 | (acc, [key, value]) => { |
| 10 | // Keep arrays even if empty (they might be intentionally cleared) | ||
| 11 | if (Array.isArray(value)) { | ||
| 12 | if (value.length > 0) { | ||
| 13 | acc[key] = value; | ||
| 14 | } | ||
| 15 | } | ||
| 16 | // For other values, filter out undefined, null, and empty strings | ||
| 17 | else if (value !== undefined && value !== null && value !== "") { | ||
| 10 | acc[key] = value; | 18 | acc[key] = value; |
| 11 | } | 19 | } |
| 12 | } | 20 | return acc; |
| 13 | // For other values, filter out undefined, null, and empty strings | 21 | }, |
| 14 | else if (value !== undefined && value !== null && value !== "") { | 22 | {} as Record<string, any>, |
| 15 | acc[key] = value; | 23 | ); |
| 16 | } | ||
| 17 | return acc; | ||
| 18 | }, {} as Record<string, any>); | ||
| 19 | }; | 24 | }; |
| 20 | 25 | ||
| 21 | /** | 26 | /** |