This is an automated email from the ASF dual-hosted git repository. mintsweet pushed a commit to branch fix-historical-pipelines-incomplete in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 84e3fb823bba97cff06eb43bea667cdd9cf9f7b1 Author: mintsweet <[email protected]> AuthorDate: Thu Sep 19 20:38:37 2024 +1200 fix: incomplete historical pipelines --- config-ui/src/api/blueprint/index.ts | 2 +- .../src/routes/blueprint/detail/status-panel.tsx | 42 ++++++++++------------ config-ui/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 727c026de..3876d3e20 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<IBlueprint>) => 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 bbc04ee6a..09d2fdf25 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<IPipeline[]>( - 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) = <h3>Historical Pipelines</h3> - {!data?.length ? ( + {!data?.count ? ( <Card>There are no historical runs associated with this blueprint.</Card> ) : ( - <PipelineTable loading={loading} dataSource={data} /> + <PipelineTable + loading={!ready} + dataSource={data.pipelines} + pagination={{ + current: page, + pageSize, + total: data.count, + onChange: setPage, + }} + /> )} </Space> diff --git a/config-ui/src/routes/pipeline/components/table.tsx b/config-ui/src/routes/pipeline/components/table.tsx index d63ddd6ce..ca16ed890 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 778d200d9..3411ec810 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, }} />
