refactor: Simplify HealthCheckConfigFields component structure and enhance layout by integrating className prop for better styling flexibility, while maintaining functionality for load balancing and health check configurations
Build, Test, and Push CFDM Docker Image / test (push) Successful in 4m9s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Successful in 2m18s
Build, Test, and Push CFDM Docker Image / update-wiki (push) Successful in 5s
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped
Build, Test, and Push CFDM Docker Image / test (push) Successful in 4m9s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Successful in 2m18s
Build, Test, and Push CFDM Docker Image / update-wiki (push) Successful in 5s
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
|||||||
} from '@cfdm/ui/components/select'
|
} from '@cfdm/ui/components/select'
|
||||||
import { Switch } from '@cfdm/ui/components/switch'
|
import { Switch } from '@cfdm/ui/components/switch'
|
||||||
import { Label } from '@cfdm/ui/components/label'
|
import { Label } from '@cfdm/ui/components/label'
|
||||||
|
import { cn } from '@cfdm/ui/lib/utils'
|
||||||
|
|
||||||
export type LbMode = 'round_robin' | 'failover' | 'weighted'
|
export type LbMode = 'round_robin' | 'failover' | 'weighted'
|
||||||
export type HealthCheckType = 'tcp' | 'http'
|
export type HealthCheckType = 'tcp' | 'http'
|
||||||
@@ -46,6 +47,7 @@ interface HealthCheckConfigFieldsProps {
|
|||||||
lbModeOptions?: { value: string; label: string }[]
|
lbModeOptions?: { value: string; label: string }[]
|
||||||
idPrefix?: string
|
idPrefix?: string
|
||||||
showLbMode?: boolean
|
showLbMode?: boolean
|
||||||
|
className?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export function HealthCheckConfigFields({
|
export function HealthCheckConfigFields({
|
||||||
@@ -55,13 +57,16 @@ export function HealthCheckConfigFields({
|
|||||||
lbModeOptions = defaultLbModeOptions,
|
lbModeOptions = defaultLbModeOptions,
|
||||||
idPrefix = 'health',
|
idPrefix = 'health',
|
||||||
showLbMode = true,
|
showLbMode = true,
|
||||||
|
className,
|
||||||
}: HealthCheckConfigFieldsProps) {
|
}: HealthCheckConfigFieldsProps) {
|
||||||
function patch(next: Partial<LbAndHealthConfig>) {
|
function patch(next: Partial<LbAndHealthConfig>) {
|
||||||
onChange({ ...value, ...next })
|
onChange({ ...value, ...next })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isHttp = value.type === 'http'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppFieldGroup>
|
<div className={cn('flex flex-col gap-4', className)}>
|
||||||
{showLbMode && (
|
{showLbMode && (
|
||||||
<FormFieldSimple label={lbModeLabel} htmlFor={`${idPrefix}-lb-mode`}>
|
<FormFieldSimple label={lbModeLabel} htmlFor={`${idPrefix}-lb-mode`}>
|
||||||
<Select
|
<Select
|
||||||
@@ -95,6 +100,12 @@ export function HealthCheckConfigFields({
|
|||||||
</div>
|
</div>
|
||||||
</FormFieldSimple>
|
</FormFieldSimple>
|
||||||
|
|
||||||
|
{value.enabled && (
|
||||||
|
<div className="rounded-md border border-border bg-muted/30 p-4">
|
||||||
|
<p className="mb-3 text-sm font-medium text-foreground">
|
||||||
|
Параметры проверки
|
||||||
|
</p>
|
||||||
|
<AppFieldGroup>
|
||||||
<FormFieldSimple label="Тип проверки" htmlFor={`${idPrefix}-type`}>
|
<FormFieldSimple label="Тип проверки" htmlFor={`${idPrefix}-type`}>
|
||||||
<Select
|
<Select
|
||||||
value={value.type}
|
value={value.type}
|
||||||
@@ -126,7 +137,11 @@ export function HealthCheckConfigFields({
|
|||||||
/>
|
/>
|
||||||
</FormFieldSimple>
|
</FormFieldSimple>
|
||||||
|
|
||||||
<FormFieldSimple label="HTTP path (для типа HTTP)" htmlFor={`${idPrefix}-path`}>
|
{isHttp && (
|
||||||
|
<FormFieldSimple
|
||||||
|
label="HTTP path"
|
||||||
|
htmlFor={`${idPrefix}-path`}
|
||||||
|
>
|
||||||
<AppInput
|
<AppInput
|
||||||
id={`${idPrefix}-path`}
|
id={`${idPrefix}-path`}
|
||||||
placeholder="/health"
|
placeholder="/health"
|
||||||
@@ -136,7 +151,9 @@ export function HealthCheckConfigFields({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</FormFieldSimple>
|
</FormFieldSimple>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isHttp && (
|
||||||
<FormFieldSimple
|
<FormFieldSimple
|
||||||
label="Ожидаемый HTTP-статус"
|
label="Ожидаемый HTTP-статус"
|
||||||
htmlFor={`${idPrefix}-status`}
|
htmlFor={`${idPrefix}-status`}
|
||||||
@@ -155,6 +172,7 @@ export function HealthCheckConfigFields({
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</FormFieldSimple>
|
</FormFieldSimple>
|
||||||
|
)}
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
<FormFieldSimple label="Интервал, сек" htmlFor={`${idPrefix}-interval`}>
|
<FormFieldSimple label="Интервал, сек" htmlFor={`${idPrefix}-interval`}>
|
||||||
@@ -189,5 +207,8 @@ export function HealthCheckConfigFields({
|
|||||||
</FormFieldSimple>
|
</FormFieldSimple>
|
||||||
</div>
|
</div>
|
||||||
</AppFieldGroup>
|
</AppFieldGroup>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -295,12 +295,6 @@ export function ServiceEditSheet({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleBindingLbModeChange(index: number, lbMode: LbMode) {
|
|
||||||
setBindings((current) =>
|
|
||||||
current.map((item, i) => (i === index ? { ...item, lb_mode: lbMode } : item)),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleBindingMetaChange(
|
function handleBindingMetaChange(
|
||||||
index: number,
|
index: number,
|
||||||
ip: string,
|
ip: string,
|
||||||
@@ -604,36 +598,12 @@ export function ServiceEditSheet({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{showLbBlock && (
|
{showLbBlock && (
|
||||||
<Accordion>
|
<Accordion defaultValue={[`lb-${index}`]}>
|
||||||
<AccordionItem value={`lb-${index}`}>
|
<AccordionItem value={`lb-${index}`}>
|
||||||
<AccordionTrigger>
|
<AccordionTrigger>
|
||||||
Балансировка и Health-check (multi-A)
|
Балансировка и Health-check (multi-A)
|
||||||
</AccordionTrigger>
|
</AccordionTrigger>
|
||||||
<AccordionContent>
|
<AccordionContent>
|
||||||
<AppFieldGroup>
|
|
||||||
<AppField>
|
|
||||||
<AppFieldLabel htmlFor={`binding-lb-mode-${index}`}>
|
|
||||||
Режим балансировки
|
|
||||||
</AppFieldLabel>
|
|
||||||
<Select
|
|
||||||
value={binding.lb_mode}
|
|
||||||
onValueChange={(value) =>
|
|
||||||
handleBindingLbModeChange(
|
|
||||||
index,
|
|
||||||
(value ?? 'round_robin') as LbMode,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<SelectTrigger id={`binding-lb-mode-${index}`} className="w-full">
|
|
||||||
<SelectValue />
|
|
||||||
</SelectTrigger>
|
|
||||||
<SelectContent>
|
|
||||||
<SelectItem value="round_robin">Round Robin</SelectItem>
|
|
||||||
<SelectItem value="failover">Failover (приоритет)</SelectItem>
|
|
||||||
<SelectItem value="weighted">Weighted (веса)</SelectItem>
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
</AppField>
|
|
||||||
<HealthCheckConfigFields
|
<HealthCheckConfigFields
|
||||||
value={{
|
value={{
|
||||||
lb_mode: binding.lb_mode,
|
lb_mode: binding.lb_mode,
|
||||||
@@ -648,10 +618,9 @@ export function ServiceEditSheet({
|
|||||||
onChange={(next) =>
|
onChange={(next) =>
|
||||||
handleBindingHealthChange(index, next)
|
handleBindingHealthChange(index, next)
|
||||||
}
|
}
|
||||||
showLbMode={false}
|
lbModeLabel="Режим балансировки"
|
||||||
idPrefix={`binding-${index}-health`}
|
idPrefix={`binding-${index}-health`}
|
||||||
/>
|
/>
|
||||||
</AppFieldGroup>
|
|
||||||
</AccordionContent>
|
</AccordionContent>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ import {
|
|||||||
AccordionItem,
|
AccordionItem,
|
||||||
AccordionTrigger,
|
AccordionTrigger,
|
||||||
} from '@cfdm/ui/components/accordion'
|
} from '@cfdm/ui/components/accordion'
|
||||||
import { Separator } from '@cfdm/ui/components/separator'
|
|
||||||
|
|
||||||
const groupTypes = [
|
const groupTypes = [
|
||||||
{ value: 'vpn', label: 'VPN' },
|
{ value: 'vpn', label: 'VPN' },
|
||||||
@@ -201,9 +200,7 @@ export function ServiceGroupEditSheet({
|
|||||||
</AppFieldGroup>
|
</AppFieldGroup>
|
||||||
|
|
||||||
{hasDomain && (
|
{hasDomain && (
|
||||||
<>
|
<Accordion defaultValue={['lb-health']}>
|
||||||
<Separator />
|
|
||||||
<Accordion>
|
|
||||||
<AccordionItem value="lb-health">
|
<AccordionItem value="lb-health">
|
||||||
<AccordionTrigger>Балансировка и Health-check</AccordionTrigger>
|
<AccordionTrigger>Балансировка и Health-check</AccordionTrigger>
|
||||||
<AccordionContent>
|
<AccordionContent>
|
||||||
@@ -216,7 +213,6 @@ export function ServiceGroupEditSheet({
|
|||||||
</AccordionContent>
|
</AccordionContent>
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</FormSheet>
|
</FormSheet>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user