'use client';
import { useState, useEffect } from 'react';
import Link from 'next/link';
import {
Beaker,
Play,
Pause,
CheckCircle,
AlertCircle,
Clock,
ChevronRight,
RefreshCw,
} from 'lucide-react';
import type { PipelineInfo } from '@/lib/pipeline-types';
import { listPipelines } from '@/lib/pipeline-api';
/**
* Pipeline card component.
*/
function PipelineCard({ pipeline }: { pipeline: PipelineInfo }) {
return (
{pipeline.name}
v{pipeline.version}
{pipeline.description}
Stages:
{pipeline.stages.slice(0, 3).map((stage, i) => (
{stage}
))}
{pipeline.stages.length > 3 && (
+{pipeline.stages.length - 3} more
)}
{pipeline.is_enabled ? 'Enabled' : 'Disabled'}
);
}
/**
* Pipelines list page.
*/
export default function PipelinesPage() {
const [pipelines, setPipelines] = useState([]);
const [loading, setLoading] = useState(true);
const [error, setError] = useState(null);
const [showDisabled, setShowDisabled] = useState(false);
const fetchPipelines = async () => {
setLoading(true);
setError(null);
try {
const data = await listPipelines(!showDisabled);
setPipelines(data);
} catch (e) {
setError(e instanceof Error ? e.message : 'Failed to load pipelines');
} finally {
setLoading(false);
}
};
useEffect(() => {
fetchPipelines();
}, [showDisabled]);
return (
{/* Header */}
{/* Content */}
{error ? (
) : loading ? (
{[1, 2, 3].map((i) => (
))}
) : pipelines.length === 0 ? (
) : (
{pipelines.map((pipeline) => (
))}
)}
);
}