Skip to content

Commit

Permalink
fix: incomplete historical pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
mintsweet committed Sep 19, 2024
1 parent f0ad6f5 commit 84e3fb8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion config-ui/src/api/blueprint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
42 changes: 18 additions & 24 deletions config-ui/src/routes/blueprint/detail/status-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 = () => {
Expand Down Expand Up @@ -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>

Expand Down
2 changes: 1 addition & 1 deletion config-ui/src/routes/pipeline/components/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ interface Props {
dataSource: IPipeline[];
pagination?: {
total: number;
page: number;
current: number;
pageSize: number;
onChange: (page: number) => void;
};
Expand Down
4 changes: 2 additions & 2 deletions config-ui/src/routes/pipeline/pipelines.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export const Pipelines = () => {
loading={!ready}
dataSource={dataSource}
pagination={{
total,
page,
current: page,
pageSize,
total,
onChange: setPage,
}}
/>
Expand Down

0 comments on commit 84e3fb8

Please sign in to comment.