feat(api, web): enhance health check and domain management features
Build, Test, and Push CFDM Docker Image / test (push) Successful in 3m3s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Successful in 1m48s
Build, Test, and Push CFDM Docker Image / update-wiki (push) Successful in 6s
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped
Build, Test, and Push CFDM Docker Image / test (push) Successful in 3m3s
Build, Test, and Push CFDM Docker Image / build-and-push (push) Successful in 1m48s
Build, Test, and Push CFDM Docker Image / update-wiki (push) Successful in 6s
Build, Test, and Push CFDM Docker Image / create-release (push) Has been skipped
- Integrated domain monitoring routes and bulk update functionality for domains in the API. - Improved health check service to include domain monitoring and logging of health status changes. - Updated web components to reflect health status with new HealthCheckBadge and enhanced domain filtering options. - Refactored domain service to support bulk updates and improved domain management capabilities. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { createFileRoute, Link } from '@tanstack/react-router'
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useForm } from 'react-hook-form'
|
||||
@@ -6,8 +6,9 @@ import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { toast } from 'sonner'
|
||||
import type { Filter } from '@/components/reui/filters'
|
||||
import { api } from '@/lib/api-client'
|
||||
import { createDomainSchema, type CreateDomainInput } from '@/lib/schemas'
|
||||
import { createDomainSchema, type BulkUpdateDomainsInput, type CreateDomainInput } from '@/lib/schemas'
|
||||
import {
|
||||
bulkUpdateDomains,
|
||||
domainKeys,
|
||||
domainsListQueryOptions,
|
||||
groupsQueryOptions,
|
||||
@@ -23,6 +24,7 @@ import {
|
||||
useDomainColumns,
|
||||
useDomainFilterFields,
|
||||
} from '@/components/columns/domains-columns'
|
||||
import { DomainsBulkToolbar } from '@/components/domains/domains-bulk-toolbar'
|
||||
import { FormSheet } from '@/components/form-sheet'
|
||||
import { FormFieldSimple } from '@/components/form-field'
|
||||
import { LoadingButton } from '@/components/loading-button'
|
||||
@@ -106,9 +108,21 @@ function DomainsPage() {
|
||||
},
|
||||
})
|
||||
|
||||
const bulkMutation = useMutation({
|
||||
mutationFn: (body: BulkUpdateDomainsInput) => bulkUpdateDomains(body),
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({ queryKey: domainKeys.all })
|
||||
toast.success(`Обновлено: ${data.updated}`)
|
||||
},
|
||||
onError: (err) => {
|
||||
toast.error(err instanceof Error ? err.message : 'Не удалось обновить')
|
||||
},
|
||||
})
|
||||
|
||||
const { columns } = useDomainColumns({
|
||||
onRequestDelete: setDeleteTarget,
|
||||
isDeleting: deleteMutation.isPending,
|
||||
enableSelection: true,
|
||||
})
|
||||
|
||||
const handleCreate = (values: CreateDomainInput) => {
|
||||
@@ -125,14 +139,9 @@ function DomainsPage() {
|
||||
}
|
||||
|
||||
const primaryAction = (
|
||||
<>
|
||||
<Button type="button" variant="outline" nativeButton={false} render={<Link to="/groups" />}>
|
||||
Группы
|
||||
</Button>
|
||||
<Button type="button" onClick={() => setSheetOpen(true)}>
|
||||
Импортировать домен
|
||||
</Button>
|
||||
</>
|
||||
<Button type="button" onClick={() => setSheetOpen(true)}>
|
||||
Импортировать домен
|
||||
</Button>
|
||||
)
|
||||
|
||||
return (
|
||||
@@ -155,6 +164,33 @@ function DomainsPage() {
|
||||
error={error}
|
||||
onRetry={refetch}
|
||||
primaryAction={primaryAction}
|
||||
enableRowSelection
|
||||
selectionToolbar={({ selectedIds, clearSelection }) => (
|
||||
<DomainsBulkToolbar
|
||||
count={selectedIds.length}
|
||||
isPending={bulkMutation.isPending}
|
||||
groupItems={groupItems}
|
||||
onAssignGroup={(groupId) => {
|
||||
bulkMutation.mutate(
|
||||
{ ids: selectedIds.map(Number), group_id: groupId },
|
||||
{ onSuccess: () => clearSelection() },
|
||||
)
|
||||
}}
|
||||
onSetEnvironment={(environment) => {
|
||||
bulkMutation.mutate(
|
||||
{ ids: selectedIds.map(Number), environment },
|
||||
{ onSuccess: () => clearSelection() },
|
||||
)
|
||||
}}
|
||||
onAddTag={(tag) => {
|
||||
bulkMutation.mutate(
|
||||
{ ids: selectedIds.map(Number), tags_add: [tag] },
|
||||
{ onSuccess: () => clearSelection() },
|
||||
)
|
||||
}}
|
||||
onClear={clearSelection}
|
||||
/>
|
||||
)}
|
||||
emptyState={{
|
||||
title: 'Домены не импортированы',
|
||||
description: 'Импортируйте зону из аккаунта Cloudflare',
|
||||
|
||||
Reference in New Issue
Block a user