From 84e3fb823bba97cff06eb43bea667cdd9cf9f7b1 Mon Sep 17 00:00:00 2001 From: mintsweet <0x1304570@gmail.com> Date: Thu, 19 Sep 2024 20:38:37 +1200 Subject: [PATCH] fix: incomplete historical pipelines --- config-ui/src/api/blueprint/index.ts | 2 +- .../routes/blueprint/detail/status-panel.tsx | 42 ++++++++----------- .../src/routes/pipeline/components/table.tsx | 2 +- config-ui/src/routes/pipeline/pipelines.tsx | 4 +- 4 files changed, 22 insertions(+), 28 deletions(-) diff --git a/config-ui/src/api/blueprint/index.ts b/config-ui/src/api/blueprint/index.ts index 727c026de68..3876d3e20da 100644 --- a/config-ui/src/api/blueprint/index.ts +++ b/config-ui/src/api/blueprint/index.ts @@ -34,7 +34,7 @@ export const remove = (id: ID) => request(`/blueprints/${id}`, { method: 'delete export const update = (id: ID, data: Partial) => request(`/blueprints/${id}`, { method: 'patch', data }); -export const pipelines = (id: ID) => request(`/blueprints/${id}/pipelines`); +export const pipelines = (id: ID, data?: Pagination) => request(`/blueprints/${id}/pipelines`, { data }); type TriggerQuery = { skipCollectors?: boolean; diff --git a/config-ui/src/routes/blueprint/detail/status-panel.tsx b/config-ui/src/routes/blueprint/detail/status-panel.tsx index bbc04ee6aed..09d2fdf2529 100644 --- a/config-ui/src/routes/blueprint/detail/status-panel.tsx +++ b/config-ui/src/routes/blueprint/detail/status-panel.tsx @@ -24,9 +24,9 @@ import { Card, Modal, Switch, Button, Tooltip, Dropdown, Flex, Space } from 'ant import API from '@/api'; import { Message } from '@/components'; import { getCron } from '@/config'; -import { useAutoRefresh } from '@/hooks'; +import { useRefreshData } from '@/hooks'; import { PipelineInfo, PipelineTasks, PipelineTable } from '@/routes/pipeline'; -import { IBlueprint, IPipeline, IPipelineStatus } from '@/types'; +import { IBlueprint } from '@/types'; import { formatTime, operator } from '@/utils'; import { FromEnum } from '../types'; @@ -40,32 +40,17 @@ interface Props { export const StatusPanel = ({ from, blueprint, pipelineId, onRefresh }: Props) => { const [type, setType] = useState<'delete' | 'fullSync'>(); + const [page, setPage] = useState(1); + const [pageSize] = useState(10); const [operating, setOperating] = useState(false); const navigate = useNavigate(); const cron = useMemo(() => getCron(blueprint.isManual, blueprint.cronConfig), [blueprint]); - const { loading, data } = useAutoRefresh( - async () => { - const res = await API.blueprint.pipelines(blueprint.id); - return res.pipelines; - }, - [], - { - cancel: (data) => - !!( - data && - data.every((it) => - [ - IPipelineStatus.COMPLETED, - IPipelineStatus.PARTIAL, - IPipelineStatus.CANCELLED, - IPipelineStatus.FAILED, - ].includes(it.status), - ) - ), - }, + const { ready, data } = useRefreshData( + () => API.blueprint.pipelines(blueprint.id, { page, pageSize }), + [blueprint.id, page, pageSize], ); const handleResetType = () => { @@ -209,10 +194,19 @@ export const StatusPanel = ({ from, blueprint, pipelineId, onRefresh }: Props) =

Historical Pipelines

- {!data?.length ? ( + {!data?.count ? ( There are no historical runs associated with this blueprint. ) : ( - + )} diff --git a/config-ui/src/routes/pipeline/components/table.tsx b/config-ui/src/routes/pipeline/components/table.tsx index d63ddd6cedc..ca16ed890bf 100644 --- a/config-ui/src/routes/pipeline/components/table.tsx +++ b/config-ui/src/routes/pipeline/components/table.tsx @@ -37,7 +37,7 @@ interface Props { dataSource: IPipeline[]; pagination?: { total: number; - page: number; + current: number; pageSize: number; onChange: (page: number) => void; }; diff --git a/config-ui/src/routes/pipeline/pipelines.tsx b/config-ui/src/routes/pipeline/pipelines.tsx index 778d200d980..3411ec810ea 100644 --- a/config-ui/src/routes/pipeline/pipelines.tsx +++ b/config-ui/src/routes/pipeline/pipelines.tsx @@ -42,9 +42,9 @@ export const Pipelines = () => { loading={!ready} dataSource={dataSource} pagination={{ - total, - page, + current: page, pageSize, + total, onChange: setPage, }} />