Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

UN-3154 [FEAT] Card based layout to list Pipelines and API Deployments (#1769)

Chandrasekharan Meb4cb95bd1ce
diff --git a/backend/api_v2/api_deployment_views.py b/backend/api_v2/api_deployment_views.py
index 92468a2f9..7462864f0 100644
--- a/backend/api_v2/api_deployment_views.py
+++ b/backend/api_v2/api_deployment_views.py
@@ -4,7 +4,7 @@ import uuid
from typing import Any
from configuration.models import Configuration
-from django.db.models import QuerySet
+from django.db.models import F, OuterRef, QuerySet, Subquery
from django.http import HttpResponse
from permissions.permission import IsOwner, IsOwnerOrSharedUserOrSharedToOrg
from plugins import get_plugin
@@ -16,7 +16,9 @@ from rest_framework.response import Response
from rest_framework.serializers import Serializer
from tool_instance_v2.models import ToolInstance
from utils.enums import CeleryTaskState
+from utils.pagination import CustomPagination
from workflow_manager.workflow_v2.dto import ExecutionResponse
+from workflow_manager.workflow_v2.models.execution import WorkflowExecution
from api_v2.api_deployment_dto_registry import ApiDeploymentDTORegistry
from api_v2.constants import ApiExecution
@@ -243,19 +245,37 @@ class DeploymentExecution(views.APIView):
class APIDeploymentViewSet(viewsets.ModelViewSet):
+ pagination_class = CustomPagination
+
def get_permissions(self) -> list[Any]:
if self.action in ["destroy", "partial_update", "update"]:
return [IsOwner()]
return [IsOwnerOrSharedUserOrSharedToOrg()]
def get_queryset(self) -> QuerySet | None:
- queryset = APIDeployment.objects.for_user(self.request.user)
+ # Subquery to get last run time for ordering
+ last_run_subquery = (
+ WorkflowExecution.objects.filter(pipeline_id=OuterRef("id"))
+ .order_by("-created_at")
+ .values("created_at")[:1]
+ )
+
+ queryset = (
+ APIDeployment.objects.for_user(self.request.user)
+ .annotate(last_run_time_annotated=Subquery(last_run_subquery))
+ .order_by(F("last_run_time_annotated").desc(nulls_last=True))
+ )
# Filter by workflow ID if provided
workflow_filter = self.request.query_params.get("workflow", None)
if workflow_filter:
queryset = queryset.filter(workflow_id=workflow_filter)
+ # Search by display name
+ search = self.request.query_params.get("search", None)
+ if search:
+ queryset = queryset.filter(display_name__icontains=search)
+
return queryset
def get_serializer_class(self) -> serializers.Serializer:
diff --git a/backend/api_v2/serializers.py b/backend/api_v2/serializers.py
index 1f5c10269..5a2068fd9 100644
--- a/backend/api_v2/serializers.py
+++ b/backend/api_v2/serializers.py
@@ -425,6 +425,9 @@ class ExecutionQuerySerializer(Serializer):
class APIDeploymentListSerializer(ModelSerializer):
workflow_name = CharField(source="workflow.workflow_name", read_only=True)
created_by_email = SerializerMethodField()
+ last_5_run_statuses = SerializerMethodField()
+ run_count = SerializerMethodField()
+ last_run_time = SerializerMethodField()
class Meta:
model = APIDeployment
@@ -439,12 +442,32 @@ class APIDeploymentListSerializer(ModelSerializer):
"api_name",
"created_by",
"created_by_email",
+ "last_5_run_statuses",
+ "run_count",
+ "last_run_time",
]
def get_created_by_email(self, obj):
"""Get the email of the creator."""
return obj.created_by.email if obj.created_by else None
+ def get_run_count(self, instance) -> int:
+ """Get total execution count for this API deployment."""
+ return WorkflowExecution.objects.filter(pipeline_id=instance.id).count()
+
+ def get_last_run_time(self, instance) -> str | None:
+ """Get the timestamp of the most recent execution."""
+ last_execution = (
+ WorkflowExecution.objects.filter(pipeline_id=instance.id)
+ .order_by("-created_at")
+ .first()
+ )
+ return last_execution.created_at.isoformat() if last_execution else None
+
+ def get_last_5_run_statuses(self, instance) -> list[dict]:
+ """Fetch the last 5 execution statuses with timestamps for this API deployment."""
+ return WorkflowExecution.get_last_run_statuses(instance.id, limit=5)
+
class APIKeyListSerializer(ModelSerializer):
class Meta:
diff --git a/backend/dashboard_metrics/services.py b/backend/dashboard_metrics/services.py
index 1942bd7aa..2697bf89a 100644
--- a/backend/dashboard_metrics/services.py
+++ b/backend/dashboard_metrics/services.py
@@ -19,6 +19,7 @@ from pipeline_v2.models import Pipeline
from usage_v2.models import Usage
from workflow_manager.file_execution.models import WorkflowFileExecution
from workflow_manager.workflow_v2.models.execution import WorkflowExecution
+from workflow_manager.workflow_v2.models.workflow import Workflow
from dashboard_metrics.models import Granularity
from unstract.core.data_models import ExecutionStatus
@@ -716,8 +717,6 @@ class MetricsQueryService:
List of dicts with workflow_id, workflow_name, total_tokens,
total_cost, and call_count, ordered by total_tokens descending.
"""
- from workflow_manager.workflow_v2.models.workflow import Workflow
-
# Query Usage grouped by workflow_id
usage_qs = (
_get_usage_queryset()
diff --git a/backend/dashboard_metrics/tasks.py b/backend/dashboard_metrics/tasks.py
index 414d86ad1..879bc8d1f 100644
--- a/backend/dashboard_metrics/tasks.py
+++ b/backend/dashboard_metrics/tasks.py
@@ -10,10 +10,12 @@ import logging
from datetime import datetime, timedelta
from typing import Any
+from account_v2.models import Organization
from celery import shared_task
from django.core.cache import cache
from django.db.utils import DatabaseError, OperationalError
from django.utils import timezone
+from workflow_manager.workflow_v2.models.execution import WorkflowExecution
from .models import (
EventMetricsDaily,
@@ -241,9 +243,6 @@ def _run_aggregation() -> dict[str, Any]:
Separated from the task function to keep the lock management clean.
"""
- from account_v2.models import Organization
- from workflow_manager.workflow_v2.models.execution import WorkflowExecution
-
end_date = timezone.now()
# Query windows for each granularity
diff --git a/backend/dashboard_metrics/tests/test_tasks.py b/backend/dashboard_metrics/tests/test_tasks.py
index 2a9f25fd9..1e38e2ca8 100644
--- a/backend/dashboard_metrics/tests/test_tasks.py
+++ b/backend/dashboard_metrics/tests/test_tasks.py
@@ -1,7 +1,7 @@
"""Unit tests for Dashboard Metrics Celery tasks."""
import uuid
-from datetime import timedelta
+from datetime import datetime, timedelta
from django.test import TestCase, TransactionTestCase
from django.utils import timezone
@@ -37,7 +37,6 @@ class TestTimeHelpers(TestCase):
def test_truncate_to_hour_from_datetime(self):
"""Test truncating a datetime to the hour."""
- from datetime import datetime
dt = datetime(2024, 1, 15, 14, 35, 22, tzinfo=timezone.utc)
result = _truncate_to_hour(dt)
@@ -49,7 +48,6 @@ class TestTimeHelpers(TestCase):
def test_truncate_to_hour_naive_datetime(self):
"""Test truncating a naive datetime makes it aware."""
- from datetime import datetime
dt = datetime(2024, 1, 15, 14, 35, 22)
result = _truncate_to_hour(dt)
@@ -60,7 +58,6 @@ class TestTimeHelpers(TestCase):
def test_truncate_to_day(self):
"""Test truncating a datetime to midnight."""
- from datetime import datetime
dt = datetime(2024, 1, 15, 14, 35, 22, tzinfo=timezone.utc)
result = _truncate_to_day(dt)
@@ -73,7 +70,6 @@ class TestTimeHelpers(TestCase):
def test_truncate_to_month(self):
"""Test truncating a datetime to first day of month."""
- from datetime import datetime
dt = datetime(2024, 1, 15, 14, 35, 22, tzinfo=timezone.utc)
result = _truncate_to_month(dt)
diff --git a/backend/dashboard_metrics/views.py b/backend/dashboard_metrics/views.py
index 658f85856..6a4db3658 100644
--- a/backend/dashboard_metrics/views.py
+++ b/backend/dashboard_metrics/views.py
@@ -403,8 +403,6 @@ class DashboardMetricsViewSet(viewsets.ReadOnlyModelViewSet):
)
# Apply granularity-based grouping to cached records
- from datetime import datetime
-
trunc_funcs = {
Granularity.HOUR: lambda ts: ts.replace(
minute=0, second=0, microsecond=0
diff --git a/backend/pipeline_v2/serializers/crud.py b/backend/pipeline_v2/serializers/crud.py
index 6e725844c..f887042b9 100644
--- a/backend/pipeline_v2/serializers/crud.py
+++ b/backend/pipeline_v2/serializers/crud.py
@@ -1,9 +1,11 @@
import logging
from collections import OrderedDict
+from datetime import datetime
from typing import Any
from croniter import croniter
from django.conf import settings
+from django.utils import timezone
from pipeline_v2.constants import PipelineConstants as PC
from pipeline_v2.constants import PipelineKey as PK
from pipeline_v2.constants import PipelineScheduling
@@ -14,6 +16,7 @@ from scheduler.helper import SchedulerHelper
from utils.serializer.integrity_error_mixin import IntegrityErrorMixin
from utils.serializer_utils import SerializerUtils
from workflow_manager.endpoint_v2.models import WorkflowEndpoint
+from workflow_manager.workflow_v2.models.execution import WorkflowExecution
from backend.serializers import AuditSerializer
from unstract.connectors.connectorkit import Connectorkit
@@ -25,6 +28,8 @@ DEPLOYMENT_ENDPOINT = settings.API_DEPLOYMENT_PATH_PREFIX + "/pipeline"
class PipelineSerializer(IntegrityErrorMixin, AuditSerializer):
api_endpoint = SerializerMethodField()
created_by_email = SerializerMethodField()
+ last_5_run_statuses = SerializerMethodField()
+ next_run_time = SerializerMethodField()
class Meta:
model = Pipeline
@@ -200,6 +205,21 @@ class PipelineSerializer(IntegrityErrorMixin, AuditSerializer):
"""Get the creator's email address."""
return obj.created_by.email if obj.created_by else None
+ def get_last_5_run_statuses(self, instance: Pipeline) -> list[dict]:
+ """Fetch the last 5 execution statuses with timestamps for this pipeline."""
+ return WorkflowExecution.get_last_run_statuses(instance.id, limit=5)
+
+ def get_next_run_time(self, instance: Pipeline) -> str | None:
+ """Calculate next scheduled run time from cron expression."""
+ if not instance.cron_string or not instance.active:
+ return None
+ try:
+ cron = croniter(instance.cron_string, timezone.now())
+ next_run: datetime = cron.get_next(datetime)
+ return next_run.isoformat()
+ except Exception:
+ return None
+
def create(self, validated_data: dict[str, Any]) -> Any:
# TODO: Deduce pipeline type based on WF?
validated_data[PK.ACTIVE] = True
@@ -242,6 +262,8 @@ class PipelineSerializer(IntegrityErrorMixin, AuditSerializer):
"""
repr[PC.SOURCE_NAME] = PC.NOT_CONFIGURED
repr[PC.DESTINATION_NAME] = PC.NOT_CONFIGURED
+ repr["source_instance_name"] = None
+ repr["destination_instance_name"] = None
for endpoint in workflow_endpoints:
if endpoint.endpoint_type == WorkflowEndpoint.EndpointType.SOURCE:
@@ -250,6 +272,10 @@ class PipelineSerializer(IntegrityErrorMixin, AuditSerializer):
connectors=connectors,
connector_id=endpoint.connector_instance.connector_id,
)
+ # User-set connector instance name
+ repr["source_instance_name"] = (
+ endpoint.connector_instance.connector_name
+ )
elif endpoint.endpoint_type == WorkflowEndpoint.EndpointType.DESTINATION:
if (
endpoint.connection_type
@@ -263,6 +289,10 @@ class PipelineSerializer(IntegrityErrorMixin, AuditSerializer):
connector_id=endpoint.connector_instance.connector_id,
)
)
+ # User-set connector instance name
+ repr["destination_instance_name"] = (
+ endpoint.connector_instance.connector_name
+ )
return repr
def to_representation(self, instance: Pipeline) -> OrderedDict[str, Any]:
diff --git a/backend/pipeline_v2/views.py b/backend/pipeline_v2/views.py
index 64b6a8b26..0d902a792 100644
--- a/backend/pipeline_v2/views.py
+++ b/backend/pipeline_v2/views.py
@@ -7,16 +7,18 @@ from api_v2.exceptions import NoActiveAPIKeyError
from api_v2.key_helper import KeyHelper
from api_v2.postman_collection.dto import PostmanCollection
from django.db import IntegrityError
-from django.db.models import QuerySet
+from django.db.models import F, QuerySet
from django.http import HttpResponse
from permissions.permission import IsOwner, IsOwnerOrSharedUserOrSharedToOrg
from plugins import get_plugin
from rest_framework import serializers, status, viewsets
from rest_framework.decorators import action
+from rest_framework.filters import OrderingFilter
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.versioning import URLPathVersioning
from scheduler.helper import SchedulerHelper
+from utils.pagination import CustomPagination
from pipeline_v2.constants import (
PipelineConstants,
@@ -43,6 +45,11 @@ logger = logging.getLogger(__name__)
class PipelineViewSet(viewsets.ModelViewSet):
versioning_class = URLPathVersioning
queryset = Pipeline.objects.all()
+ pagination_class = CustomPagination
+ filter_backends = [OrderingFilter]
+ ordering_fields = ["created_at", "last_run_time", "pipeline_name", "run_count"]
+ # Note: Default ordering with nulls_last is applied in get_queryset()
+ # DRF's ordering attribute doesn't support nulls_last natively
def get_permissions(self) -> list[Any]:
if self.action in ["destroy", "partial_update", "update"]:
@@ -65,6 +72,18 @@ class PipelineViewSet(viewsets.ModelViewSet):
if workflow_filter:
queryset = queryset.filter(workflow_id=workflow_filter)
+ # Search by pipeline name
+ search = self.request.query_params.get("search", None)
+ if search:
+ queryset = queryset.filter(pipeline_name__icontains=search)
+
+ # Apply default ordering: last_run_time desc (nulls last), then created_at desc
+ # This ensures pipelines with recent runs appear first, never-run pipelines at end
+ queryset = queryset.order_by(
+ F("last_run_time").desc(nulls_last=True),
+ F("created_at").desc(),
+ )
+
return queryset
def get_serializer_class(self) -> serializers.Serializer:
diff --git a/backend/workflow_manager/workflow_v2/models/execution.py b/backend/workflow_manager/workflow_v2/models/execution.py
index 11b5fdb37..5c7a8ba3a 100644
--- a/backend/workflow_manager/workflow_v2/models/execution.py
+++ b/backend/workflow_manager/workflow_v2/models/execution.py
@@ -15,6 +15,7 @@ from utils.models.base_model import BaseModel
from workflow_manager.execution.dto import ExecutionCache
from workflow_manager.execution.execution_cache_utils import ExecutionCacheUtils
+from workflow_manager.file_execution.models import WorkflowFileExecution
from workflow_manager.workflow_v2.enums import ExecutionStatus
from workflow_manager.workflow_v2.models import Workflow
@@ -370,3 +371,53 @@ class WorkflowExecution(BaseModel):
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
self._handle_execution_cache()
+
+ @classmethod
+ def get_last_run_statuses(cls, pipeline_id: uuid.UUID, limit: int = 5) -> list[dict]:
+ """Fetch the last N execution statuses for a pipeline.
+
+ Computes PARTIAL_SUCCESS dynamically when execution completed but has
+ both successful and failed files.
+
+ Args:
+ pipeline_id: UUID of the pipeline (ETL or API deployment)
+ limit: Number of recent executions to fetch (default 5)
+
+ Returns:
+ List of dicts with execution_id, status, timestamp, and file counts.
+ Ordered oldest to newest (for left-to-right timeline display).
+ """
+ executions = cls.objects.filter(pipeline_id=pipeline_id).order_by("-created_at")[
+ :limit
+ ]
+
+ result = []
+ for e in executions:
+ # TODO: Optimize by storing successful/failed counts directly in
+ # WorkflowExecution model. Current approach causes N+1 queries
+ # (2 queries per execution). Denormalized counts would eliminate
+ # these queries entirely.
+ successful = WorkflowFileExecution.objects.filter(
+ workflow_execution_id=e.id, status="COMPLETED"
+ ).count()
+ failed = WorkflowFileExecution.objects.filter(
+ workflow_execution_id=e.id, status="ERROR"
+ ).count()
+
+ # Compute display_status: PARTIAL_SUCCESS if completed with mixed results
+ display_status = e.status
+ if e.status == "COMPLETED" and failed > 0 and successful > 0:
+ display_status = "PARTIAL_SUCCESS"
+
+ result.append(
+ {
+ "execution_id": str(e.id),
+ "status": display_status,
+ "timestamp": e.created_at.isoformat() if e.created_at else None,
+ "successful_files": successful,
+ "failed_files": failed,
+ }
+ )
+
+ # Reverse to get oldest first (left-to-right timeline)
+ return list(reversed(result))
diff --git a/frontend/src/components/deployments/api-deployment/ApiDeployment.jsx b/frontend/src/components/deployments/api-deployment/ApiDeployment.jsx
index 17a42a730..7805e1640 100644
--- a/frontend/src/components/deployments/api-deployment/ApiDeployment.jsx
+++ b/frontend/src/components/deployments/api-deployment/ApiDeployment.jsx
@@ -1,33 +1,23 @@
-import {
- CloudDownloadOutlined,
- CodeOutlined,
- CopyOutlined,
- DeleteOutlined,
- EditOutlined,
- EllipsisOutlined,
- FileSearchOutlined,
- KeyOutlined,
- NotificationOutlined,
- ShareAltOutlined,
-} from "@ant-design/icons";
-import { Button, Dropdown, Space, Switch, Tooltip, Typography } from "antd";
-import { useEffect, useState } from "react";
-import { useNavigate } from "react-router-dom";
+import { useEffect, useMemo, useRef, useState } from "react";
+import { useLocation } from "react-router-dom";
import { deploymentApiTypes, displayURL } from "../../../helpers/GetStaticData";
import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate.js";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
+import { useExecutionLogs } from "../../../hooks/useExecutionLogs";
+import { usePaginatedList } from "../../../hooks/usePaginatedList";
import usePipelineHelper from "../../../hooks/usePipelineHelper.js";
import {
useInitialFetchCount,
usePromptStudioModal,
} from "../../../hooks/usePromptStudioFetchCount";
+import { useScrollRestoration } from "../../../hooks/useScrollRestoration";
+import { useShareModal } from "../../../hooks/useShareModal";
import { useAlertStore } from "../../../store/alert-store";
import { usePromptStudioStore } from "../../../store/prompt-studio-store";
import { useSessionStore } from "../../../store/session-store";
import { usePromptStudioService } from "../../api/prompt-studio-service";
import { PromptStudioModal } from "../../common/PromptStudioModal";
-import { fetchExecutionLogs } from "../../pipelines-or-deployments/log-modal/fetchExecutionLogs";
import { LogsModal } from "../../pipelines-or-deployments/log-modal/LogsModal.jsx";
import { NotificationModal } from "../../pipelines-or-deployments/notification-modal/NotificationModal.jsx";
import { SharePermission } from "../../widgets/share-permission/SharePermission";
@@ -37,12 +27,13 @@ import { DeleteModal } from "../delete-modal/DeleteModal";
import { DisplayCode } from "../display-code/DisplayCode";
import { Layout } from "../layout/Layout";
import { ManageKeys } from "../manage-keys/ManageKeys";
+import { createApiDeploymentCardConfig } from "./ApiDeploymentCardConfig.jsx";
import { apiDeploymentsService } from "./api-deployments-service";
function ApiDeployment() {
const { sessionDetails } = useSessionStore();
const { setAlertDetails } = useAlertStore();
- const navigate = useNavigate();
+ const location = useLocation();
const apiDeploymentsApiService = apiDeploymentsService();
const workflowApiService = workflowService();
const [isTableLoading, setIsTableLoading] = useState(true);
@@ -52,150 +43,84 @@ function ApiDeployment() {
const [openManageKeysModal, setOpenManageKeysModal] = useState(false);
const [selectedRow, setSelectedRow] = useState({});
const [tableData, setTableData] = useState([]);
+ const [filteredData, setFilteredData] = useState([]);
const [apiKeys, setApiKeys] = useState([]);
const [isEdit, setIsEdit] = useState(false);
const [workflowEndpointList, setWorkflowEndpointList] = useState([]);
const handleException = useExceptionHandler();
- const [openLogsModal, setOpenLogsModal] = useState(false);
- const [executionLogs, setExecutionLogs] = useState([]);
- const [executionLogsTotalCount, setExecutionLogsTotalCount] = useState(0);
const axiosPrivate = useAxiosPrivate();
- const { getApiKeys, downloadPostmanCollection, copyUrl } =
- usePipelineHelper();
+ const { getApiKeys, downloadPostmanCollection } = usePipelineHelper();
const [openNotificationModal, setOpenNotificationModal] = useState(false);
- const [openShareModal, setOpenShareModal] = useState(false);
- const [allUsers, setAllUsers] = useState([]);
- const [isLoadingShare, setIsLoadingShare] = useState(false);
const { count, isLoading, fetchCount } = usePromptStudioStore();
const { getPromptStudioCount } = usePromptStudioService();
+ // Ref to forward the fetch function to hooks (avoids declaration ordering)
+ const fetchListRef = useRef(null);
+
+ const {
+ pagination,
+ setPagination,
+ searchTerm,
+ setSearchTerm,
+ handlePaginationChange,
+ handleSearch,
+ } = usePaginatedList({
+ fetchData: (...args) => fetchListRef.current?.(...args),
+ });
+
+ const { scrollRestoreId, activateScrollRestore, clearPendingScroll } =
+ useScrollRestoration({
+ location,
+ setSearchTerm,
+ setPagination,
+ fetchData: (...args) => fetchListRef.current?.(...args),
+ });
+
+ const {
+ openLogsModal,
+ setOpenLogsModal,
+ executionLogs,
+ executionLogsTotalCount,
+ isFetchingLogs,
+ handleFetchLogs,
+ handleViewLogs,
+ } = useExecutionLogs({
+ axiosPrivate,
+ handleException,
+ sessionDetails,
+ setAlertDetails,
+ });
+
+ const {
+ openShareModal,
+ setOpenShareModal,
+ allUsers,
+ isLoadingShare,
+ handleShare,
+ onShare,
+ } = useShareModal({
+ apiService: apiDeploymentsApiService,
+ setSelectedItem: setSelectedRow,
+ setAlertDetails,
+ handleException,
+ refreshList: () =>
+ getApiDeploymentList(pagination.current, pagination.pageSize, searchTerm),
+ });
+
const initialFetchComplete = useInitialFetchCount(
fetchCount,
getPromptStudioCount,
);
- const handleFetchLogs = (page, pageSize) => {
- fetchExecutionLogs(
- axiosPrivate,
- handleException,
- sessionDetails,
- selectedRow,
- setExecutionLogs,
- setExecutionLogsTotalCount,
- setAlertDetails,
- page,
- pageSize,
- );
- };
-
- const columns = [
- {
- title: "API Name",
- key: "display_name",
- render: (_, record) => (
- <Typography.Text strong>{record?.display_name}</Typography.Text>
- ),
- align: "left",
- },
- {
- title: "Description",
- key: "description",
- render: (_, record) => <Space>{record?.description}</Space>,
- align: "left",
- },
- {
- title: "API Endpoint",
- key: "api_endpoint",
- render: (_, record) => (
- <Space direction="horizontal" className="display-flex-space-between">
- <div>
- <Typography.Text>
- {displayURL(record?.api_endpoint)}
- </Typography.Text>
- </div>
- <div>
- <Tooltip title="click to copy">
- <Button
- size="small"
- onClick={() => copyUrl(record?.api_endpoint)}
- >
- <CopyOutlined />
- </Button>
- </Tooltip>
- </div>
- </Space>
- ),
- align: "left",
- },
- {
- title: "Workflow",
- key: "workflow_name",
- render: (_, record) => (
- <Tooltip title="view workflow">
- <Space
- className="workflowName"
- onClick={() =>
- navigate(
- `/${sessionDetails?.orgName}/workflows/${record?.workflow}`,
- )
- }
- >
- {record?.workflow_name}
- </Space>
- </Tooltip>
- ),
- align: "left",
- },
- {
- title: "Owner",
- key: "created_by",
- render: (_, record) => {
- const currentUser = sessionDetails?.userId;
- const isOwner = record?.created_by === currentUser;
- return (
- <Space>
- {isOwner ? "You" : record?.created_by_email || "Unknown"}
- </Space>
- );
- },
- align: "left",
- },
- {
- title: "Enabled",
- key: "active",
- dataIndex: "active",
- align: "center",
- render: (_, record) => (
- <Switch
- size="small"
- checked={record.is_active}
- onChange={(e) => {
- updateStatus(record);
- }}
- />
- ),
- },
- {
- title: "Actions",
- key: "pipeline_id",
- align: "center",
- render: (_, record) => (
- <Dropdown
- menu={{ items: actionItems }}
- placement="bottomLeft"
- trigger={["click"]}
- onOpenChange={() => setSelectedRow(record)}
- >
- <EllipsisOutlined className="cur-pointer" />
- </Dropdown>
- ),
- },
- ];
-
useEffect(() => {
getApiDeploymentList();
getWorkflows();
}, []);
+
+ useEffect(() => {
+ setFilteredData(tableData);
+ }, [tableData]);
+
const getWorkflows = () => {
workflowApiService
.getWorkflowEndpointList("SOURCE", "API")
@@ -210,28 +135,45 @@ function ApiDeployment() {
});
};
- const getApiDeploymentList = () => {
+ const getApiDeploymentList = (page = 1, pageSize = 10, search = "") => {
setIsTableLoading(true);
apiDeploymentsApiService
- .getApiDeploymentsList()
+ .getApiDeploymentsList(page, pageSize, search)
.then((res) => {
- setTableData(res?.data);
+ const data = res?.data;
+ const results = data.results || data;
+ setTableData(results);
+ setPagination((prev) => ({
+ ...prev,
+ current: page,
+ pageSize,
+ total: data.count ?? data.results?.length ?? data.length,
+ }));
+
+ activateScrollRestore();
})
.catch((err) => {
setAlertDetails(handleException(err));
+ clearPendingScroll();
})
.finally(() => {
setIsTableLoading(false);
});
};
+ fetchListRef.current = getApiDeploymentList;
+
const deleteApiDeployment = () => {
apiDeploymentsApiService
.deleteApiDeployment(selectedRow.id)
.then((res) => {
setOpenDeleteModal(false);
- getApiDeploymentList();
+ getApiDeploymentList(
+ pagination.current,
+ pagination.pageSize,
+ searchTerm,
+ );
setAlertDetails({
type: "success",
content: "API Deployment Deleted Successfully",
@@ -242,17 +184,24 @@ function ApiDeployment() {
});
};
+ const updateItemStatus = (itemId, isActive) => {
+ setTableData((prev) =>
+ prev.map((item) =>
+ item.id === itemId ? { ...item, is_active: isActive } : item,
+ ),
+ );
+ };
+
const updateStatus = (record) => {
- setIsTableLoading(true);
- record.is_active = !record?.is_active;
+ const newStatus = !record?.is_active;
+ // Optimistic update - no loading spinner
+ updateItemStatus(record.id, newStatus);
+
apiDeploymentsApiService
- .updateApiDeployment(record)
- .then(() => {})
+ .updateApiDeployment({ ...record, is_active: newStatus })
.catch((err) => {
+ updateItemStatus(record.id, !newStatus);
setAlertDetails(handleException(err));
- })
- .finally(() => {
- setIsTableLoading(false);
});
};
@@ -261,235 +210,73 @@ function ApiDeployment() {
setOpenAddApiModal(true);
};
- const handleShare = async () => {
- setIsLoadingShare(true);
- setOpenShareModal(true);
- // Fetch all users
- try {
- const [usersResponse, sharedUsersResponse] = await Promise.all([
- apiDeploymentsApiService.getAllUsers(),
- apiDeploymentsApiService.getSharedUsers(selectedRow.id),
- ]);
+ // Handlers for card view actions
+ const handleEditDeployment = () => {
+ openAddModal(true);
+ };
- const userList =
- usersResponse?.data?.members?.map((member) => ({
- id: member.id,
- email: member.email,
- })) || [];
+ const handleDeleteDeployment = () => {
+ setOpenDeleteModal(true);
+ };
- // Pass the complete user list - SharePermission component will handle filtering
- setAllUsers(userList);
+ const handleViewLogsDeployment = (deployment) => {
+ handleViewLogs(deployment, setSelectedRow);
+ };
- // Update selected row with shared user info for the SharePermission component
- const updatedSelectedRow = {
- ...selectedRow,
- ...sharedUsersResponse.data,
- };
- setSelectedRow(updatedSelectedRow);
- } catch (err) {
- setAlertDetails(
- handleException(err, `Unable to fetch sharing information`),
- );
- setOpenShareModal(false);
- } finally {
- setIsLoadingShare(false);
- }
+ const handleManageKeysDeployment = (deployment) => {
+ setSelectedRow(deployment);
+ getApiKeys(
+ apiDeploymentsApiService,
+ deployment.id,
+ setApiKeys,
+ setOpenManageKeysModal,
+ );
};
- const onShare = (sharedUsers, api, shareWithEveryone) => {
- setIsLoadingShare(true);
- apiDeploymentsApiService
- .updateSharing(selectedRow.id, sharedUsers, shareWithEveryone)
- .then(() => {
- setAlertDetails({
- type: "success",
- content: "Sharing permissions updated successfully",
- });
- setOpenShareModal(false);
- getApiDeploymentList(); // Refresh the list
- })
- .catch((err) => {
- setAlertDetails(handleException(err));
- })
- .finally(() => {
- setIsLoadingShare(false);
- });
+ const handleSetupNotificationsDeployment = (deployment) => {
+ setSelectedRow(deployment);
+ setOpenNotificationModal(true);
};
- const actionItems = [
- // Configuration Section
- {
- key: "1",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() => openAddModal(true)}
- >
- <div>
- <EditOutlined />
- </div>
- <div>
- <Typography.Text>Edit</Typography.Text>
- </div>
- </Space>
- ),
- },
- {
- key: "2",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() =>
- getApiKeys(
- apiDeploymentsApiService,
- selectedRow?.id,
- setApiKeys,
- setOpenManageKeysModal,
- )
- }
- >
- <div>
- <KeyOutlined />
- </div>
- <div>
- <Typography.Text>Manage Keys</Typography.Text>
- </div>
- </Space>
- ),
- },
- {
- key: "3",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={handleShare}
- >
- <div>
- <ShareAltOutlined />
- </div>
- <div>
- <Typography.Text>Share</Typography.Text>
- </div>
- </Space>
- ),
- },
- {
- key: "4",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() => setOpenNotificationModal(true)}
- >
- <div>
- <NotificationOutlined />
- </div>
- <div>
- <Typography.Text>Setup Notifications</Typography.Text>
- </div>
- </Space>
- ),
- },
- {
- key: "divider-config",
- type: "divider",
- },
- // Operation Section
- {
- key: "5",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() => {
- setOpenLogsModal(true);
- fetchExecutionLogs(
- axiosPrivate,
- handleException,
- sessionDetails,
- selectedRow,
- setExecutionLogs,
- setExecutionLogsTotalCount,
- setAlertDetails,
- );
- }}
- >
- <div>
- <FileSearchOutlined />
- </div>
- <div>
- <Typography.Text>View Logs</Typography.Text>
- </div>
- </Space>
- ),
- },
- {
- key: "divider-operation",
- type: "divider",
- },
- // Developer related Section
- {
- key: "6",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() => setOpenCodeModal(true)}
- >
- <div>
- <CodeOutlined />
- </div>
- <div>
- <Typography.Text>Code Snippets</Typography.Text>
- </div>
- </Space>
- ),
- },
- {
- key: "7",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() =>
- downloadPostmanCollection(apiDeploymentsApiService, selectedRow?.id)
- }
- >
- <div>
- <CloudDownloadOutlined />
- </div>
- <div>
- <Typography.Text>Download Postman Collection</Typography.Text>
- </div>
- </Space>
- ),
- },
- {
- key: "divider-dev-related",
- type: "divider",
- },
- // Delete related section
- {
- key: "8",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() => setOpenDeleteModal(true)}
- >
- <div>
- <DeleteOutlined />
- </div>
- <div>
- <Typography.Text>Delete</Typography.Text>
- </div>
- </Space>
- ),
- },
- ];
+ const handleCodeSnippetsDeployment = (deployment) => {
+ setSelectedRow(deployment);
+ setOpenCodeModal(true);
+ };
+
+ const handleDownloadPostmanDeployment = (deployment) => {
+ downloadPostmanCollection(apiDeploymentsApiService, deployment.id);
+ };
+
+ // Card view configuration
+ const apiDeploymentCardConfig = useMemo(
+ () =>
+ createApiDeploymentCardConfig({
+ setSelectedRow,
+ updateStatus,
+ sessionDetails,
+ location,
+ onEdit: handleEditDeployment,
+ onShare: handleShare,
+ onDelete: handleDeleteDeployment,
+ onViewLogs: handleViewLogsDeployment,
+ onManageKeys: handleManageKeysDeployment,
+ onSetupNotifications: handleSetupNotificationsDeployment,
+ onCodeSnippets: handleCodeSnippetsDeployment,
+ onDownloadPostman: handleDownloadPostmanDeployment,
+ listContext: {
+ page: pagination.current,
+ pageSize: pagination.pageSize,
+ searchTerm,
+ },
+ }),
+ [
+ sessionDetails,
+ location,
+ pagination.current,
+ pagination.pageSize,
+ searchTerm,
+ ],
+ );
// Using the custom hook to manage modal state
const { showModal, handleModalClose } = usePromptStudioModal(
@@ -505,10 +292,21 @@ function ApiDeployment() {
)}
<Layout
type="api"
- columns={columns}
- tableData={tableData}
+ tableData={filteredData}
isTableLoading={isTableLoading}
openAddModal={openAddModal}
+ cardConfig={apiDeploymentCardConfig}
+ listMode={true}
+ scrollToId={scrollRestoreId}
+ enableSearch={true}
+ onSearch={handleSearch}
+ setSearchList={setFilteredData}
+ pagination={{
+ current: pagination.current,
+ pageSize: pagination.pageSize,
+ total: pagination.total,
+ onChange: handlePaginationChange,
+ }}
/>
{openAddApiModal && (
<CreateApiDeploymentModal
@@ -547,6 +345,7 @@ function ApiDeployment() {
logRecord={executionLogs}
totalLogs={executionLogsTotalCount}
fetchExecutionLogs={handleFetchLogs}
+ loading={isFetchingLogs}
/>
<NotificationModal
open={openNotificationModal}
diff --git a/frontend/src/components/deployments/api-deployment/ApiDeploymentCardConfig.jsx b/frontend/src/components/deployments/api-deployment/ApiDeploymentCardConfig.jsx
new file mode 100644
index 000000000..e5c9d6796
--- /dev/null
+++ b/frontend/src/components/deployments/api-deployment/ApiDeploymentCardConfig.jsx
@@ -0,0 +1,179 @@
+import {
+ CloudDownloadOutlined,
+ CodeOutlined,
+ FileSearchOutlined,
+ KeyOutlined,
+ NotificationOutlined,
+ SyncOutlined,
+} from "@ant-design/icons";
+import { Flex, Space, Switch, Tooltip, Typography } from "antd";
+import PropTypes from "prop-types";
+
+import { StatusPills } from "../../pipelines-or-deployments/pipelines/PipelineCardConfig";
+import {
+ ApiEndpointSection,
+ CardActionBox,
+ CardHeaderRow,
+ Last5RunsFieldRow,
+ LastRunFieldRow,
+ OwnerFieldRow,
+ WorkflowFieldRow,
+} from "../../widgets/card-grid-view/CardFieldComponents";
+
+/**
+ * Create API deployment card configuration for list mode - Row-based layout
+ * No expand/collapse - all content visible directly on card
+ * @return {Object} Card configuration object
+ */
+function createApiDeploymentCardConfig({
+ setSelectedRow,
+ updateStatus,
+ sessionDetails,
+ location,
+ onEdit,
+ onShare,
+ onDelete,
+ onViewLogs,
+ onManageKeys,
+ onSetupNotifications,
+ onCodeSnippets,
+ onDownloadPostman,
+ listContext,
+}) {
+ return {
+ header: {
+ title: (deployment) => deployment.display_name,
+ actions: [],
+ },
+ expandable: false,
+ listContent: (deployment) => {
+ const kebabMenuItems = {
+ items: [
+ {
+ key: "view-logs",
+ icon: <FileSearchOutlined />,
+ label: "View Logs",
+ onClick: () => onViewLogs?.(deployment),
+ },
+ { type: "divider" },
+ {
+ key: "manage-keys",
+ icon: <KeyOutlined />,
+ label: "Manage Keys",
+ onClick: () => onManageKeys?.(deployment),
+ },
+ {
+ key: "notifications",
+ icon: <NotificationOutlined />,
+ label: "Notifications",
+ onClick: () => onSetupNotifications?.(deployment),
+ },
+ { type: "divider" },
+ {
+ key: "code-snippets",
+ icon: <CodeOutlined />,
+ label: "Code Snippets",
+ onClick: () => onCodeSnippets?.(deployment),
+ },
+ {
+ key: "download-postman",
+ icon: <CloudDownloadOutlined />,
+ label: "Download Postman Collection",
+ onClick: () => onDownloadPostman?.(deployment),
+ },
+ ],
+ };
+
+ return (
+ <div className="card-list-content">
+ <CardHeaderRow
+ title={deployment.display_name}
+ description={deployment.description}
+ >
+ <Space size={16} className="card-list-actions">
+ <Tooltip
+ title={
+ deployment.is_active
+ ? "Disable API deployment"
+ : "Enable API deployment"
+ }
+ >
+ <Switch
+ size="small"
+ checked={deployment.is_active}
+ onChange={(checked, e) => {
+ e.stopPropagation();
+ updateStatus(deployment);
+ }}
+ />
+ </Tooltip>
+ <CardActionBox
+ item={deployment}
+ setSelectedItem={setSelectedRow}
+ onEdit={onEdit}
+ onShare={onShare}
+ onDelete={onDelete}
+ deleteTitle="Delete API deployment?"
+ kebabMenuItems={kebabMenuItems}
+ />
+ </Space>
+ </CardHeaderRow>
+
+ <div className="card-list-row-layout">
+ <WorkflowFieldRow
+ workflowId={deployment.workflow}
+ workflowName={deployment.workflow_name}
+ sessionDetails={sessionDetails}
+ location={location}
+ itemId={deployment.id}
+ listContext={listContext}
+ />
+ <OwnerFieldRow item={deployment} sessionDetails={sessionDetails} />
+ <LastRunFieldRow lastRunTime={deployment.last_run_time} />
+ <Last5RunsFieldRow
+ statuses={deployment.last_5_run_statuses}
+ executionType="API"
+ itemId={deployment.id}
+ StatusPillsComponent={StatusPills}
+ listContext={listContext}
+ />
+ </div>
+
+ <Flex align="center" gap={32} className="card-list-footer-row">
+ <Space size={10} className="card-list-footer-item">
+ <SyncOutlined />
+ <Typography.Text
+ type="secondary"
+ className="card-list-footer-label"
+ >
+ Total Runs
+ </Typography.Text>
+ <Typography.Text>{deployment.run_count || 0}</Typography.Text>
+ </Space>
+ </Flex>
+
+ <ApiEndpointSection apiEndpoint={deployment.api_endpoint} />
+ </div>
+ );
+ },
+ sections: [],
+ };
+}
+
+createApiDeploymentCardConfig.propTypes = {
+ setSelectedRow: PropTypes.func.isRequired,
+ updateStatus: PropTypes.func.isRequired,
+ sessionDetails: PropTypes.object,
+ location: PropTypes.object,
+ onEdit: PropTypes.func,
+ onShare: PropTypes.func,
+ onDelete: PropTypes.func,
+ onViewLogs: PropTypes.func,
+ onManageKeys: PropTypes.func,
+ onSetupNotifications: PropTypes.func,
+ onCodeSnippets: PropTypes.func,
+ onDownloadPostman: PropTypes.func,
+ listContext: PropTypes.object,
+};
+
+export { createApiDeploymentCardConfig };
diff --git a/frontend/src/components/deployments/api-deployment/api-deployments-service.js b/frontend/src/components/deployments/api-deployment/api-deployments-service.js
index 6fd9b752b..4990178b4 100644
--- a/frontend/src/components/deployments/api-deployment/api-deployments-service.js
+++ b/frontend/src/components/deployments/api-deployment/api-deployments-service.js
@@ -15,10 +15,18 @@ function apiDeploymentsService() {
};
return {
- getApiDeploymentsList: () => {
+ getApiDeploymentsList: (page = 1, pageSize = 10, search = "") => {
+ const params = {
+ page,
+ page_size: pageSize,
+ };
+ if (search) {
+ params.search = search;
+ }
options = {
url: `${path}/api/deployment/`,
method: "GET",
+ params,
};
return axiosPrivate(options);
},
diff --git a/frontend/src/components/deployments/body/Body.jsx b/frontend/src/components/deployments/body/Body.jsx
index b1bcdd768..02060d3be 100644
--- a/frontend/src/components/deployments/body/Body.jsx
+++ b/frontend/src/components/deployments/body/Body.jsx
@@ -1,12 +1,23 @@
-import { Table } from "antd";
import PropTypes from "prop-types";
import { deploymentsStaticContent } from "../../../helpers/GetStaticData";
import { IslandLayout } from "../../../layouts/island-layout/IslandLayout";
+import { CardGridView } from "../../widgets/card-grid-view";
import { EmptyState } from "../../widgets/empty-state/EmptyState";
import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader";
-function Body({ type, columns, tableData, isTableLoading, openAddModal }) {
+function Body({
+ type,
+ tableData,
+ isTableLoading,
+ openAddModal,
+ cardConfig,
+ onCardClick,
+ listMode = false,
+ forceExpandedId = null,
+ scrollToId = null,
+ pagination = null,
+}) {
if (isTableLoading) {
return <SpinnerLoader />;
}
@@ -21,22 +32,21 @@ function Body({ type, columns, tableData, isTableLoading, openAddModal }) {
</IslandLayout>
);
}
+
return (
<IslandLayout>
- <div className="body-div">
- <div className="table-div">
- <Table
- className="table"
- size="middle"
- columns={columns}
- dataSource={tableData}
- rowKey="id"
- loading={{
- indicator: <SpinnerLoader />,
- spinning: isTableLoading,
- }}
- />
- </div>
+ <div className="body-div pipeline-card-grid-container">
+ <CardGridView
+ data={tableData}
+ cardConfig={cardConfig}
+ loading={isTableLoading}
+ onCardClick={onCardClick}
+ rowKey="id"
+ listMode={listMode}
+ forceExpandedId={forceExpandedId}
+ scrollToId={scrollToId}
+ pagination={pagination}
+ />
</div>
</IslandLayout>
);
@@ -44,10 +54,20 @@ function Body({ type, columns, tableData, isTableLoading, openAddModal }) {
Body.propTypes = {
type: PropTypes.string.isRequired,
- columns: PropTypes.array.isRequired,
tableData: PropTypes.array.isRequired,
isTableLoading: PropTypes.bool.isRequired,
openAddModal: PropTypes.func.isRequired,
+ cardConfig: PropTypes.object.isRequired,
+ onCardClick: PropTypes.func,
+ listMode: PropTypes.bool,
+ forceExpandedId: PropTypes.string,
+ scrollToId: PropTypes.string,
+ pagination: PropTypes.shape({
+ current: PropTypes.number,
+ pageSize: PropTypes.number,
+ total: PropTypes.number,
+ onChange: PropTypes.func,
+ }),
};
export { Body };
diff --git a/frontend/src/components/deployments/create-api-deployment-modal/CreateApiDeploymentModal.jsx b/frontend/src/components/deployments/create-api-deployment-modal/CreateApiDeploymentModal.jsx
index 829793ab9..f6fc25ae5 100644
--- a/frontend/src/components/deployments/create-api-deployment-modal/CreateApiDeploymentModal.jsx
+++ b/frontend/src/components/deployments/create-api-deployment-modal/CreateApiDeploymentModal.jsx
@@ -82,33 +82,15 @@ const CreateApiDeploymentModal = ({
setOpen(false);
};
- const updateTableData = () => {
- apiDeploymentsApiService
- .getApiDeploymentsList()
- .then((res) => {
- setTableData(res?.data);
- })
- .catch((err) => {
- setAlertDetails({
- type: "error",
- content: "Error fetching API deployments",
- });
- });
- };
-
const createApiDeployment = () => {
- try {
- const wf = workflowEndpointList.find(
- (item) => item?.workflow === formDetails?.workflow,
- );
- setPostHogCustomEvent("intent_success_api_deployment", {
- info: "Clicked on 'Save' button",
- deployment_name: formDetails?.api_name,
- workflow_name: wf?.workflow_name,
- });
- } catch (err) {
- // If an error occurs while setting custom posthog event, ignore it and continue
- }
+ const wf = workflowEndpointList.find(
+ (item) => item?.workflow === formDetails?.workflow,
+ );
+ setPostHogCustomEvent("intent_success_api_deployment", {
+ info: "Clicked on 'Save' button",
+ deployment_name: formDetails?.api_name,
+ workflow_name: wf?.workflow_name,
+ });
setIsLoading(true);
const body = formDetails;
@@ -125,7 +107,8 @@ const CreateApiDeploymentModal = ({
onDeploymentCreated();
}
} else {
- updateTableData();
+ // Add new deployment to list
+ setTableData((prev) => [res?.data, ...prev]);
setSelectedRow(res?.data);
openCodeModal(true);
}
@@ -159,6 +142,18 @@ const CreateApiDeploymentModal = ({
});
};
+ const mergeUpdatedRow = (updatedData) => {
+ setTableData((prev) => {
+ const index = prev.findIndex((item) => item?.id === updatedData?.id);
+ if (index !== -1) {
+ const newData = [...prev];
+ newData[index] = { ...newData[index], ...updatedData };
+ return newData;
+ }
+ return prev;
+ });
+ };
+
const updateApiDeployment = () => {
setIsLoading(true);
const body = formDetails;
@@ -166,7 +161,7 @@ const CreateApiDeploymentModal = ({
apiDeploymentsApiService
.updateApiDeployment(body)
.then((res) => {
- updateTableData();
+ mergeUpdatedRow(res?.data);
setOpen(false);
clearFormDetails();
setAlertDetails({
diff --git a/frontend/src/components/deployments/header/Header.jsx b/frontend/src/components/deployments/header/Header.jsx
index 09c0d9203..fb58ecbd6 100644
--- a/frontend/src/components/deployments/header/Header.jsx
+++ b/frontend/src/components/deployments/header/Header.jsx
@@ -5,7 +5,7 @@ import usePostHogEvents from "../../../hooks/usePostHogEvents";
import { ToolNavBar } from "../../navigations/tool-nav-bar/ToolNavBar";
import { CustomButton } from "../../widgets/custom-button/CustomButton";
-function Header({ type, openAddModal }) {
+function Header({ type, openAddModal, enableSearch, onSearch, setSearchList }) {
const { posthogDeploymentEventText, setPostHogCustomEvent } =
usePostHogEvents();
@@ -16,7 +16,7 @@ function Header({ type, openAddModal }) {
setPostHogCustomEvent(posthogDeploymentEventText[type], {
info: `Clicked on '+ ${deploymentsStaticContent[type].addBtn}' button`,
});
- } catch (err) {
+ } catch (_err) {
// If an error occurs while setting custom posthog event, ignore it and continue
}
};
@@ -36,6 +36,9 @@ function Header({ type, openAddModal }) {
<ToolNavBar
title={deploymentsStaticContent[type].title}
CustomButtons={customButtons}
+ enableSearch={enableSearch}
+ onSearch={onSearch}
+ setSearchList={setSearchList}
/>
);
}
@@ -43,6 +46,9 @@ function Header({ type, openAddModal }) {
Header.propTypes = {
type: PropTypes.string.isRequired,
openAddModal: PropTypes.func.isRequired,
+ enableSearch: PropTypes.bool,
+ onSearch: PropTypes.func,
+ setSearchList: PropTypes.func,
};
export { Header };
diff --git a/frontend/src/components/deployments/layout/Layout.jsx b/frontend/src/components/deployments/layout/Layout.jsx
index dd25e000a..50b35ac31 100644
--- a/frontend/src/components/deployments/layout/Layout.jsx
+++ b/frontend/src/components/deployments/layout/Layout.jsx
@@ -4,19 +4,44 @@ import { Body } from "../body/Body";
import { Header } from "../header/Header";
import "./Layout.css";
-function Layout({ type, columns, tableData, isTableLoading, openAddModal }) {
+function Layout({
+ type,
+ tableData,
+ isTableLoading,
+ openAddModal,
+ cardConfig,
+ onCardClick,
+ listMode = false,
+ forceExpandedId = null,
+ scrollToId = null,
+ enableSearch = false,
+ onSearch,
+ setSearchList,
+ pagination = null,
+}) {
return (
<div className="deploy-layout">
<div>
- <Header type={type} openAddModal={openAddModal} />
+ <Header
+ type={type}
+ openAddModal={openAddModal}
+ enableSearch={enableSearch}
+ onSearch={onSearch}
+ setSearchList={setSearchList}
+ />
</div>
<div className="layout-body">
<Body
type={type}
- columns={columns}
tableData={tableData}
isTableLoading={isTableLoading}
openAddModal={openAddModal}
+ cardConfig={cardConfig}
+ onCardClick={onCardClick}
+ listMode={listMode}
+ forceExpandedId={forceExpandedId}
+ scrollToId={scrollToId}
+ pagination={pagination}
/>
</div>
</div>
@@ -25,10 +50,23 @@ function Layout({ type, columns, tableData, isTableLoading, openAddModal }) {
Layout.propTypes = {
type: PropTypes.string.isRequired,
- columns: PropTypes.array.isRequired,
tableData: PropTypes.array.isRequired,
isTableLoading: PropTypes.bool.isRequired,
openAddModal: PropTypes.func.isRequired,
+ cardConfig: PropTypes.object.isRequired,
+ onCardClick: PropTypes.func,
+ listMode: PropTypes.bool,
+ forceExpandedId: PropTypes.string,
+ scrollToId: PropTypes.string,
+ enableSearch: PropTypes.bool,
+ onSearch: PropTypes.func,
+ setSearchList: PropTypes.func,
+ pagination: PropTypes.shape({
+ current: PropTypes.number,
+ pageSize: PropTypes.number,
+ total: PropTypes.number,
+ onChange: PropTypes.func,
+ }),
};
export { Layout };
diff --git a/frontend/src/components/logging/detailed-logs/DetailedLogs.jsx b/frontend/src/components/logging/detailed-logs/DetailedLogs.jsx
index 407a19b00..3522d0cd4 100644
--- a/frontend/src/components/logging/detailed-logs/DetailedLogs.jsx
+++ b/frontend/src/components/logging/detailed-logs/DetailedLogs.jsx
@@ -1,5 +1,4 @@
import {
- ArrowLeftOutlined,
CalendarOutlined,
ClockCircleOutlined,
CloseCircleFilled,
@@ -24,12 +23,11 @@ import {
} from "antd";
import PropTypes from "prop-types";
import { useEffect, useRef, useState } from "react";
-import { useNavigate, useParams } from "react-router-dom";
+import { useParams } from "react-router-dom";
import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler";
import { useAlertStore } from "../../../store/alert-store";
-import { useSessionStore } from "../../../store/session-store";
import "./DetailedLogs.css";
import {
formattedDateTime,
@@ -91,10 +89,8 @@ ActionColumnHeader.propTypes = {
const DetailedLogs = () => {
const { id, type } = useParams(); // Get the ID from the URL
const axiosPrivate = useAxiosPrivate();
- const { sessionDetails } = useSessionStore();
const { setAlertDetails } = useAlertStore();
const handleException = useExceptionHandler();
- const navigate = useNavigate();
const { getUrl } = useRequestUrl();
const copyToClipboard = useCopyToClipboard();
@@ -458,13 +454,7 @@ const DetailedLogs = () => {
<div className="detailed-logs-container">
<div className="detailed-logs-header">
<Typography.Title className="logs-title" level={4}>
- <Button
- type="text"
- shape="circle"
- icon={<ArrowLeftOutlined />}
- onClick={() => navigate(`/${sessionDetails?.orgName}/logs`)}
- />
- {type} Execution ID {id}
+ {type} Execution {id}
<Button
className="copy-btn-outlined"
icon={<CopyOutlined />}
diff --git a/frontend/src/components/logging/execution-logs/ExecutionLogs.jsx b/frontend/src/components/logging/execution-logs/ExecutionLogs.jsx
index 0b409b0cb..10aa141c0 100644
--- a/frontend/src/components/logging/execution-logs/ExecutionLogs.jsx
+++ b/frontend/src/components/logging/execution-logs/ExecutionLogs.jsx
@@ -1,6 +1,6 @@
import { DatePicker, Tabs } from "antd";
import { useEffect, useRef, useState } from "react";
-import { useNavigate, useParams } from "react-router-dom";
+import { useLocation, useNavigate, useParams } from "react-router-dom";
import {
ApiDeployments,
ETLIcon,
@@ -26,6 +26,7 @@ function ExecutionLogs() {
const { RangePicker } = DatePicker;
const [activeTab, setActiveTab] = useState("ETL");
const { id } = useParams();
+ const location = useLocation();
const axiosPrivate = useAxiosPrivate();
const { sessionDetails } = useSessionStore();
const { setAlertDetails } = useAlertStore();
@@ -48,6 +49,20 @@ function ExecutionLogs() {
const autoRefreshIntervalRef = useRef(null);
const currentPath = location.pathname !== `/${sessionDetails?.orgName}/logs`;
+ // Compute back route - use location state if available, otherwise default to logs listing
+ const backRoute = id
+ ? location.state?.from || `/${sessionDetails?.orgName}/logs`
+ : null;
+
+ // State to pass back for scroll restoration
+ const backRouteState =
+ id && location.state?.scrollToCardId
+ ? {
+ scrollToCardId: location.state.scrollToCardId,
+ cardExpanded: location.state.cardExpanded,
+ }
+ : null;
+
const items = [
{
key: "ETL",
@@ -206,6 +221,8 @@ function ExecutionLogs() {
title={"Execution Logs"}
CustomButtons={customButtons}
enableSearch={false}
+ previousRoute={backRoute}
+ previousRouteState={backRouteState}
/>
<div className="file-log-layout">
{id ? (
diff --git a/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx b/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx
index bb3a95c32..6e4804909 100644
--- a/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx
+++ b/frontend/src/components/navigations/tool-nav-bar/ToolNavBar.jsx
@@ -12,6 +12,7 @@ function ToolNavBar({
CustomButtons,
setSearchList,
previousRoute,
+ previousRouteState,
segmentFilter,
segmentOptions,
onSearch,
@@ -30,7 +31,9 @@ function ToolNavBar({
type="text"
shape="circle"
icon={<ArrowLeftOutlined />}
- onClick={() => navigate(previousRoute)}
+ onClick={() =>
+ navigate(previousRoute, { state: previousRouteState })
+ }
/>
)}
{title && (
@@ -75,6 +78,7 @@ ToolNavBar.propTypes = {
CustomButtons: PropTypes.func,
setSearchList: PropTypes.func,
previousRoute: PropTypes.string,
+ previousRouteState: PropTypes.object,
segmentOptions: PropTypes.array,
segmentFilter: PropTypes.func,
onSearch: PropTypes.func,
diff --git a/frontend/src/components/pipelines-or-deployments/etl-task-deploy/EtlTaskDeploy.jsx b/frontend/src/components/pipelines-or-deployments/etl-task-deploy/EtlTaskDeploy.jsx
index 72c90e400..b3803ee79 100644
--- a/frontend/src/components/pipelines-or-deployments/etl-task-deploy/EtlTaskDeploy.jsx
+++ b/frontend/src/components/pipelines-or-deployments/etl-task-deploy/EtlTaskDeploy.jsx
@@ -205,10 +205,6 @@ const EtlTaskDeploy = ({
updatePipelineTable(res?.data);
setOpen(false);
clearFormDetails();
- setAlertDetails({
- type: "success",
- content: "Pipeline Updated Successfully",
- });
})
.catch((err) => {
setAlertDetails(handleException(err, "", setBackendErrors));
@@ -219,18 +215,12 @@ const EtlTaskDeploy = ({
};
const createPipeline = () => {
- try {
- const wf = workflowList.find(
- (item) => item?.id === formDetails?.workflow,
- );
- setPostHogCustomEvent(posthogDeploymentEventText[`${type}_success`], {
- info: "Clicked on 'Save and Deploy' button",
- deployment_name: formDetails?.pipeline_name,
- workflow_name: wf?.workflow_name,
- });
- } catch (err) {
- // If an error occurs while setting custom posthog event, ignore it and continue
- }
+ const wf = workflowList.find((item) => item?.id === formDetails?.workflow);
+ setPostHogCustomEvent(posthogDeploymentEventText[`${type}_success`], {
+ info: "Clicked on 'Save and Deploy' button",
+ deployment_name: formDetails?.pipeline_name,
+ workflow_name: wf?.workflow_name,
+ });
const body = formDetails;
body["pipeline_type"] = type.toUpperCase();
diff --git a/frontend/src/components/pipelines-or-deployments/log-modal/LogsModal.jsx b/frontend/src/components/pipelines-or-deployments/log-modal/LogsModal.jsx
index 6d2129cc8..09dd7ac04 100644
--- a/frontend/src/components/pipelines-or-deployments/log-modal/LogsModal.jsx
+++ b/frontend/src/components/pipelines-or-deployments/log-modal/LogsModal.jsx
@@ -14,6 +14,7 @@ const LogsModal = ({
logRecord,
totalLogs,
fetchExecutionLogs,
+ loading = false,
}) => {
const [selectedLogId, setSelectedLogId] = useState(null);
const [logDescModalOpen, setLogDescModalOpen] = useState(false);
@@ -128,6 +129,7 @@ const LogsModal = ({
dataSource={logRecord}
rowKey="id"
align="left"
+ loading={loading}
pagination={{
total: totalLogs,
onChange: (page, pageSize) => {
@@ -170,6 +172,7 @@ LogsModal.propTypes = {
logRecord: PropTypes.array.isRequired,
totalLogs: PropTypes.number.isRequired,
fetchExecutionLogs: PropTypes.func.isRequired,
+ loading: PropTypes.bool,
};
export { LogsModal };
diff --git a/frontend/src/components/pipelines-or-deployments/log-modal/fetchExecutionLogs.js b/frontend/src/components/pipelines-or-deployments/log-modal/fetchExecutionLogs.js
index 11f0fd0c5..6faf2af4e 100644
--- a/frontend/src/components/pipelines-or-deployments/log-modal/fetchExecutionLogs.js
+++ b/frontend/src/components/pipelines-or-deployments/log-modal/fetchExecutionLogs.js
@@ -8,7 +8,10 @@ const fetchExecutionLogs = (
setAlertDetails,
page = 1,
pageSize = 10,
+ setIsLoading = null,
) => {
+ setIsLoading?.(true);
+
const requestOptions = {
method: "GET",
url: `/api/v1/unstract/${sessionDetails?.orgId}/pipeline/${selectedRow.id}/executions/`,
@@ -34,6 +37,9 @@ const fetchExecutionLogs = (
})
.catch((err) => {
setAlertDetails(handleException(err));
+ })
+ .finally(() => {
+ setIsLoading?.(false);
});
};
diff --git a/frontend/src/components/pipelines-or-deployments/pipelines/PipelineCardConfig.jsx b/frontend/src/components/pipelines-or-deployments/pipelines/PipelineCardConfig.jsx
new file mode 100644
index 000000000..6680c1df5
--- /dev/null
+++ b/frontend/src/components/pipelines-or-deployments/pipelines/PipelineCardConfig.jsx
@@ -0,0 +1,434 @@
+import {
+ AppstoreOutlined,
+ CalendarOutlined,
+ CheckCircleFilled,
+ ClearOutlined,
+ CloseCircleFilled,
+ CloudDownloadOutlined,
+ FileSearchOutlined,
+ HistoryOutlined,
+ KeyOutlined,
+ NotificationOutlined,
+ ScheduleOutlined,
+ SyncOutlined,
+} from "@ant-design/icons";
+import { Avatar, Flex, Space, Switch, Tag, Tooltip, Typography } from "antd";
+import cronstrue from "cronstrue";
+import PropTypes from "prop-types";
+import { useLocation, useNavigate } from "react-router-dom";
+import { formattedDateTime } from "../../../helpers/GetStaticData";
+import { useSessionStore } from "../../../store/session-store";
+import {
+ ApiEndpointSection,
+ CardActionBox,
+ Last5RunsFieldRow,
+ LastRunFieldRow,
+ OwnerFieldRow,
+ WorkflowFieldRow,
+} from "../../widgets/card-grid-view/CardFieldComponents";
+
+/**
+ * Status badge component for displaying execution status as text badges
+ * @return {JSX.Element|null} Rendered status pills or null
+ */
+function StatusPills({
+ statuses = [],
+ executionType,
+ pipelineId,
+ listContext = {},
+}) {
+ const navigate = useNavigate();
+ const location = useLocation();
+ const { sessionDetails } = useSessionStore();
+
+ if (!statuses || statuses.length === 0) {
+ return null;
+ }
+
+ const handleStatusClick = (e, run) => {
+ e.stopPropagation();
+ if (run.execution_id && executionType && sessionDetails?.orgName) {
+ navigate(
+ `/${sessionDetails.orgName}/logs/${executionType}/${run.execution_id}`,
+ {
+ state: {
+ from: location.pathname,
+ scrollToCardId: pipelineId,
+ // Include list context for full restoration on back navigation
+ page: listContext.page,
+ pageSize: listContext.pageSize,
+ searchTerm: listContext.searchTerm,
+ },
+ },
+ );
+ }
+ };
+
+ const getStatusConfig = (status) => {
+ const statusLower = (status || "").toLowerCase();
+ switch (statusLower) {
+ case "completed":
+ case "success":
+ return { label: "SUCCESS", color: "success" };
+ case "error":
+ case "failed":
+ case "failure":
+ return { label: "ERROR", color: "error" };
+ case "partial_success":
+ case "partial success":
+ return { label: "PARTIAL", color: "warning" };
+ case "executing":
+ case "processing":
+ case "running":
+ return { label: "EXECUTING", color: "processing" };
+ case "pending":
+ return { label: "PENDING", color: "default" };
+ case "stopped":
+ return { label: "STOPPED", color: "default" };
+ default:
+ return {
+ label: status?.toUpperCase() || "UNKNOWN",
+ color: "default",
+ };
+ }
+ };
+
+ return (
+ <Space className="status-badges-container" size={6} wrap>
+ {statuses.map((run, index) => {
+ const config = getStatusConfig(run.status);
+ const isClickable = run.execution_id && executionType;
+ const hasFileCounts = run.successful_files > 0 || run.failed_files > 0;
+ // Use execution_id for unique key, fallback to timestamp, then index
+ const key =
+ run.execution_id || run.timestamp || `${config.label}-${index}`;
+ const tooltipContent = (
+ <Space
+ direction="vertical"
+ size={4}
+ className="status-tooltip-content"
+ >
+ {hasFileCounts && (
+ <Space size={12} className="status-tooltip-counts">
+ <Typography.Text className="status-tooltip-count success">
+ <CheckCircleFilled /> {run.successful_files}
+ </Typography.Text>
+ <Typography.Text className="status-tooltip-count error">
+ <CloseCircleFilled /> {run.failed_files}
+ </Typography.Text>
+ </Space>
+ )}
+ {run.timestamp && (
+ <Typography.Text className="status-tooltip-timestamp">
+ {formattedDateTime(run.timestamp)}
+ </Typography.Text>
+ )}
+ {isClickable && (
+ <Typography.Text className="status-tooltip-hint">
+ Click to view details
+ </Typography.Text>
+ )}
+ </Space>
+ );
+
+ if (isClickable) {
+ return (
+ <Tooltip key={key} title={tooltipContent}>
+ <Tag
+ color={config.color}
+ className="status-badge status-badge-clickable"
+ onClick={(e) => handleStatusClick(e, run)}
+ tabIndex={0}
+ role="button"
+ onKeyDown={(e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
+ handleStatusClick(e, run);
+ }
+ }}
+ >
+ {config.label}
+ </Tag>
+ </Tooltip>
+ );
+ }
+
+ return (
+ <Tooltip key={key} title={tooltipContent}>
+ <Tag color={config.color} className="status-badge">
+ {config.label}
+ </Tag>
+ </Tooltip>
+ );
+ })}
+ </Space>
+ );
+}
+
+StatusPills.propTypes = {
+ statuses: PropTypes.arrayOf(
+ PropTypes.shape({
+ status: PropTypes.string,
+ timestamp: PropTypes.string,
+ execution_id: PropTypes.string,
+ }),
+ ),
+ executionType: PropTypes.string,
+ pipelineId: PropTypes.string,
+ listContext: PropTypes.object,
+};
+
+/**
+ * Source/Destination connector field row
+ * @return {JSX.Element} Rendered connector field row
+ */
+function ConnectorFieldRow({ label, icon, instanceName, connectorName }) {
+ return (
+ <Flex align="center" className="card-list-field-row">
+ <Typography.Text type="secondary" className="card-list-field-label">
+ {label}
+ </Typography.Text>
+ <Space size={10} className="card-list-field-value">
+ <Avatar
+ src={icon}
+ size={32}
+ shape="square"
+ icon={<AppstoreOutlined />}
+ />
+ <Flex vertical gap={2} className="card-list-field-text">
+ <Typography.Text className="card-list-field-instance-name">
+ {instanceName || connectorName}
+ </Typography.Text>
+ {instanceName && (
+ <Typography.Text
+ type="secondary"
+ className="card-list-field-subtext"
+ >
+ {connectorName}
+ </Typography.Text>
+ )}
+ </Flex>
+ </Space>
+ </Flex>
+ );
+}
+
+ConnectorFieldRow.propTypes = {
+ label: PropTypes.string.isRequired,
+ icon: PropTypes.string,
+ instanceName: PropTypes.string,
+ connectorName: PropTypes.string,
+};
+
+/**
+ * Create pipeline card configuration for list mode - Row-based layout
+ * No expand/collapse - all content visible directly on card
+ * @return {Object} Card configuration object
+ */
+function createPipelineCardConfig({
+ setSelectedPorD,
+ handleEnablePipeline,
+ sessionDetails,
+ location,
+ onEdit,
+ onShare,
+ onDelete,
+ onViewLogs,
+ onViewFileHistory,
+ onClearFileHistory,
+ onSyncNow,
+ onManageKeys,
+ onSetupNotifications,
+ onDownloadPostman,
+ isClearingFileHistory,
+ pipelineType,
+ listContext,
+}) {
+ return {
+ header: {
+ title: (pipeline) => pipeline.pipeline_name,
+ actions: [],
+ },
+ expandable: false,
+ listContent: (pipeline) => {
+ // Schedule display
+ let scheduleDisplay = "Not scheduled";
+ if (pipeline.cron_string) {
+ try {
+ scheduleDisplay = cronstrue.toString(pipeline.cron_string);
+ } catch {
+ scheduleDisplay = pipeline.cron_string;
+ }
+ }
+
+ const kebabMenuItems = {
+ items: [
+ {
+ key: "view-logs",
+ icon: <FileSearchOutlined />,
+ label: "View Logs",
+ onClick: () => onViewLogs?.(pipeline),
+ },
+ {
+ key: "file-history",
+ icon: <HistoryOutlined />,
+ label: "View File History",
+ onClick: () => onViewFileHistory?.(pipeline),
+ },
+ {
+ key: "clear-history",
+ icon: <ClearOutlined />,
+ label: isClearingFileHistory ? "Clearing..." : "Clear File History",
+ disabled: isClearingFileHistory,
+ onClick: () => onClearFileHistory?.(pipeline),
+ },
+ { type: "divider" },
+ {
+ key: "sync-now",
+ icon: <SyncOutlined />,
+ label: "Sync Now",
+ onClick: () => onSyncNow?.(pipeline),
+ },
+ { type: "divider" },
+ {
+ key: "manage-keys",
+ icon: <KeyOutlined />,
+ label: "Manage Keys",
+ onClick: () => onManageKeys?.(pipeline),
+ },
+ {
+ key: "notifications",
+ icon: <NotificationOutlined />,
+ label: "Notifications",
+ onClick: () => onSetupNotifications?.(pipeline),
+ },
+ { type: "divider" },
+ {
+ key: "download-postman",
+ icon: <CloudDownloadOutlined />,
+ label: "Download Postman Collection",
+ onClick: () => onDownloadPostman?.(pipeline),
+ },
+ ],
+ };
+
+ return (
+ <div className="card-list-content">
+ {/* Header Row: Name + Actions */}
+ <div className="card-list-header-row">
+ <Tooltip title={pipeline.pipeline_name}>
+ <Typography.Text className="card-list-name" strong>
+ {pipeline.pipeline_name}
+ </Typography.Text>
+ </Tooltip>
+
+ <Space size={16} className="card-list-actions">
+ <Tooltip
+ title={pipeline.active ? "Disable pipeline" : "Enable pipeline"}
+ >
+ <Switch
+ size="small"
+ checked={pipeline.active}
+ onChange={(checked, e) => {
+ e.stopPropagation();
+ handleEnablePipeline(checked, pipeline.id);
+ }}
+ />
+ </Tooltip>
+ <CardActionBox
+ item={pipeline}
+ setSelectedItem={setSelectedPorD}
+ onEdit={onEdit}
+ onShare={onShare}
+ onDelete={onDelete}
+ deleteTitle="Delete pipeline?"
+ kebabMenuItems={kebabMenuItems}
+ />
+ </Space>
+ </div>
+
+ {/* Row-based content */}
+ <div className="card-list-row-layout">
+ <ConnectorFieldRow
+ label="Source"
+ icon={pipeline.source_icon}
+ instanceName={pipeline.source_instance_name}
+ connectorName={pipeline.source_name}
+ />
+ <ConnectorFieldRow
+ label="Destination"
+ icon={pipeline.destination_icon}
+ instanceName={pipeline.destination_instance_name}
+ connectorName={pipeline.destination_name}
+ />
+ <WorkflowFieldRow
+ workflowId={pipeline.workflow_id}
+ workflowName={pipeline.workflow_name}
+ sessionDetails={sessionDetails}
+ location={location}
+ itemId={pipeline.id}
+ listContext={listContext}
+ />
+ <OwnerFieldRow item={pipeline} sessionDetails={sessionDetails} />
+ <LastRunFieldRow lastRunTime={pipeline.last_run_time} />
+
+ {/* NEXT RUN AT row (only if scheduled) */}
+ {pipeline.next_run_time && (
+ <Flex align="center" className="card-list-field-row">
+ <Typography.Text
+ type="secondary"
+ className="card-list-field-label"
+ >
+ Next Run At
+ </Typography.Text>
+ <Space size={10} className="card-list-field-value">
+ <ScheduleOutlined />
+ <Typography.Text>
+ {formattedDateTime(pipeline.next_run_time)}
+ </Typography.Text>
+ </Space>
+ </Flex>
+ )}
+
+ <Last5RunsFieldRow
+ statuses={pipeline.last_5_run_statuses}
+ executionType={pipelineType?.toUpperCase()}
+ itemId={pipeline.id}
+ StatusPillsComponent={StatusPills}
+ listContext={listContext}
+ />
+ </div>
+
+ {/* Footer: Schedule | Total Runs */}
+ <Flex align="center" gap={32} className="card-list-footer-row">
+ <Space size={10} className="card-list-footer-item">
+ <CalendarOutlined />
+ <Typography.Text
+ type="secondary"
+ className="card-list-footer-label"
+ >
+ Schedule
+ </Typography.Text>
+ <Typography.Text>{scheduleDisplay}</Typography.Text>
+ </Space>
+ <Space size={10} className="card-list-footer-item">
+ <SyncOutlined />
+ <Typography.Text
+ type="secondary"
+ className="card-list-footer-label"
+ >
+ Total Runs
+ </Typography.Text>
+ <Typography.Text>{pipeline.run_count || 0}</Typography.Text>
+ </Space>
+ </Flex>
+
+ <ApiEndpointSection apiEndpoint={pipeline.api_endpoint} />
+ </div>
+ );
+ },
+ sections: [],
+ };
+}
+
+export { createPipelineCardConfig, StatusPills };
diff --git a/frontend/src/components/pipelines-or-deployments/pipelines/Pipelines.jsx b/frontend/src/components/pipelines-or-deployments/pipelines/Pipelines.jsx
index dc4218383..67acbf4e7 100644
--- a/frontend/src/components/pipelines-or-deployments/pipelines/Pipelines.jsx
+++ b/frontend/src/components/pipelines-or-deployments/pipelines/Pipelines.jsx
@@ -1,42 +1,15 @@
-import {
- CloudDownloadOutlined,
- CopyOutlined,
- DeleteOutlined,
- EditOutlined,
- EllipsisOutlined,
- FileSearchOutlined,
- HighlightOutlined,
- HistoryOutlined,
- KeyOutlined,
- LoadingOutlined,
- NotificationOutlined,
- ReloadOutlined,
- ShareAltOutlined,
- SyncOutlined,
-} from "@ant-design/icons";
-import {
- Button,
- Dropdown,
- Image,
- Space,
- Switch,
- Tooltip,
- Typography,
-} from "antd";
-import cronstrue from "cronstrue";
import PropTypes from "prop-types";
-import { useEffect, useState } from "react";
+import { useEffect, useMemo, useRef, useState } from "react";
+import { useLocation } from "react-router-dom";
import {
deploymentApiTypes,
deploymentsStaticContent,
- displayURL,
} from "../../../helpers/GetStaticData";
import { useAxiosPrivate } from "../../../hooks/useAxiosPrivate.js";
import { useAlertStore } from "../../../store/alert-store.js";
import { useSessionStore } from "../../../store/session-store.js";
import { Layout } from "../../deployments/layout/Layout.jsx";
-import { SpinnerLoader } from "../../widgets/spinner-loader/SpinnerLoader.jsx";
import { DeleteModal } from "../delete-modal/DeleteModal.jsx";
import { EtlTaskDeploy } from "../etl-task-deploy/EtlTaskDeploy.jsx";
import FileHistoryModal from "../file-history-modal/FileHistoryModal.jsx";
@@ -44,19 +17,23 @@ import { LogsModal } from "../log-modal/LogsModal.jsx";
import "./Pipelines.css";
import useClearFileHistory from "../../../hooks/useClearFileHistory";
import { useExceptionHandler } from "../../../hooks/useExceptionHandler.jsx";
+import { useExecutionLogs } from "../../../hooks/useExecutionLogs";
+import { usePaginatedList } from "../../../hooks/usePaginatedList";
import usePipelineHelper from "../../../hooks/usePipelineHelper.js";
import {
useInitialFetchCount,
usePromptStudioModal,
} from "../../../hooks/usePromptStudioFetchCount";
+import { useScrollRestoration } from "../../../hooks/useScrollRestoration";
+import { useShareModal } from "../../../hooks/useShareModal";
import { usePromptStudioStore } from "../../../store/prompt-studio-store";
import { usePromptStudioService } from "../../api/prompt-studio-service";
import { PromptStudioModal } from "../../common/PromptStudioModal";
import { ManageKeys } from "../../deployments/manage-keys/ManageKeys.jsx";
import { SharePermission } from "../../widgets/share-permission/SharePermission";
-import * as fetchExecutionLogsModule from "../log-modal/fetchExecutionLogs.js";
import { NotificationModal } from "../notification-modal/NotificationModal.jsx";
import { pipelineService } from "../pipeline-service.js";
+import { createPipelineCardConfig } from "./PipelineCardConfig.jsx";
function Pipelines({ type }) {
const [tableData, setTableData] = useState([]);
@@ -65,49 +42,80 @@ function Pipelines({ type }) {
const [selectedPorD, setSelectedPorD] = useState({});
const [tableLoading, setTableLoading] = useState(true);
const { sessionDetails } = useSessionStore();
+ const location = useLocation();
const { setAlertDetails } = useAlertStore();
const axiosPrivate = useAxiosPrivate();
const handleException = useExceptionHandler();
const { clearFileHistory, isClearing: isClearingFileHistory } =
useClearFileHistory();
const [isEdit, setIsEdit] = useState(false);
- const [openLogsModal, setOpenLogsModal] = useState(false);
- const [executionLogs, setExecutionLogs] = useState([]);
- const [executionLogsTotalCount, setExecutionLogsTotalCount] = useState(0);
const [openFileHistoryModal, setOpenFileHistoryModal] = useState(false);
- const { fetchExecutionLogs } = fetchExecutionLogsModule;
const [openManageKeysModal, setOpenManageKeysModal] = useState(false);
const [apiKeys, setApiKeys] = useState([]);
const pipelineApiService = pipelineService();
- const { getApiKeys, downloadPostmanCollection, copyUrl } =
- usePipelineHelper();
+ const { getApiKeys, downloadPostmanCollection } = usePipelineHelper();
const [openNotificationModal, setOpenNotificationModal] = useState(false);
const { count, isLoading, fetchCount } = usePromptStudioStore();
const { getPromptStudioCount } = usePromptStudioService();
- // Sharing state
- const [openShareModal, setOpenShareModal] = useState(false);
- const [allUsers, setAllUsers] = useState([]);
- const [isLoadingShare, setIsLoadingShare] = useState(false);
+
+ // Ref to forward the fetch function to hooks (avoids declaration ordering)
+ const fetchListRef = useRef(null);
+
+ const {
+ pagination,
+ setPagination,
+ searchTerm,
+ setSearchTerm,
+ handlePaginationChange,
+ handleSearch,
+ } = usePaginatedList({
+ fetchData: (...args) => fetchListRef.current?.(...args),
+ });
+
+ const { scrollRestoreId, activateScrollRestore, clearPendingScroll } =
+ useScrollRestoration({
+ location,
+ setSearchTerm,
+ setPagination,
+ fetchData: (...args) => fetchListRef.current?.(...args),
+ });
+
+ const {
+ openLogsModal,
+ setOpenLogsModal,
+ executionLogs,
+ executionLogsTotalCount,
+ isFetchingLogs,
+ handleFetchLogs,
+ handleViewLogs,
+ } = useExecutionLogs({
+ axiosPrivate,
+ handleException,
+ sessionDetails,
+ setAlertDetails,
+ });
+
+ const {
+ openShareModal,
+ setOpenShareModal,
+ allUsers,
+ isLoadingShare,
+ handleShare,
+ onShare,
+ } = useShareModal({
+ apiService: pipelineApiService,
+ setSelectedItem: setSelectedPorD,
+ setAlertDetails,
+ handleException,
+ refreshList: () =>
+ getPipelineList(pagination.current, pagination.pageSize, searchTerm),
+ });
const initialFetchComplete = useInitialFetchCount(
fetchCount,
getPromptStudioCount,
);
- const handleFetchLogs = (page, pageSize) => {
- fetchExecutionLogs(
- axiosPrivate,
- handleException,
- sessionDetails,
- selectedPorD,
- setExecutionLogs,
- setExecutionLogsTotalCount,
- setAlertDetails,
- page,
- pageSize,
- );
- };
-
useEffect(() => {
getPipelineList();
}, [type]);
@@ -117,27 +125,47 @@ function Pipelines({ type }) {
setOpenEtlOrTaskModal(true);
};
- const getPipelineList = () => {
+ const getPipelineList = (page = 1, pageSize = 10, search = "") => {
setTableLoading(true);
+ const params = {
+ type: type.toUpperCase(),
+ page,
+ page_size: pageSize,
+ };
+ if (search) {
+ params.search = search;
+ }
const requestOptions = {
method: "GET",
- url: `/api/v1/unstract/${
- sessionDetails?.orgId
- }/pipeline/?type=${type.toUpperCase()}`,
+ url: `/api/v1/unstract/${sessionDetails?.orgId}/pipeline/`,
+ params,
};
axiosPrivate(requestOptions)
.then((res) => {
- setTableData(res?.data);
+ const data = res?.data;
+ // Handle paginated response
+ setTableData(data.results || data);
+ setPagination((prev) => ({
+ ...prev,
+ current: page,
+ pageSize,
+ total: data.count ?? data.results?.length ?? data.length ?? 0,
+ }));
+
+ activateScrollRestore();
})
.catch((err) => {
setAlertDetails(handleException(err));
+ clearPendingScroll();
})
.finally(() => {
setTableLoading(false);
});
};
+ fetchListRef.current = getPipelineList;
+
const handleSync = (params) => {
const body = { ...params, pipeline_type: type.toUpperCase() };
const pipelineId = params?.pipeline_id;
@@ -162,39 +190,13 @@ function Pipelines({ type }) {
});
};
- const handleStatusRefresh = (pipelineId) => {
- const fieldsToUpdate = {
- last_run_status: "processing",
- };
- handleLoaderInTableData(fieldsToUpdate, pipelineId);
-
- getPipelineData(pipelineId)
- .then((res) => {
- const data = res?.data;
- fieldsToUpdate["last_run_status"] = data?.last_run_status;
- fieldsToUpdate["last_run_time"] = data?.last_run_time;
- })
- .catch((err) => {
- setAlertDetails(
- handleException(err, `Failed to update pipeline status.`),
- );
- const date = new Date();
- fieldsToUpdate["last_run_status"] = "FAILURE";
- fieldsToUpdate["last_run_time"] = date.toISOString();
- })
- .finally(() => {
- handleLoaderInTableData(fieldsToUpdate, pipelineId);
- });
- };
-
const handleLoaderInTableData = (updatedFields, pipelineId) => {
- const filteredData = tableData.map((item) => {
- if (item.id === pipelineId) {
- return { ...item, ...updatedFields };
- }
- return item;
- });
- setTableData(filteredData);
+ // Use functional update to avoid stale closure issues
+ setTableData((prevData) =>
+ prevData.map((item) =>
+ item.id === pipelineId ? { ...item, ...updatedFields } : item,
+ ),
+ );
};
const handleSyncApiReq = async (body) => {
@@ -216,6 +218,10 @@ function Pipelines({ type }) {
};
const handleEnablePipeline = (value, id) => {
+ // Optimistically update the UI immediately
+ const fieldsToUpdate = { active: value };
+ handleLoaderInTableData(fieldsToUpdate, id);
+
const body = { active: value, pipeline_id: id };
const requestOptions = {
method: "PATCH",
@@ -226,14 +232,12 @@ function Pipelines({ type }) {
},
data: body,
};
- axiosPrivate(requestOptions)
- .then(() => {
- getPipelineList();
- })
- .catch((err) => {
- setAlertDetails(handleException(err));
- })
- .finally(() => {});
+
+ axiosPrivate(requestOptions).catch((err) => {
+ // Revert optimistic update on failure
+ handleLoaderInTableData({ active: !value }, id);
+ setAlertDetails(handleException(err));
+ });
};
const deletePipeline = () => {
@@ -247,7 +251,8 @@ function Pipelines({ type }) {
axiosPrivate(requestOptions)
.then(() => {
setOpenDeleteModal(false);
- getPipelineList();
+ // Refresh with current pagination
+ getPipelineList(pagination.current, pagination.pageSize, searchTerm);
setAlertDetails({
type: "success",
content: "Pipeline Deleted Successfully",
@@ -258,453 +263,109 @@ function Pipelines({ type }) {
});
};
- const getPipelineData = (pipelineId) => {
- const requestOptions = {
- method: "GET",
- url: `/api/v1/unstract/${sessionDetails?.orgId}/pipeline/${pipelineId}/`,
- headers: {
- "X-CSRFToken": sessionDetails?.csrfToken,
- },
- };
- return axiosPrivate(requestOptions)
- .then((res) => res)
- .catch((err) => {
- throw err;
- });
- };
-
- const clearFileMarkers = async () => {
- const workflowId = selectedPorD?.workflow_id;
- const success = await clearFileHistory(workflowId);
+ const clearFileMarkers = async (workflowId) => {
+ const id = workflowId || selectedPorD?.workflow_id;
+ const success = await clearFileHistory(id);
if (success && openDeleteModal) {
setOpenDeleteModal(false);
}
};
- const handleShare = async () => {
- setIsLoadingShare(true);
- // Fetch all users and shared users first, then open modal
- try {
- const [usersResponse, sharedUsersResponse] = await Promise.all([
- pipelineApiService.getAllUsers(),
- pipelineApiService.getSharedUsers(selectedPorD.id),
- ]);
-
- // Extract members array from the response and map to the required format
- const userList =
- usersResponse?.data?.members?.map((member) => ({
- id: member.id,
- email: member.email,
- })) || [];
-
- const sharedUsersList = sharedUsersResponse.data?.shared_users || [];
-
- // Set shared_users property on selectedPorD for SharePermission component
- setSelectedPorD({
- ...selectedPorD,
- shared_users: Array.isArray(sharedUsersList) ? sharedUsersList : [],
- });
+ // Handlers for icon actions (top-right)
+ const handleEditPipeline = () => {
+ openAddModal(true);
+ };
- setAllUsers(userList);
+ const handleDeletePipeline = () => {
+ setOpenDeleteModal(true);
+ };
+
+ // Handlers for expanded view actions
+ const handleViewLogsPipeline = (pipeline) => {
+ handleViewLogs(pipeline, setSelectedPorD);
+ };
- // Only open modal after data is loaded
- setOpenShareModal(true);
- } catch (error) {
- setAlertDetails(handleException(error));
- // Ensure allUsers is always an array even on error
- setAllUsers([]);
- } finally {
- setIsLoadingShare(false);
+ const handleViewFileHistoryPipeline = (pipeline) => {
+ if (!pipeline?.workflow_id) {
+ setAlertDetails({
+ type: "error",
+ content: "Cannot view file history: Workflow ID not found",
+ });
+ return;
}
+ setSelectedPorD(pipeline);
+ setOpenFileHistoryModal(true);
};
- const onShare = (sharedUsers, _, shareWithEveryone) => {
- setIsLoadingShare(true);
- // sharedUsers is already an array of user IDs from SharePermission component
+ const handleClearFileHistoryPipeline = (pipeline) => {
+ setSelectedPorD(pipeline);
+ clearFileMarkers(pipeline.workflow_id);
+ };
- pipelineApiService
- .updateSharing(selectedPorD.id, sharedUsers, shareWithEveryone)
- .then(() => {
- setAlertDetails({
- type: "success",
- content: "Sharing permissions updated successfully",
- });
- setOpenShareModal(false);
- // Refresh pipeline list to show updated ownership
- getPipelineList();
- })
- .catch((error) => {
- setAlertDetails(
- handleException(error, "Failed to update sharing settings"),
- );
- })
- .finally(() => {
- setIsLoadingShare(false);
- });
+ const handleSyncNowPipeline = (pipeline) => {
+ handleSync({ pipeline_id: pipeline.id });
};
- const actionItems = [
- // Configuration Section
- {
- key: "1",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() => openAddModal(true)}
- >
- <div>
- <EditOutlined />
- </div>
- <div>
- <Typography.Text>Edit</Typography.Text>
- </div>
- </Space>
- ),
- },
- {
- key: "2",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() =>
- getApiKeys(
- pipelineApiService,
- selectedPorD?.id,
- setApiKeys,
- setOpenManageKeysModal,
- )
- }
- >
- <KeyOutlined />
- <Typography.Text>Manage Keys</Typography.Text>
- </Space>
- ),
- },
- {
- key: "3",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() => setOpenNotificationModal(true)}
- >
- <NotificationOutlined />
- <Typography.Text>Setup Notifications</Typography.Text>
- </Space>
- ),
- },
- {
- key: "share",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={handleShare}
- >
- <ShareAltOutlined />
- <Typography.Text>Share</Typography.Text>
- </Space>
- ),
- },
- {
- key: "divider-config",
- type: "divider",
- },
- // Operation Section
- {
- key: "4",
- label: (
- <Space
- direction="horizontal"
- className={`action-items ${
- isClearingFileHistory
- ? "action-item-disabled"
- : "action-item-enabled"
- }`}
- onClick={() =>
- !isClearingFileHistory &&
- handleSync({
- pipeline_id: selectedPorD.id,
- })
- }
- >
- <SyncOutlined />
- <Typography.Text>Sync Now</Typography.Text>
- </Space>
- ),
- },
- {
- key: "5",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() => {
- setOpenLogsModal(true);
- fetchExecutionLogs(
- axiosPrivate,
- handleException,
- sessionDetails,
- selectedPorD,
- setExecutionLogs,
- setExecutionLogsTotalCount,
- setAlertDetails,
- );
- }}
- >
- <FileSearchOutlined />
- <Typography.Text>View Logs</Typography.Text>
- </Space>
- ),
- },
- {
- key: "view-file-history",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() => {
- if (!selectedPorD?.workflow_id) {
- setAlertDetails({
- type: "error",
- content: "Cannot view file history: Workflow ID not found",
- });
- return;
- }
-
- setOpenFileHistoryModal(true);
- }}
- >
- <HistoryOutlined />
- <Typography.Text>View File History</Typography.Text>
- </Space>
- ),
- },
- {
- key: "divider-operation",
- type: "divider",
- },
- // Developer related Section
- {
- key: "6",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() =>
- downloadPostmanCollection(pipelineApiService, selectedPorD?.id)
- }
- >
- <CloudDownloadOutlined />
- <Typography.Text>Download Postman Collection</Typography.Text>
- </Space>
- ),
- },
- {
- key: "divider-dev-related",
- type: "divider",
- },
- // Delete related section
- {
- key: "7",
- label: (
- <Space
- direction="horizontal"
- className={`action-items ${
- isClearingFileHistory
- ? "action-item-disabled"
- : "action-item-enabled"
- }`}
- onClick={() => !isClearingFileHistory && clearFileMarkers()}
- >
- {isClearingFileHistory ? <LoadingOutlined /> : <HighlightOutlined />}
- <Typography.Text>Clear Processed File History</Typography.Text>
- </Space>
- ),
- },
- {
- key: "8",
- label: (
- <Space
- direction="horizontal"
- className="action-items"
- onClick={() => setOpenDeleteModal(true)}
- >
- <DeleteOutlined />
- <Typography.Text>Delete</Typography.Text>
- </Space>
- ),
- },
- ];
-
- const columns = [
- {
- title: "Source",
- render: (_, record) => (
- <div>
- <div>
- <Image src={record?.source_icon} preview={false} width={30} />
- </div>
- <Typography.Text className="p-or-d-typography" strong>
- {record?.source_name}
- </Typography.Text>
- </div>
- ),
- key: "source",
- align: "center",
- },
- {
- title: "Pipeline",
- key: "pipeline_name",
- render: (_, record) => (
- <>
- <Typography.Text strong>{record?.pipeline_name}</Typography.Text>
- <br />
- <Typography.Text type="secondary" className="p-or-d-typography">
- from {record?.workflow_name}
- </Typography.Text>
- </>
- ),
- align: "center",
- },
- {
- title: "Destination",
- render: (_, record) => (
- <div>
- <div>
- <Image src={record?.destination_icon} preview={false} width={30} />
- </div>
- <Typography.Text className="p-or-d-typography" strong>
- {record?.destination_name}
- </Typography.Text>
- </div>
- ),
- key: "destination",
- align: "center",
- },
- {
- title: "API Endpoint",
- key: "api_endpoint",
- render: (_, record) => (
- <Space direction="horizontal" className="display-flex-space-between">
- <div>
- <Typography.Text>
- {displayURL(record?.api_endpoint)}
- </Typography.Text>
- </div>
- <div>
- <Tooltip title="click to copy">
- <Button
- size="small"
- onClick={() => copyUrl(record?.api_endpoint)}
- >
- <CopyOutlined />
- </Button>
- </Tooltip>
- </div>
- </Space>
- ),
- align: "left",
- },
- {
- title: "Status of Previous Run",
- dataIndex: "last_run_status",
- key: "last_run_status",
- align: "center",
- render: (_, record) => (
- <>
- {record.last_run_status === "processing" ? (
- <SpinnerLoader />
- ) : (
- <Space>
- <Typography.Text className="p-or-d-typography" strong>
- {record?.last_run_status}
- </Typography.Text>
- <Button
- icon={<ReloadOutlined />}
- type="text"
- size="small"
- onClick={() => handleStatusRefresh(record?.id)}
- />
- </Space>
- )}
- </>
- ),
- },
- {
- title: "Previous Run At",
- key: "last_run_time",
- dataIndex: "last_run_time",
- align: "center",
- render: (_, record) => (
- <div>
- <Typography.Text className="p-or-d-typography" strong>
- {record?.last_run_time}
- </Typography.Text>
- </div>
- ),
- },
- {
- title: "Frequency",
- key: "last_run_time",
- dataIndex: "last_run_time",
- align: "center",
- render: (_, record) => (
- <div>
- <Typography.Text className="p-or-d-typography" strong>
- {record?.cron_string && cronstrue.toString(record?.cron_string)}
- </Typography.Text>
- </div>
- ),
- },
- {
- title: "Owner",
- dataIndex: "created_by_email",
- key: "created_by_email",
- align: "center",
- render: (email, record) => {
- const isOwner = record.created_by === sessionDetails?.userId;
- return (
- <Tooltip title={email}>
- <Typography.Text className="p-or-d-typography">
- {isOwner ? "You" : email?.split("@")[0] || "Unknown"}
- </Typography.Text>
- </Tooltip>
- );
- },
- },
- {
- title: "Enabled",
- key: "active",
- dataIndex: "active",
- align: "center",
- render: (_, record) => (
- <Switch
- checked={record.active}
- onChange={() => {
- handleEnablePipeline(!record.active, record.id);
- }}
- />
- ),
- },
- {
- title: "Actions",
- key: "pipeline_id",
- align: "center",
- render: (_, record) => (
- <Dropdown
- menu={{ items: actionItems }}
- placement="bottomLeft"
- onOpenChange={() => setSelectedPorD(record)}
- trigger={["click"]}
- >
- <EllipsisOutlined className="p-or-d-actions cur-pointer" />
- </Dropdown>
- ),
- },
- ];
+ const handleManageKeysPipeline = (pipeline) => {
+ setSelectedPorD(pipeline);
+ getApiKeys(
+ pipelineApiService,
+ pipeline.id,
+ setApiKeys,
+ setOpenManageKeysModal,
+ );
+ };
+
+ const handleSetupNotificationsPipeline = (pipeline) => {
+ setSelectedPorD(pipeline);
+ setOpenNotificationModal(true);
+ };
+
+ const handleDownloadPostmanPipeline = (pipeline) => {
+ downloadPostmanCollection(pipelineApiService, pipeline.id);
+ };
+
+ // Card view configuration - no actionItems needed, all handlers passed directly
+ const pipelineCardConfig = useMemo(
+ () =>
+ createPipelineCardConfig({
+ setSelectedPorD,
+ handleEnablePipeline,
+ sessionDetails,
+ location,
+ // Icon actions
+ onEdit: handleEditPipeline,
+ onShare: handleShare,
+ onDelete: handleDeletePipeline,
+ // Expanded view actions
+ onViewLogs: handleViewLogsPipeline,
+ onViewFileHistory: handleViewFileHistoryPipeline,
+ onClearFileHistory: handleClearFileHistoryPipeline,
+ onSyncNow: handleSyncNowPipeline,
+ onManageKeys: handleManageKeysPipeline,
+ onSetupNotifications: handleSetupNotificationsPipeline,
+ onDownloadPostman: handleDownloadPostmanPipeline,
+ // Loading states
+ isClearingFileHistory,
+ // Pipeline type for status pill navigation
+ pipelineType: type,
+ // List context for scroll restoration on back navigation
+ listContext: {
+ page: pagination.current,
+ pageSize: pagination.pageSize,
+ searchTerm,
+ },
+ }),
+ [
+ sessionDetails,
+ isClearingFileHistory,
+ location,
+ type,
+ pagination.current,
+ pagination.pageSize,
+ searchTerm,
+ ],
+ );
// Using the custom hook to manage modal state
const { showModal, handleModalClose } = usePromptStudioModal(
@@ -720,10 +381,20 @@ function Pipelines({ type }) {
)}
<Layout
type={type}
- columns={columns}
tableData={tableData}
isTableLoading={tableLoading}
openAddModal={openAddModal}
+ cardConfig={pipelineCardConfig}
+ listMode={true}
+ scrollToId={scrollRestoreId}
+ enableSearch={true}
+ onSearch={handleSearch}
+ pagination={{
+ current: pagination.current,
+ pageSize: pagination.pageSize,
+ total: pagination.total,
+ onChange: handlePaginationChange,
+ }}
/>
{openEtlOrTaskModal && (
<EtlTaskDeploy
@@ -743,6 +414,7 @@ function Pipelines({ type }) {
logRecord={executionLogs}
totalLogs={executionLogsTotalCount}
fetchExecutionLogs={handleFetchLogs}
+ loading={isFetchingLogs}
/>
<DeleteModal
open={openDeleteModal}
diff --git a/frontend/src/components/widgets/card-grid-view/CardFieldComponents.jsx b/frontend/src/components/widgets/card-grid-view/CardFieldComponents.jsx
new file mode 100644
index 000000000..f5e215880
--- /dev/null
+++ b/frontend/src/components/widgets/card-grid-view/CardFieldComponents.jsx
@@ -0,0 +1,393 @@
+import {
+ ClockCircleOutlined,
+ CopyOutlined,
+ DeleteOutlined,
+ EditOutlined,
+ ExportOutlined,
+ HistoryOutlined,
+ MoreOutlined,
+ ShareAltOutlined,
+ UserOutlined,
+} from "@ant-design/icons";
+import {
+ Avatar,
+ Button,
+ Card,
+ Dropdown,
+ Flex,
+ Popconfirm,
+ Space,
+ Tooltip,
+ Typography,
+} from "antd";
+import PropTypes from "prop-types";
+import { Link } from "react-router-dom";
+import WorkflowIcon from "../../../assets/Workflows.svg";
+import {
+ copyToClipboard,
+ formattedDateTime,
+ shortenApiEndpoint,
+} from "../../../helpers/GetStaticData";
+
+/**
+ * Reusable action box with Edit, Share, Delete icons and kebab menu
+ * @return {JSX.Element} Rendered action box
+ */
+function CardActionBox({
+ item,
+ setSelectedItem,
+ onEdit,
+ onShare,
+ onDelete,
+ deleteTitle = "Delete item?",
+ kebabMenuItems,
+}) {
+ const handleEditAction = (e) => {
+ e.stopPropagation();
+ setSelectedItem(item);
+ onEdit?.(item);
+ };
+
+ const handleShareAction = (e) => {
+ e.stopPropagation();
+ setSelectedItem(item);
+ onShare?.(item);
+ };
+
+ return (
+ <Space className="card-list-action-box">
+ <Button
+ type="text"
+ className="action-icon-btn edit-icon"
+ icon={<EditOutlined />}
+ onClick={handleEditAction}
+ />
+ <Button
+ type="text"
+ className="action-icon-btn share-icon"
+ icon={<ShareAltOutlined />}
+ onClick={handleShareAction}
+ />
+ <Popconfirm
+ title={deleteTitle}
+ description="This action cannot be undone."
+ onConfirm={() => {
+ setSelectedItem(item);
+ onDelete?.(item);
+ }}
+ onCancel={(e) => e?.stopPropagation()}
+ okText="Delete"
+ cancelText="Cancel"
+ okButtonProps={{ danger: true }}
+ >
+ <Button
+ type="text"
+ className="action-icon-btn delete-icon"
+ icon={<DeleteOutlined />}
+ onClick={(e) => e.stopPropagation()}
+ />
+ </Popconfirm>
+ <Dropdown
+ menu={kebabMenuItems}
+ trigger={["click"]}
+ placement="bottomRight"
+ >
+ <Button
+ type="text"
+ className="card-kebab-menu"
+ icon={<MoreOutlined />}
+ onClick={(e) => e.stopPropagation()}
+ />
+ </Dropdown>
+ </Space>
+ );
+}
+
+CardActionBox.propTypes = {
+ item: PropTypes.object.isRequired,
+ setSelectedItem: PropTypes.func.isRequired,
+ onEdit: PropTypes.func,
+ onShare: PropTypes.func,
+ onDelete: PropTypes.func,
+ deleteTitle: PropTypes.string,
+ kebabMenuItems: PropTypes.object.isRequired,
+};
+
+/**
+ * Reusable owner field row
+ * @return {JSX.Element} Rendered owner field row
+ */
+function OwnerFieldRow({ item, sessionDetails }) {
+ const isOwner = item.created_by === sessionDetails?.userId;
+ const email = item.created_by_email;
+ const ownerDisplay = isOwner ? "You" : email?.split("@")[0] || "Unknown";
+
+ return (
+ <Flex align="center" className="card-list-field-row">
+ <Typography.Text type="secondary" className="card-list-field-label">
+ Owner
+ </Typography.Text>
+ <Space size={10} className="card-list-field-value">
+ <UserOutlined />
+ <Tooltip title={email}>
+ <Typography.Text>{ownerDisplay}</Typography.Text>
+ </Tooltip>
+ </Space>
+ </Flex>
+ );
+}
+
+OwnerFieldRow.propTypes = {
+ item: PropTypes.object.isRequired,
+ sessionDetails: PropTypes.object,
+};
+
+/**
+ * Reusable last run field row
+ * @return {JSX.Element} Rendered last run field row
+ */
+function LastRunFieldRow({ lastRunTime }) {
+ return (
+ <Flex align="center" className="card-list-field-row">
+ <Typography.Text type="secondary" className="card-list-field-label">
+ Last Run
+ </Typography.Text>
+ <Space size={10} className="card-list-field-value">
+ <ClockCircleOutlined />
+ <Typography.Text>
+ {lastRunTime ? formattedDateTime(lastRunTime) : "Never"}
+ </Typography.Text>
+ </Space>
+ </Flex>
+ );
+}
+
+LastRunFieldRow.propTypes = {
+ lastRunTime: PropTypes.string,
+};
+
+/**
+ * Reusable last 5 runs field row
+ * @return {JSX.Element|null} Rendered last 5 runs field row or null
+ */
+function Last5RunsFieldRow({
+ statuses,
+ executionType,
+ itemId,
+ StatusPillsComponent,
+ listContext,
+}) {
+ if (!statuses?.length) {
+ return null;
+ }
+
+ return (
+ <Flex align="center" className="card-list-field-row">
+ <Typography.Text type="secondary" className="card-list-field-label">
+ Last 5 Runs
+ </Typography.Text>
+ <Space size={10} className="card-list-field-value">
+ <HistoryOutlined />
+ <StatusPillsComponent
+ statuses={statuses}
+ executionType={executionType}
+ pipelineId={itemId}
+ listContext={listContext}
+ />
+ </Space>
+ </Flex>
+ );
+}
+
+Last5RunsFieldRow.propTypes = {
+ statuses: PropTypes.array,
+ executionType: PropTypes.string,
+ itemId: PropTypes.string,
+ StatusPillsComponent: PropTypes.elementType.isRequired,
+ listContext: PropTypes.object,
+};
+
+/**
+ * Reusable workflow link field row
+ * @return {JSX.Element} Rendered workflow field row
+ */
+function WorkflowFieldRow({
+ workflowId,
+ workflowName,
+ sessionDetails,
+ location,
+ itemId,
+ listContext,
+}) {
+ const orgName = sessionDetails?.orgName;
+
+ // Guard against undefined orgName to prevent malformed URLs
+ if (!orgName) {
+ return (
+ <Flex align="center" className="card-list-field-row">
+ <Typography.Text type="secondary" className="card-list-field-label">
+ Workflow
+ </Typography.Text>
+ <Space size={10} className="card-list-field-value">
+ <Avatar
+ src={WorkflowIcon}
+ size={14}
+ shape="square"
+ className="card-list-meta-icon"
+ />
+ <Typography.Text className="card-list-workflow-link-row">
+ {workflowName}
+ </Typography.Text>
+ </Space>
+ </Flex>
+ );
+ }
+
+ return (
+ <Flex align="center" className="card-list-field-row">
+ <Typography.Text type="secondary" className="card-list-field-label">
+ Workflow
+ </Typography.Text>
+ <Space size={10} className="card-list-field-value">
+ <Avatar
+ src={WorkflowIcon}
+ size={14}
+ shape="square"
+ className="card-list-meta-icon"
+ />
+ <Link
+ to={`/${orgName}/workflows/${workflowId}`}
+ state={{
+ from: location?.pathname,
+ scrollToCardId: itemId,
+ page: listContext?.page,
+ pageSize: listContext?.pageSize,
+ searchTerm: listContext?.searchTerm,
+ }}
+ className="card-list-workflow-link-row"
+ onClick={(e) => e.stopPropagation()}
+ >
+ {workflowName}
+ <ExportOutlined />
+ </Link>
+ </Space>
+ </Flex>
+ );
+}
+
+WorkflowFieldRow.propTypes = {
+ workflowId: PropTypes.string.isRequired,
+ workflowName: PropTypes.string.isRequired,
+ sessionDetails: PropTypes.object,
+ location: PropTypes.object,
+ itemId: PropTypes.string,
+ listContext: PropTypes.object,
+};
+
+/**
+ * Reusable API endpoint section
+ * @return {JSX.Element|null} Rendered API endpoint section or null
+ */
+function ApiEndpointSection({ apiEndpoint }) {
+ if (!apiEndpoint) {
+ return null;
+ }
+
+ // Validate URL scheme to prevent javascript: or other malicious protocols
+ const isValidUrl = (() => {
+ try {
+ const parsed = new URL(apiEndpoint, globalThis.location.origin);
+ return ["http:", "https:"].includes(parsed.protocol);
+ } catch {
+ return false;
+ }
+ })();
+
+ return (
+ <div className="card-list-endpoint-wrapper">
+ <Card size="small" className="card-list-endpoint-row">
+ <Flex align="center" gap={12}>
+ <Typography.Text type="secondary" className="card-list-field-label">
+ API Endpoint
+ </Typography.Text>
+ <div className="card-list-endpoint-value">
+ <Tooltip title={apiEndpoint} overlayStyle={{ maxWidth: 500 }}>
+ {isValidUrl ? (
+ <Typography.Link
+ href={apiEndpoint}
+ target="_blank"
+ onClick={(e) => e.stopPropagation()}
+ >
+ {shortenApiEndpoint(apiEndpoint)}
+ </Typography.Link>
+ ) : (
+ <Typography.Text>
+ {shortenApiEndpoint(apiEndpoint)}
+ </Typography.Text>
+ )}
+ </Tooltip>
+ <Tooltip title="Copy endpoint">
+ <Button
+ className="copy-btn-outlined"
+ icon={<CopyOutlined />}
+ size="small"
+ onClick={(e) => {
+ e.stopPropagation();
+ copyToClipboard(apiEndpoint);
+ }}
+ />
+ </Tooltip>
+ </div>
+ </Flex>
+ </Card>
+ </div>
+ );
+}
+
+ApiEndpointSection.propTypes = {
+ apiEndpoint: PropTypes.string,
+};
+
+/**
+ * Reusable card header row with title and actions
+ * @return {JSX.Element} Rendered header row
+ */
+function CardHeaderRow({ title, description, children }) {
+ return (
+ <Flex
+ justify="space-between"
+ align="center"
+ className="card-list-header-row"
+ >
+ <Flex vertical gap={4} className="card-list-title-section">
+ <Tooltip title={title}>
+ <Typography.Text className="card-list-name" strong>
+ {title}
+ </Typography.Text>
+ </Tooltip>
+ {description && (
+ <Typography.Text className="card-list-description" type="secondary">
+ {description}
+ </Typography.Text>
+ )}
+ </Flex>
+ {children}
+ </Flex>
+ );
+}
+
+CardHeaderRow.propTypes = {
+ title: PropTypes.string.isRequired,
+ description: PropTypes.string,
+ children: PropTypes.node,
+};
+
+export {
+ CardActionBox,
+ OwnerFieldRow,
+ LastRunFieldRow,
+ Last5RunsFieldRow,
+ WorkflowFieldRow,
+ ApiEndpointSection,
+ CardHeaderRow,
+};
diff --git a/frontend/src/components/widgets/card-grid-view/CardGridView.css b/frontend/src/components/widgets/card-grid-view/CardGridView.css
new file mode 100644
index 000000000..9627e3c38
--- /dev/null
+++ b/frontend/src/components/widgets/card-grid-view/CardGridView.css
@@ -0,0 +1,1152 @@
+/* CardGridView - Responsive Grid Layout */
+.card-grid-view {
+ width: 60%;
+ min-width: 700px;
+ max-width: 1200px;
+ margin: 0 auto;
+ padding: 16px 10px 40px 10px;
+}
+
+.card-grid-row {
+ margin: 0 !important;
+ row-gap: 16px;
+}
+
+/* CardItem - Individual Card Styling */
+.card-grid-item {
+ height: 100%;
+ transition: all 0.2s ease;
+ border-radius: 8px;
+}
+
+.card-grid-item:hover {
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
+}
+
+.card-grid-item .ant-card-head {
+ min-height: auto;
+ padding: 12px 16px;
+ border-bottom: 1px solid #f0f0f0;
+}
+
+.card-grid-item .ant-card-head-title {
+ padding: 0;
+ font-size: 14px;
+ font-weight: 600;
+}
+
+.card-grid-item .ant-card-extra {
+ padding: 0;
+}
+
+.card-grid-item .ant-card-body {
+ padding: 16px;
+}
+
+/* Card Header */
+.card-item-header {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ gap: 12px;
+}
+
+.card-item-title-section {
+ flex: 1;
+ min-width: 0;
+}
+
+.card-item-title {
+ font-size: 14px;
+ font-weight: 600;
+ margin: 0;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.card-item-subtitle {
+ display: block;
+ font-size: 12px;
+ color: rgba(0, 0, 0, 0.55);
+ margin-top: 2px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.card-item-actions {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+ flex-shrink: 0;
+}
+
+/* Card Sections */
+.card-section {
+ margin-top: 12px;
+}
+
+.card-section:first-child {
+ margin-top: 0;
+}
+
+.card-section-grid {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
+ gap: 12px;
+}
+
+/* Card Fields */
+.card-field-icon {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 20px;
+ height: 20px;
+ flex-shrink: 0;
+}
+
+.card-field-icon img {
+ max-width: 100%;
+ max-height: 100%;
+ object-fit: contain;
+}
+
+.card-field-content {
+ min-width: 0;
+}
+
+.card-field-label {
+ font-size: 11px;
+ color: rgba(0, 0, 0, 0.55);
+ text-transform: uppercase;
+ letter-spacing: 0.5px;
+}
+
+.card-field-value {
+ font-size: 13px;
+ color: rgba(0, 0, 0, 0.85);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+/* Connector display (source/destination) */
+.card-connector {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.card-connector-icon {
+ width: 24px;
+ height: 24px;
+ flex-shrink: 0;
+}
+
+.card-connector-icon img {
+ width: 100%;
+ height: 100%;
+ object-fit: contain;
+}
+
+.card-connector-name {
+ font-size: 13px;
+ color: rgba(0, 0, 0, 0.85);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+/* Status Pills */
+.card-status-pill {
+ display: inline-flex;
+ align-items: center;
+ padding: 2px 8px;
+ border-radius: 4px;
+ font-size: 12px;
+ font-weight: 500;
+ text-transform: capitalize;
+}
+
+.card-status-success {
+ background-color: #f6ffed;
+ color: #237804;
+ border: 1px solid #b7eb8f;
+}
+
+.card-status-failure,
+.card-status-failed {
+ background-color: #fff2f0;
+ color: #cf1322;
+ border: 1px solid #ffccc7;
+}
+
+.card-status-processing,
+.card-status-running {
+ background-color: #e6f7ff;
+ color: #096dd9;
+ border: 1px solid #91d5ff;
+}
+
+.card-status-pending,
+.card-status-unknown {
+ background-color: #fafafa;
+ color: rgba(0, 0, 0, 0.55);
+ border: 1px solid #d9d9d9;
+}
+
+/* Expanded Content */
+.card-expanded-content {
+ margin-top: 16px;
+ padding-top: 16px;
+ border-top: 1px solid #f0f0f0;
+ animation: cardExpandAnimation 0.2s ease-out;
+}
+
+@keyframes cardExpandAnimation {
+ from {
+ opacity: 0;
+ transform: translateY(-8px);
+ }
+ to {
+ opacity: 1;
+ transform: translateY(0);
+ }
+}
+
+/* Loading Skeleton */
+.card-skeleton-row {
+ margin: 0 !important;
+}
+
+.card-skeleton-item .ant-card-body {
+ padding: 16px;
+}
+
+/* Empty State */
+.card-grid-empty {
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ min-height: 200px;
+ padding: 24px;
+}
+
+/* Action Menu */
+.card-action-menu {
+ cursor: pointer;
+ padding: 4px 8px;
+ border-radius: 4px;
+ transition: background-color 0.2s;
+}
+
+.card-action-menu:hover {
+ background-color: rgba(0, 0, 0, 0.04);
+}
+
+/* Responsive adjustments */
+@media (max-width: 768px) {
+ .card-field {
+ width: 100%;
+ }
+}
+
+/* ==============================
+ List Mode Card Layout
+ ============================== */
+
+/* List mode card item - full width horizontal layout */
+.card-grid-item.card-list-mode {
+ width: 100%;
+ transition: all 0.2s ease;
+}
+
+.card-grid-item.card-list-mode .ant-card-body {
+ padding: 0;
+}
+
+/* Card content container */
+.card-list-content {
+ position: relative;
+ width: 100%;
+}
+
+/* Actions at top-right (absolute position) */
+.card-list-actions-absolute {
+ position: absolute;
+ top: 16px;
+ right: 16px;
+ display: flex;
+ align-items: center;
+ gap: 20px;
+ z-index: 1;
+}
+
+/* 2-column layout */
+.card-list-two-column {
+ display: flex;
+ gap: 48px;
+ padding: 16px 180px 16px 16px;
+ align-items: end;
+ justify-content: center;
+}
+
+/* Title section - contains name and description */
+.card-list-title-section {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ min-width: 0;
+ flex: 1;
+}
+
+/* Description subtext styling */
+.card-list-description {
+ font-size: 13px;
+ color: rgba(0, 0, 0, 0.55);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ max-width: 400px;
+}
+
+/* Single column layout - title, connectors, meta stacked vertically */
+.card-list-single-column {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ padding: 16px 180px 16px 16px;
+}
+
+.card-list-info-column {
+ flex: 0 0 auto;
+ min-width: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+}
+
+.card-list-connectors-column {
+ flex: 0 0 auto;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ align-items: flex-start;
+}
+
+/* Stack meta rows vertically */
+.card-list-meta-stack {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+}
+
+/* Workflow link - styled with icon */
+.card-list-workflow-link {
+ font-size: 14px;
+ color: rgba(0, 0, 0, 0.85);
+ text-decoration: none;
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ padding: 2px 6px;
+ border-radius: 4px;
+ transition: background-color 0.2s ease;
+}
+
+.card-list-workflow-link:hover {
+ background-color: rgba(0, 0, 0, 0.04);
+ color: rgba(0, 0, 0, 0.85);
+}
+
+.card-list-workflow-link-icon {
+ font-size: 11px;
+ color: rgba(0, 0, 0, 0.55);
+}
+
+.card-list-name {
+ font-family: var(--font-family);
+ font-size: 16px;
+ font-weight: var(--font-weight-600);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ max-width: 300px;
+}
+
+/* Status Badges Container */
+.status-badges-container {
+ display: flex;
+ gap: 6px;
+ align-items: center;
+ flex-wrap: wrap;
+}
+
+/* Status Badges - AntD Tag for Last 5 runs */
+.status-badge,
+.status-badge.ant-tag {
+ padding: 4px 10px;
+ border-radius: 4px;
+ font-size: 11px;
+ font-weight: 600;
+ font-family: var(--font-family);
+ text-transform: uppercase;
+ letter-spacing: 0.5px;
+ cursor: default;
+ transition:
+ transform 0.15s ease,
+ box-shadow 0.15s ease;
+ white-space: nowrap;
+ margin: 0;
+ line-height: 1.2;
+}
+
+.status-badge:hover,
+.status-badge.ant-tag:hover {
+ transform: scale(1.05);
+ box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
+}
+
+/* Clickable status badges - AntD Tag with click handler */
+.status-badge.status-badge-clickable,
+.status-badge.ant-tag.status-badge-clickable {
+ cursor: pointer;
+ transition:
+ transform 0.15s ease,
+ box-shadow 0.15s ease;
+}
+
+.status-badge.status-badge-clickable:hover,
+.status-badge.ant-tag.status-badge-clickable:hover {
+ transform: scale(1.1);
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
+}
+
+.status-badge.status-badge-clickable:focus-visible,
+.status-badge.ant-tag.status-badge-clickable:focus-visible {
+ outline: 2px solid #1890ff;
+ outline-offset: 2px;
+}
+
+/* Status tooltip styling */
+.status-tooltip-content {
+ font-size: 11px;
+}
+
+.status-tooltip-counts {
+ display: flex;
+ gap: 12px;
+ margin-bottom: 4px;
+}
+
+.status-tooltip-count {
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+}
+
+.status-tooltip-count.success {
+ color: #52c41a;
+}
+
+.status-tooltip-count.error {
+ color: #ff4242;
+}
+
+.status-tooltip-timestamp {
+ margin-bottom: 2px;
+}
+
+.status-tooltip-hint {
+ margin-top: 4px;
+ opacity: 0.8;
+}
+
+/* Override antd Typography color inside dark tooltips */
+.status-tooltip-content .ant-typography {
+ color: inherit;
+}
+
+/* Preserve icon colors inside dark tooltip background */
+.status-tooltip-count.success .anticon {
+ color: #52c41a;
+}
+
+.status-tooltip-count.error .anticon {
+ color: #ff4242;
+}
+
+/* Meta row with label/value pattern - VERTICAL STACKING */
+.card-list-meta-row {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ font-family: var(--font-family);
+}
+
+/* Status row - full width below 2-column layout */
+.card-list-status-row {
+ margin-top: 8px;
+}
+
+.card-list-meta-item {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 200px;
+}
+
+/* Meta item labels - light grey, sentence case with icons */
+.card-list-meta-label {
+ font-size: 12px;
+ color: rgba(0, 0, 0, 0.55);
+ letter-spacing: 0.3px;
+ font-weight: 500;
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ min-width: 90px;
+}
+
+.card-list-meta-label .anticon {
+ font-size: 14px;
+}
+
+.card-list-meta-icon {
+ width: 14px;
+ height: 14px;
+ vertical-align: middle;
+}
+
+/* Meta item values - dark color */
+.card-list-meta-value {
+ font-size: 14px;
+ color: rgba(0, 0, 0, 0.85);
+ font-weight: 400;
+}
+
+/* Connector flow display - VERTICAL STACKING */
+.connector-flow {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 8px;
+}
+
+.connector-flow-item {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+}
+
+/* Clickable connector styling */
+.connector-flow-clickable {
+ cursor: pointer;
+ padding: 6px 10px;
+ border-radius: 6px;
+ transition: background 0.2s ease;
+}
+
+.connector-flow-clickable:hover {
+ background: rgba(0, 0, 0, 0.04);
+}
+
+/* Larger connector icons */
+.connector-flow-icon {
+ width: 32px;
+ height: 32px;
+ flex-shrink: 0;
+}
+
+.connector-flow-icon img {
+ width: 100%;
+ height: 100%;
+ object-fit: contain;
+}
+
+/* Connector text container */
+.connector-flow-text {
+ display: flex;
+ flex-direction: column;
+ align-items: flex-start;
+}
+
+/* Connector instance name - user-set name, prominent */
+.connector-flow-instance-name {
+ font-family: var(--font-family);
+ font-size: 14px;
+ font-weight: 500;
+ color: rgba(0, 0, 0, 0.85);
+ white-space: nowrap;
+}
+
+/* Connector type name - smaller subtext */
+.connector-flow-type-name {
+ font-size: 11px;
+ color: rgba(0, 0, 0, 0.55);
+ white-space: nowrap;
+}
+
+/* Legacy connector name style (fallback) */
+.connector-flow-name {
+ font-family: var(--font-family);
+ font-size: 14px;
+ font-weight: 500;
+ color: rgba(0, 0, 0, 0.85);
+ white-space: nowrap;
+}
+
+/* Hide arrow - no longer used in vertical layout */
+.connector-flow-arrow {
+ display: none;
+}
+
+/* Connector tooltip styling */
+.connector-tooltip {
+ text-align: center;
+}
+
+.connector-tooltip-hint {
+ font-size: 11px;
+ opacity: 0.7;
+ margin-top: 4px;
+}
+
+/* Card list actions */
+.card-list-actions {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+}
+
+/* Action box - white bordered container for action icons */
+.card-list-action-box {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+ padding: 8px 12px;
+ border: 1px solid #e8e8e8;
+ border-radius: 6px;
+ background: #fff;
+}
+
+/* Icon action group - Edit, Share, Delete */
+.action-icon-group {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+}
+
+/* Action icon buttons - supports both native button and AntD Button */
+.action-icon-btn,
+.action-icon-btn.ant-btn {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 18px;
+ color: #092c4c;
+ cursor: pointer;
+ transition:
+ color 0.2s ease,
+ transform 0.15s ease;
+ padding: 4px;
+ border: none;
+ outline: none;
+ height: auto;
+ width: auto;
+}
+
+.action-icon-btn:hover,
+.action-icon-btn.ant-btn:hover {
+ transform: scale(1.1);
+ color: #092c4c;
+}
+
+.action-icon-btn:focus-visible,
+.action-icon-btn.ant-btn:focus-visible {
+ outline: 2px solid #1890ff;
+ outline-offset: 2px;
+ border-radius: 4px;
+}
+
+.action-icon-btn.edit-icon:hover,
+.action-icon-btn.edit-icon.ant-btn:hover {
+ color: #0958d9;
+}
+
+.action-icon-btn.share-icon:hover,
+.action-icon-btn.share-icon.ant-btn:hover {
+ color: #0958d9;
+}
+
+.action-icon-btn.delete-icon:hover,
+.action-icon-btn.delete-icon.ant-btn:hover {
+ color: #cf1322;
+}
+
+/* List mode expanded content - hidden by default, shown on hover */
+.card-list-expanded {
+ display: flex;
+ gap: 24px;
+ max-height: 0;
+ overflow: hidden;
+ opacity: 0;
+ padding-top: 0;
+ margin-top: 0;
+ border-top: none;
+ transition:
+ max-height 0.3s ease,
+ opacity 0.2s ease,
+ padding 0.2s ease,
+ margin 0.2s ease;
+}
+
+/* Expanded state - triggered via chevron toggle */
+.card-list-expanded.expanded {
+ max-height: 500px;
+ opacity: 1;
+ padding-top: 12px;
+ margin-top: 12px;
+ border-top: 1px solid #f0f0f0;
+}
+
+/* Chevron toggle button - supports both native button and AntD Button */
+.card-expand-chevron,
+.card-expand-chevron.ant-btn {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ cursor: pointer;
+ padding: 4px;
+ border-radius: 4px;
+ color: rgba(0, 0, 0, 0.55);
+ transition: all 0.2s ease;
+ font-size: 12px;
+ background: none;
+ border: none;
+ outline: none;
+ height: auto;
+ width: auto;
+}
+
+.card-expand-chevron:hover,
+.card-expand-chevron.ant-btn:hover {
+ background: rgba(0, 0, 0, 0.04);
+ color: rgba(0, 0, 0, 0.88);
+}
+
+.card-expand-chevron:focus-visible,
+.card-expand-chevron.ant-btn:focus-visible {
+ outline: 2px solid #1890ff;
+ outline-offset: 2px;
+}
+
+/* Expanded content wrapper */
+.card-list-expanded-content {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+}
+
+/* Info fields row */
+.card-list-expanded-info {
+ display: flex;
+ gap: 24px;
+ flex-wrap: wrap;
+}
+
+.card-list-expanded-field {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+
+.card-list-expanded-label {
+ font-family: var(--font-family);
+ font-size: 11px;
+ color: rgba(0, 0, 0, 0.55);
+ letter-spacing: 0.3px;
+}
+
+.card-list-expanded-value {
+ font-family: var(--font-family);
+ font-size: 14px;
+ color: rgba(0, 0, 0, 0.85);
+}
+
+/* Expanded view action buttons */
+.card-list-expanded-actions {
+ display: flex;
+ gap: 12px;
+ flex-wrap: wrap;
+ padding-top: 8px;
+ justify-content: center;
+}
+
+.card-list-expanded-actions .ant-btn {
+ font-size: 13px;
+}
+
+/* Responsive adjustments for list mode */
+@media (max-width: 992px) {
+ .card-list-two-column {
+ flex-wrap: wrap;
+ gap: 16px;
+ padding-right: 180px;
+ }
+
+ .card-list-single-column {
+ padding-right: 180px;
+ }
+
+ .card-list-connectors-column {
+ width: 100%;
+ justify-content: flex-start;
+ }
+}
+
+@media (max-width: 768px) {
+ .card-list-two-column {
+ padding-right: 150px;
+ }
+
+ .card-list-single-column {
+ padding-right: 150px;
+ }
+
+ .connector-flow-icon {
+ width: 24px;
+ height: 24px;
+ }
+
+ .connector-flow-instance-name {
+ font-size: 12px;
+ }
+
+ .connector-flow-type-name {
+ font-size: 10px;
+ }
+
+ .card-list-meta-row {
+ gap: 12px;
+ }
+
+ .card-list-meta-label {
+ font-size: 10px;
+ }
+}
+
+@media (max-width: 576px) {
+ .card-list-two-column {
+ padding-right: 120px;
+ }
+
+ .card-list-single-column {
+ padding-right: 120px;
+ }
+
+ .connector-flow-text {
+ display: none;
+ }
+
+ .card-list-name {
+ max-width: 200px;
+ }
+
+ .card-list-expanded.expanded {
+ flex-wrap: wrap;
+ gap: 12px;
+ }
+
+ .card-list-workflow-link {
+ font-size: 11px;
+ }
+
+ .action-icon-group {
+ gap: 10px;
+ }
+
+ .action-icon-btn {
+ font-size: 16px;
+ }
+}
+
+/* Style Ant Design copyable icon to be grey */
+.card-list-expanded-value .ant-typography-copy {
+ color: rgba(0, 0, 0, 0.55);
+}
+
+.card-list-expanded-value .ant-typography-copy:hover {
+ color: rgba(0, 0, 0, 0.85);
+}
+
+/* Outlined copy button style - matches Execution Logs page */
+.copy-btn-outlined {
+ border: 1px solid #d9d9d9;
+ background: #fff;
+ color: rgba(0, 0, 0, 0.65);
+ margin-left: 8px;
+ padding: 2px 6px;
+}
+
+.copy-btn-outlined:hover {
+ border-color: #1677ff;
+ color: #1677ff;
+}
+
+/* Responsive override for card-grid-view on smaller screens */
+@media (max-width: 900px) {
+ .card-grid-view {
+ width: 100%;
+ min-width: auto;
+ padding: 16px 8px 40px 8px;
+ }
+}
+
+/* Pagination Controls */
+.card-grid-pagination {
+ margin-top: 8px;
+ padding: 16px 0;
+}
+
+/* ==============================
+ Row-Based Card Layout (v2 Redesign)
+ No expand/collapse - all content visible
+ ============================== */
+
+/* Header row: Name left, actions right */
+.card-list-header-row {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 16px;
+ border-bottom: 1px solid #f0f0f0;
+ background: #fafafa;
+ border-radius: 8px 8px 0 0;
+}
+
+/* Row-based card layout - each field is its own row */
+.card-list-row-layout {
+ display: flex;
+ flex-direction: column;
+ gap: 0;
+ padding: 0 16px;
+}
+
+/* Each field row: label left, value right */
+.card-list-field-row {
+ padding: 14px 0;
+ border-bottom: 1px solid #f5f5f5;
+}
+
+.card-list-field-row:last-child {
+ border-bottom: none;
+}
+
+/* Label column - fixed width, uppercase */
+.card-list-field-label {
+ width: 120px;
+ flex-shrink: 0;
+ font-size: 12px;
+ font-weight: 500;
+ color: rgba(0, 0, 0, 0.55);
+ text-transform: uppercase;
+ letter-spacing: 0.5px;
+}
+
+/* Value column with icon */
+.card-list-field-value {
+ font-size: 14px;
+ color: rgba(0, 0, 0, 0.85);
+}
+
+/* Small icons (anticons, meta icons) get same width as connector icons */
+.card-list-field-value > .anticon,
+.card-list-field-value > .card-list-meta-icon {
+ width: 32px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ color: rgba(0, 0, 0, 0.55);
+}
+
+/* Connector text with instance name and type subtext */
+.card-list-field-text {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+
+.card-list-field-instance-name {
+ font-size: 14px;
+ font-weight: 500;
+ color: rgba(0, 0, 0, 0.85);
+}
+
+.card-list-field-subtext {
+ font-size: 11px;
+ color: rgba(0, 0, 0, 0.55);
+}
+
+/* Footer row - inline items */
+.card-list-footer-row {
+ padding: 14px 16px 0px 16px;
+ font-size: 14px;
+ color: rgba(0, 0, 0, 0.85);
+ border-top: 1px solid #f0f0f0;
+ background: #fafafa;
+}
+
+/* Footer icons - same width treatment as field icons */
+.card-list-footer-item > .anticon {
+ width: 32px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ flex-shrink: 0;
+ color: rgba(0, 0, 0, 0.55);
+}
+
+.card-list-footer-label {
+ width: 80px;
+ flex-shrink: 0;
+ font-size: 12px;
+ font-weight: 500;
+ color: rgba(0, 0, 0, 0.55);
+ text-transform: uppercase;
+ letter-spacing: 0.3px;
+}
+
+/* API Endpoint wrapper - grey background like footer */
+.card-list-endpoint-wrapper {
+ padding: 16px;
+ background: #fafafa;
+ border-radius: 0 0 8px 8px;
+}
+
+/* API Endpoint row - antd Card provides border/bg/radius */
+.card-list-endpoint-row.ant-card {
+ border-color: #e8e8e8;
+ border-radius: 6px;
+}
+
+.card-list-endpoint-row.ant-card .ant-card-body {
+ padding: 12px 16px;
+}
+
+.card-list-endpoint-row .card-list-field-label {
+ width: auto;
+ min-width: 100px;
+}
+
+.card-list-endpoint-value {
+ flex: 1;
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.card-list-endpoint-value a,
+.card-list-endpoint-value .ant-typography-link {
+ color: rgba(0, 0, 0, 0.85);
+ text-decoration: none;
+ font-size: 13px;
+ font-family: monospace;
+}
+
+.card-list-endpoint-value a:hover,
+.card-list-endpoint-value .ant-typography-link:hover {
+ color: rgba(0, 0, 0, 0.85);
+}
+
+/* Kebab menu button - supports both native button and AntD Button */
+.card-kebab-menu,
+.card-kebab-menu.ant-btn {
+ display: inline-flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 18px;
+ color: rgba(0, 0, 0, 0.65);
+ cursor: pointer;
+ padding: 4px;
+ border-radius: 4px;
+ transition: all 0.2s ease;
+ background: none;
+ border: none;
+ outline: none;
+ height: auto;
+ width: auto;
+}
+
+.card-kebab-menu:hover,
+.card-kebab-menu.ant-btn:hover {
+ background: rgba(0, 0, 0, 0.04);
+ color: rgba(0, 0, 0, 0.85);
+}
+
+.card-kebab-menu:focus-visible,
+.card-kebab-menu.ant-btn:focus-visible {
+ outline: 2px solid #1890ff;
+ outline-offset: 2px;
+}
+
+/* Workflow link in row layout */
+.card-list-workflow-link-row {
+ font-size: 14px;
+ color: rgba(0, 0, 0, 0.85);
+ text-decoration: none;
+ display: inline-flex;
+ align-items: center;
+ gap: 4px;
+ transition: color 0.2s ease;
+}
+
+.card-list-workflow-link-row:hover {
+ color: #1677ff;
+}
+
+.card-list-workflow-link-row .anticon {
+ font-size: 11px;
+ color: rgba(0, 0, 0, 0.55);
+}
+
+/* Responsive adjustments for row layout */
+@media (max-width: 768px) {
+ .card-list-header-row {
+ flex-wrap: wrap;
+ gap: 12px;
+ }
+
+ .card-list-field-label {
+ width: 100px;
+ font-size: 11px;
+ }
+
+ .card-list-footer-row {
+ flex-wrap: wrap;
+ gap: 16px;
+ }
+
+ .card-list-endpoint-wrapper {
+ padding: 12px;
+ }
+
+ .card-list-endpoint-row.ant-card .ant-card-body {
+ padding: 8px 12px;
+ }
+}
+
+@media (max-width: 576px) {
+ .card-list-field-row {
+ flex-direction: column;
+ align-items: flex-start;
+ gap: 8px;
+ }
+
+ .card-list-field-label {
+ width: auto;
+ }
+}
diff --git a/frontend/src/components/widgets/card-grid-view/CardGridView.jsx b/frontend/src/components/widgets/card-grid-view/CardGridView.jsx
new file mode 100644
index 000000000..703f83edd
--- /dev/null
+++ b/frontend/src/components/widgets/card-grid-view/CardGridView.jsx
@@ -0,0 +1,202 @@
+import { Col, Empty, Flex, Pagination, Row } from "antd";
+import PropTypes from "prop-types";
+
+import { CardItem } from "./CardItem.jsx";
+import { LoadingSkeleton } from "./LoadingSkeleton.jsx";
+import "./CardGridView.css";
+
+/**
+ * A reusable card-based grid layout component for entity listings
+ *
+ * @param {Object} props - Component props
+ * @param {Array} props.data - Array of data items to display
+ * @param {Object} props.cardConfig - Configuration object for card rendering
+ * @param {Function} props.onCardClick - Click handler for card interactions
+ * @param {boolean} props.loading - Loading state indicator
+ * @param {React.ReactNode} props.emptyState - Custom empty state component
+ * @param {Object} props.gridConfig - Responsive grid layout configuration
+ * @param {string} props.className - Additional CSS class name
+ * @param {Function} props.rowKey - Function to get unique key for each item
+ * @param {boolean} props.listMode - When true, renders cards as full-width list items
+ * @param {string} props.forceExpandedId - ID of item to keep expanded (e.g., when modal is open)
+ * @param {string} props.scrollToId - ID of item to scroll to (without forcing expansion)
+ * @return {JSX.Element} The rendered card grid component
+ *
+ * @example
+ * <CardGridView
+ * data={pipelines}
+ * cardConfig={pipelineCardConfig}
+ * loading={isLoading}
+ * onCardClick={(item) => navigate(`/pipeline/${item.id}`)}
+ * />
+ */
+function CardGridView({
+ data,
+ cardConfig,
+ onCardClick,
+ loading = false,
+ emptyState,
+ gridConfig,
+ className = "",
+ rowKey,
+ listMode = false,
+ forceExpandedId = null,
+ scrollToId = null,
+ pagination = null,
+}) {
+ // Default grid configuration
+ const defaultGridConfig = {
+ gutter: [16, 16],
+ columns: {
+ xs: 24, // 1 column on mobile
+ sm: 24, // 1 column on small tablets
+ md: 12, // 2 columns on tablets
+ lg: 12, // 2 columns on small desktops
+ xl: 8, // 3 columns on desktops
+ xxl: 8, // 3 columns on large screens
+ },
+ };
+
+ // List mode forces single column layout
+ const listModeColumns = {
+ xs: 24,
+ sm: 24,
+ md: 24,
+ lg: 24,
+ xl: 24,
+ xxl: 24,
+ };
+
+ const finalGridConfig = {
+ gutter: listMode ? [16, 8] : gridConfig?.gutter || defaultGridConfig.gutter,
+ columns: listMode
+ ? listModeColumns
+ : { ...defaultGridConfig.columns, ...gridConfig?.columns },
+ };
+
+ // Get unique key for each item
+ const getRowKey = (item, index) => {
+ if (rowKey) {
+ return typeof rowKey === "function" ? rowKey(item) : item[rowKey];
+ }
+ return item.id || item.key || index;
+ };
+
+ // Render loading state
+ if (loading) {
+ return (
+ <div className={`card-grid-view ${className}`}>
+ <LoadingSkeleton gridConfig={finalGridConfig} count={6} />
+ </div>
+ );
+ }
+
+ // Render empty state
+ if (!data || data.length === 0) {
+ return (
+ <div className={`card-grid-view card-grid-empty ${className}`}>
+ {emptyState || <Empty description="No items found" />}
+ </div>
+ );
+ }
+
+ const { columns, gutter } = finalGridConfig;
+
+ const showPagination = pagination && pagination.total > pagination.pageSize;
+
+ return (
+ <div className={`card-grid-view ${className}`}>
+ <Row gutter={gutter} className="card-grid-row">
+ {data.map((item, index) => (
+ <Col
+ key={getRowKey(item, index)}
+ xs={columns.xs}
+ sm={columns.sm}
+ md={columns.md}
+ lg={columns.lg}
+ xl={columns.xl}
+ xxl={columns.xxl}
+ >
+ <CardItem
+ item={item}
+ config={cardConfig}
+ onClick={onCardClick}
+ listMode={listMode}
+ forceExpanded={
+ forceExpandedId && String(forceExpandedId) === String(item.id)
+ }
+ scrollIntoView={
+ scrollToId && String(scrollToId) === String(item.id)
+ }
+ />
+ </Col>
+ ))}
+ </Row>
+
+ {showPagination && (
+ <Flex justify="flex-end" className="card-grid-pagination">
+ <Pagination
+ current={pagination.current}
+ pageSize={pagination.pageSize}
+ total={pagination.total}
+ onChange={pagination.onChange}
+ showSizeChanger
+ pageSizeOptions={["10", "20", "50"]}
+ showTotal={(total, range) =>
+ `${range[0]}-${range[1]} of ${total} items`
+ }
+ />
+ </Flex>
+ )}
+ </div>
+ );
+}
+
+CardGridView.propTypes = {
+ data: PropTypes.array.isRequired,
+ cardConfig: PropTypes.shape({
+ header: PropTypes.shape({
+ title: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired,
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
+ actions: PropTypes.array,
+ }).isRequired,
+ sections: PropTypes.arrayOf(
+ PropTypes.shape({
+ type: PropTypes.oneOf(["metadata", "stats", "status", "custom"]),
+ fields: PropTypes.array.isRequired,
+ layout: PropTypes.oneOf(["horizontal", "vertical", "grid"]),
+ className: PropTypes.string,
+ }),
+ ),
+ expandable: PropTypes.bool,
+ expandedContent: PropTypes.func,
+ listContent: PropTypes.func,
+ }).isRequired,
+ onCardClick: PropTypes.func,
+ loading: PropTypes.bool,
+ emptyState: PropTypes.node,
+ gridConfig: PropTypes.shape({
+ gutter: PropTypes.arrayOf(PropTypes.number),
+ columns: PropTypes.shape({
+ xs: PropTypes.number,
+ sm: PropTypes.number,
+ md: PropTypes.number,
+ lg: PropTypes.number,
+ xl: PropTypes.number,
+ xxl: PropTypes.number,
+ }),
+ }),
+ className: PropTypes.string,
+ rowKey: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
+ listMode: PropTypes.bool,
+ forceExpandedId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
+ scrollToId: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
+ pagination: PropTypes.shape({
+ current: PropTypes.number,
+ pageSize: PropTypes.number,
+ total: PropTypes.number,
+ onChange: PropTypes.func,
+ }),
+};
+
+export { CardGridView };
diff --git a/frontend/src/components/widgets/card-grid-view/CardItem.jsx b/frontend/src/components/widgets/card-grid-view/CardItem.jsx
new file mode 100644
index 000000000..d8a2b83fb
--- /dev/null
+++ b/frontend/src/components/widgets/card-grid-view/CardItem.jsx
@@ -0,0 +1,373 @@
+import { DownOutlined, UpOutlined } from "@ant-design/icons";
+import { Button, Card, Flex, Space, Tooltip, Typography } from "antd";
+import PropTypes from "prop-types";
+import { memo, useCallback, useEffect, useRef, useState } from "react";
+
+/**
+ * Individual card item renderer for CardGridView
+ *
+ * @param {Object} props - Component props
+ * @param {Object} props.item - Data item to render
+ * @param {Object} props.config - Card configuration
+ * @param {Function} props.onClick - Click handler for the card
+ * @param {boolean} props.listMode - Whether to render in list mode
+ * @param {boolean} props.forceExpanded - Force card to stay expanded (e.g., when modal is open)
+ * @param {boolean} props.scrollIntoView - Scroll to this card (without forcing expansion)
+ * @return {JSX.Element} The rendered card item
+ */
+function CardItem({
+ item,
+ config,
+ onClick,
+ listMode = false,
+ forceExpanded = false,
+ scrollIntoView = false,
+}) {
+ const [expanded, setExpanded] = useState(false);
+ const cardRef = useRef(null);
+
+ // Auto-scroll to center when card is expanded OR scrollIntoView is requested
+ const isExpanded = expanded || forceExpanded;
+ const shouldScroll = isExpanded || scrollIntoView;
+ useEffect(() => {
+ let timerId;
+ if (shouldScroll && cardRef.current) {
+ timerId = setTimeout(() => {
+ cardRef.current?.scrollIntoView({
+ behavior: "smooth",
+ block: "center",
+ inline: "nearest",
+ });
+ }, 50);
+ }
+ return () => clearTimeout(timerId);
+ }, [shouldScroll]);
+
+ const handleCardClick = useCallback(
+ (e) => {
+ // Don't trigger card click if clicking on an interactive element
+ if (
+ e.target.closest("button") ||
+ e.target.closest(".ant-switch") ||
+ e.target.closest(".ant-dropdown-trigger") ||
+ e.target.closest("a") ||
+ e.target.closest(".status-badge-clickable") ||
+ e.target.closest(".action-icon-btn") ||
+ e.target.closest(".ant-popover") ||
+ e.target.closest(".card-action-wrapper")
+ ) {
+ return;
+ }
+
+ if (onClick) {
+ onClick(item);
+ }
+
+ // Toggle on card click (both grid and list mode)
+ if (config.expandable) {
+ setExpanded((prev) => !prev);
+ }
+ },
+ [item, config.expandable, onClick],
+ );
+
+ // Toggle handler for chevron expansion
+ const handleToggleExpand = useCallback(
+ (e) => {
+ e.stopPropagation();
+ if (config.expandable) {
+ setExpanded((prev) => !prev);
+ }
+ },
+ [config.expandable],
+ );
+
+ // Resolve value from config - handles both string keys and functions
+ const resolveValue = (valueOrFn, defaultValue = "") => {
+ if (typeof valueOrFn === "function") {
+ return valueOrFn(item);
+ }
+ if (typeof valueOrFn === "string") {
+ return item[valueOrFn] ?? defaultValue;
+ }
+ return valueOrFn ?? defaultValue;
+ };
+
+ // Check if field should be visible
+ const isFieldVisible = (field) => {
+ if (field.visible === undefined) {
+ return true;
+ }
+ if (typeof field.visible === "function") {
+ return field.visible(item);
+ }
+ return field.visible;
+ };
+
+ // Render a single field
+ const renderField = (field) => {
+ if (!isFieldVisible(field)) {
+ return null;
+ }
+
+ const value = item[field.key];
+
+ // Custom renderer takes priority
+ if (field.render) {
+ return (
+ <Flex
+ key={field.key}
+ align="center"
+ gap={8}
+ className={`card-field ${field.className || ""}`}
+ >
+ {field.icon && <span className="card-field-icon">{field.icon}</span>}
+ <Flex vertical className="card-field-content">
+ {field.render(value, item)}
+ </Flex>
+ </Flex>
+ );
+ }
+
+ // Default field rendering
+ return (
+ <Flex
+ key={field.key}
+ align="center"
+ gap={8}
+ className={`card-field ${field.className || ""}`}
+ >
+ {field.icon && <span className="card-field-icon">{field.icon}</span>}
+ <Flex vertical className="card-field-content">
+ {field.label && (
+ <Typography.Text type="secondary" className="card-field-label">
+ {field.label}
+ </Typography.Text>
+ )}
+ <Typography.Text className="card-field-value">
+ {value ?? "-"}
+ </Typography.Text>
+ </Flex>
+ </Flex>
+ );
+ };
+
+ // Render a section
+ const renderSection = (section, index) => {
+ const visibleFields = section.fields.filter(isFieldVisible);
+ if (visibleFields.length === 0) {
+ return null;
+ }
+
+ const layout = section.layout || "horizontal";
+ const className = `card-section card-section-${layout} ${section.className || ""}`;
+
+ // Grid layout needs CSS grid (auto-fit), can't use Flex
+ if (layout === "grid") {
+ return (
+ <div key={index} className={className}>
+ {visibleFields.map(renderField)}
+ </div>
+ );
+ }
+
+ return (
+ <Flex
+ key={index}
+ vertical={layout === "vertical"}
+ wrap={layout === "horizontal"}
+ gap={layout === "vertical" ? 8 : 16}
+ align={layout === "horizontal" ? "center" : undefined}
+ className={className}
+ >
+ {visibleFields.map(renderField)}
+ </Flex>
+ );
+ };
+
+ // Render card header actions
+ const renderActions = () => {
+ if (!config.header?.actions?.length) {
+ return null;
+ }
+
+ return (
+ <Space size={8} className="card-item-actions">
+ {config.header.actions.map((action) => {
+ if (action.visible !== undefined) {
+ const isVisible =
+ typeof action.visible === "function"
+ ? action.visible(item)
+ : action.visible;
+ if (!isVisible) {
+ return null;
+ }
+ }
+
+ // Custom render for action
+ if (action.render) {
+ return (
+ <span key={action.key} className="card-action-wrapper">
+ {action.render(item)}
+ </span>
+ );
+ }
+
+ return null;
+ })}
+ </Space>
+ );
+ };
+
+ // Get card title
+ const title = resolveValue(config.header?.title, "Untitled");
+ const subtitle = config.header?.subtitle
+ ? resolveValue(config.header.subtitle)
+ : null;
+
+ // Render chevron toggle for list mode
+ const renderExpandChevron = () => {
+ if (!config.expandable || !config.expandedContent) {
+ return null;
+ }
+
+ return (
+ <Button
+ type="text"
+ className="card-expand-chevron"
+ icon={isExpanded ? <UpOutlined /> : <DownOutlined />}
+ onClick={handleToggleExpand}
+ />
+ );
+ };
+
+ // List mode rendering
+ if (listMode && config.listContent) {
+ // Non-expandable list mode - no expand/collapse behavior
+ if (!config.expandable) {
+ return (
+ <Card
+ ref={cardRef}
+ className="card-grid-item card-list-mode"
+ hoverable={!!onClick}
+ onClick={handleCardClick}
+ >
+ {/* Custom list content - all content visible, no expanded section */}
+ {config.listContent(item, {
+ renderActions,
+ })}
+ </Card>
+ );
+ }
+
+ // Expandable list mode - original behavior
+ return (
+ <Card
+ ref={cardRef}
+ className="card-grid-item card-list-mode"
+ hoverable={!!onClick}
+ onClick={handleCardClick}
+ >
+ {/* Custom list content */}
+ {config.listContent(item, {
+ expanded: isExpanded,
+ renderActions,
+ renderExpandChevron,
+ })}
+
+ {/* Expanded Content - always rendered, visibility controlled by CSS */}
+ {config.expandedContent && (
+ <div className={`card-list-expanded ${isExpanded ? "expanded" : ""}`}>
+ {config.expandedContent(item)}
+ </div>
+ )}
+ </Card>
+ );
+ }
+
+ return (
+ <Card
+ ref={cardRef}
+ className="card-grid-item"
+ hoverable={!!onClick || config.expandable}
+ onClick={handleCardClick}
+ >
+ {/* Card Header */}
+ <Flex
+ justify="space-between"
+ align="flex-start"
+ gap={12}
+ className="card-item-header"
+ >
+ <Flex vertical className="card-item-title-section">
+ <Tooltip title={title}>
+ <Typography.Text className="card-item-title" strong>
+ {title}
+ </Typography.Text>
+ </Tooltip>
+ {subtitle && (
+ <Typography.Text type="secondary" className="card-item-subtitle">
+ {subtitle}
+ </Typography.Text>
+ )}
+ </Flex>
+ {renderActions()}
+ </Flex>
+
+ {/* Card Sections */}
+ {config.sections?.map(renderSection)}
+
+ {/* Expanded Content */}
+ {isExpanded && config.expandedContent && (
+ <div className="card-expanded-content">
+ {config.expandedContent(item)}
+ </div>
+ )}
+ </Card>
+ );
+}
+
+CardItem.propTypes = {
+ item: PropTypes.object.isRequired,
+ config: PropTypes.shape({
+ header: PropTypes.shape({
+ title: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired,
+ subtitle: PropTypes.oneOfType([PropTypes.string, PropTypes.func]),
+ actions: PropTypes.arrayOf(
+ PropTypes.shape({
+ key: PropTypes.string.isRequired,
+ render: PropTypes.func,
+ visible: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
+ }),
+ ),
+ }).isRequired,
+ sections: PropTypes.arrayOf(
+ PropTypes.shape({
+ type: PropTypes.oneOf(["metadata", "stats", "status", "custom"]),
+ fields: PropTypes.arrayOf(
+ PropTypes.shape({
+ key: PropTypes.string.isRequired,
+ label: PropTypes.string,
+ render: PropTypes.func,
+ icon: PropTypes.node,
+ visible: PropTypes.oneOfType([PropTypes.bool, PropTypes.func]),
+ className: PropTypes.string,
+ }),
+ ).isRequired,
+ layout: PropTypes.oneOf(["horizontal", "vertical", "grid"]),
+ className: PropTypes.string,
+ }),
+ ),
+ expandable: PropTypes.bool,
+ expandedContent: PropTypes.func,
+ listContent: PropTypes.func,
+ }).isRequired,
+ onClick: PropTypes.func,
+ listMode: PropTypes.bool,
+ forceExpanded: PropTypes.bool,
+ scrollIntoView: PropTypes.bool,
+};
+
+// Wrap with memo to prevent unnecessary re-renders when parent array reference changes
+const MemoizedCardItem = memo(CardItem);
+export { MemoizedCardItem as CardItem };
diff --git a/frontend/src/components/widgets/card-grid-view/LoadingSkeleton.jsx b/frontend/src/components/widgets/card-grid-view/LoadingSkeleton.jsx
new file mode 100644
index 000000000..bad03ffd4
--- /dev/null
+++ b/frontend/src/components/widgets/card-grid-view/LoadingSkeleton.jsx
@@ -0,0 +1,66 @@
+import { Card, Col, Row, Skeleton } from "antd";
+import PropTypes from "prop-types";
+import { useMemo } from "react";
+
+/**
+ * Loading skeleton that matches the card grid layout
+ *
+ * @param {Object} props - Component props
+ * @param {Object} props.gridConfig - Grid configuration for responsive columns
+ * @param {number} props.count - Number of skeleton cards to display
+ * @return {JSX.Element} The rendered loading skeleton grid
+ */
+function LoadingSkeleton({ gridConfig, count = 6 }) {
+ const defaultColumns = {
+ xs: 24,
+ sm: 24,
+ md: 12,
+ lg: 12,
+ xl: 8,
+ xxl: 8,
+ };
+
+ const columns = gridConfig?.columns || defaultColumns;
+ const gutter = gridConfig?.gutter || [16, 16];
+ const skeletonIds = useMemo(
+ () => Array.from({ length: count }, (_, i) => `skeleton-${i}`),
+ [count],
+ );
+
+ return (
+ <Row gutter={gutter} className="card-skeleton-row">
+ {skeletonIds.map((id) => (
+ <Col
+ key={id}
+ xs={columns.xs}
+ sm={columns.sm}
+ md={columns.md}
+ lg={columns.lg}
+ xl={columns.xl}
+ xxl={columns.xxl}
+ >
+ <Card className="card-skeleton-item">
+ <Skeleton active paragraph={{ rows: 3 }} />
+ </Card>
+ </Col>
+ ))}
+ </Row>
+ );
+}
+
+LoadingSkeleton.propTypes = {
+ gridConfig: PropTypes.shape({
+ gutter: PropTypes.arrayOf(PropTypes.number),
+ columns: PropTypes.shape({
+ xs: PropTypes.number,
+ sm: PropTypes.number,
+ md: PropTypes.number,
+ lg: PropTypes.number,
+ xl: PropTypes.number,
+ xxl: PropTypes.number,
+ }),
+ }),
+ count: PropTypes.number,
+};
+
+export { LoadingSkeleton };
diff --git a/frontend/src/components/widgets/card-grid-view/index.js b/frontend/src/components/widgets/card-grid-view/index.js
new file mode 100644
index 000000000..7331122d2
--- /dev/null
+++ b/frontend/src/components/widgets/card-grid-view/index.js
@@ -0,0 +1,3 @@
+export { CardGridView } from "./CardGridView.jsx";
+export { CardItem } from "./CardItem.jsx";
+export { LoadingSkeleton } from "./LoadingSkeleton.jsx";
diff --git a/frontend/src/helpers/GetStaticData.js b/frontend/src/helpers/GetStaticData.js
index 1d06e8367..c9e309989 100644
--- a/frontend/src/helpers/GetStaticData.js
+++ b/frontend/src/helpers/GetStaticData.js
@@ -548,6 +548,35 @@ const displayURL = (text) => {
return getBaseUrl() + "/" + text;
};
+// Helper to strip trailing slashes without regex (avoids ReDoS concerns)
+const stripTrailingSlashes = (str) => {
+ let end = str.length;
+ while (end > 0 && str[end - 1] === "/") {
+ end--;
+ }
+ return str.slice(0, end);
+};
+
+const shortenApiEndpoint = (url) => {
+ if (typeof url !== "string" || url.trim() === "") {
+ return "";
+ }
+ try {
+ // Parse URL to strip query/hash and get clean pathname
+ const parsed = new URL(url, globalThis.location.origin);
+ const path = stripTrailingSlashes(parsed.pathname);
+ const parts = path.split("/").filter(Boolean);
+ const suffix = parts[parts.length - 1] || "";
+ return suffix ? `.../${suffix}` : ".../";
+ } catch {
+ // Fallback for invalid URLs - strip query/hash manually
+ const path = stripTrailingSlashes(url.split("?")[0].split("#")[0]);
+ const parts = path.split("/").filter(Boolean);
+ const suffix = parts[parts.length - 1] || "";
+ return suffix ? `.../${suffix}` : ".../";
+ }
+};
+
const formatNumberWithCommas = (number) => {
if (!number && number !== 0) {
return null;
@@ -754,6 +783,7 @@ export {
pollForCompletion,
getDocIdFromKey,
displayURL,
+ shortenApiEndpoint,
formatNumberWithCommas,
isValidJsonKey,
PROMPT_RUN_TYPES,
diff --git a/frontend/src/helpers/dateFormatter.js b/frontend/src/helpers/dateFormatter.js
new file mode 100644
index 000000000..237479cf3
--- /dev/null
+++ b/frontend/src/helpers/dateFormatter.js
@@ -0,0 +1,150 @@
+import {
+ differenceInHours,
+ differenceInMinutes,
+ format,
+ formatDistanceToNow,
+ isThisWeek,
+ isToday,
+ isValid,
+ isYesterday,
+ parseISO,
+} from "date-fns";
+
+/**
+ * Format options for the date formatter
+ * @typedef {Object} DateFormatOptions
+ * @property {boolean} [includeTime=false] - Include time in the output
+ * @property {boolean} [relative=false] - Use relative formatting for recent dates
+ * @property {number} [relativeThreshold=24] - Hours threshold for relative formatting
+ */
+
+/**
+ * Format an ISO date string to a compact, human-readable format
+ *
+ * @param {string} isoDate - ISO 8601 date string
+ * @param {DateFormatOptions} [options={}] - Formatting options
+ * @return {string} Formatted date string
+ *
+ * @example
+ * // Standard format
+ * formatCompactDate("2024-01-12T14:30:00Z") // "12 Jan 2024"
+ *
+ * @example
+ * // With time
+ * formatCompactDate("2024-01-12T14:30:00Z", { includeTime: true }) // "12 Jan 2024 14:30"
+ *
+ * @example
+ * // Relative (if within threshold)
+ * formatCompactDate(recentDate, { relative: true }) // "2 hours ago"
+ */
+function formatCompactDate(isoDate, options = {}) {
+ const {
+ includeTime = false,
+ relative = false,
+ relativeThreshold = 24,
+ } = options;
+
+ if (!isoDate) {
+ return "-";
+ }
+
+ let date;
+ try {
+ date = typeof isoDate === "string" ? parseISO(isoDate) : new Date(isoDate);
+ if (!isValid(date)) {
+ return isoDate; // Return raw value if invalid
+ }
+ } catch {
+ return isoDate; // Return raw value on parse error
+ }
+
+ const now = new Date();
+
+ // Handle relative formatting for recent dates
+ if (relative) {
+ const hoursAgo = differenceInHours(now, date);
+ const minutesAgo = differenceInMinutes(now, date);
+
+ // "Just now" for < 1 minute
+ if (minutesAgo < 1) {
+ return "Just now";
+ }
+
+ // Relative format within threshold
+ if (hoursAgo < relativeThreshold) {
+ return formatDistanceToNow(date, { addSuffix: true });
+ }
+
+ // Yesterday with time
+ if (isYesterday(date)) {
+ return `Yesterday ${format(date, "HH:mm")}`;
+ }
+
+ // This week - show day name with time
+ if (isThisWeek(date, { weekStartsOn: 1 })) {
+ return format(date, "EEEE HH:mm");
+ }
+ }
+
+ // Standard formatting
+ if (includeTime) {
+ return format(date, "dd MMM yyyy HH:mm");
+ }
+
+ return format(date, "dd MMM yyyy");
+}
+
+/**
+ * Format a date to show relative time if recent, absolute otherwise
+ *
+ * @param {string} isoDate - ISO 8601 date string
+ * @return {string} Formatted date string with smart relative/absolute switching
+ */
+function formatSmartDate(isoDate) {
+ return formatCompactDate(isoDate, { relative: true, includeTime: true });
+}
+
+/**
+ * Format a date for display in tooltips (full date and time)
+ *
+ * @param {string} isoDate - ISO 8601 date string
+ * @return {string} Full formatted date string
+ */
+function formatFullDate(isoDate) {
+ if (!isoDate) {
+ return "-";
+ }
+
+ let date;
+ try {
+ date = typeof isoDate === "string" ? parseISO(isoDate) : new Date(isoDate);
+ if (!isValid(date)) {
+ return isoDate;
+ }
+ } catch {
+ return isoDate;
+ }
+
+ return format(date, "EEEE, dd MMMM yyyy 'at' HH:mm:ss");
+}
+
+/**
+ * Check if a date is today
+ *
+ * @param {string} isoDate - ISO 8601 date string
+ * @return {boolean} True if the date is today
+ */
+function checkIsToday(isoDate) {
+ if (!isoDate) {
+ return false;
+ }
+ try {
+ const date =
+ typeof isoDate === "string" ? parseISO(isoDate) : new Date(isoDate);
+ return isValid(date) && isToday(date);
+ } catch {
+ return false;
+ }
+}
+
+export { formatCompactDate, formatSmartDate, formatFullDate, checkIsToday };
diff --git a/frontend/src/helpers/pdfWorkerConfig.js b/frontend/src/helpers/pdfWorkerConfig.js
index 30322d7a7..e3f34852e 100644
--- a/frontend/src/helpers/pdfWorkerConfig.js
+++ b/frontend/src/helpers/pdfWorkerConfig.js
@@ -1,3 +1,4 @@
// Load the worker file from the installed pdfjs-dist package
// The ?url suffix tells Webpack 5 to return the URL of the asset
+// eslint-disable-next-line import/no-unresolved
export { default as PDF_WORKER_URL } from "pdfjs-dist/build/pdf.worker.min.js?url";
diff --git a/frontend/src/hooks/useExecutionLogs.js b/frontend/src/hooks/useExecutionLogs.js
new file mode 100644
index 000000000..f183e8f31
--- /dev/null
+++ b/frontend/src/hooks/useExecutionLogs.js
@@ -0,0 +1,78 @@
+import { useRef, useState } from "react";
+
+import { fetchExecutionLogs } from "../components/pipelines-or-deployments/log-modal/fetchExecutionLogs";
+
+/**
+ * Shared hook for execution logs modal state and fetching.
+ * Tracks the selected item via ref so pagination works after the initial fetch.
+ *
+ * @param {Object} options
+ * @param {Function} options.axiosPrivate
+ * @param {Function} options.handleException
+ * @param {Object} options.sessionDetails
+ * @param {Function} options.setAlertDetails
+ * @return {Object} Logs modal state and handlers
+ */
+function useExecutionLogs({
+ axiosPrivate,
+ handleException,
+ sessionDetails,
+ setAlertDetails,
+}) {
+ const [openLogsModal, setOpenLogsModal] = useState(false);
+ const [executionLogs, setExecutionLogs] = useState([]);
+ const [executionLogsTotalCount, setExecutionLogsTotalCount] = useState(0);
+ const [isFetchingLogs, setIsFetchingLogs] = useState(false);
+
+ const logsItemRef = useRef(null);
+
+ const handleFetchLogs = (page, pageSize) => {
+ fetchExecutionLogs(
+ axiosPrivate,
+ handleException,
+ sessionDetails,
+ logsItemRef.current,
+ setExecutionLogs,
+ setExecutionLogsTotalCount,
+ setAlertDetails,
+ page,
+ pageSize,
+ setIsFetchingLogs,
+ );
+ };
+
+ /**
+ * Open the logs modal for a given item and trigger the initial fetch.
+ * @param {Object} item - the pipeline/deployment to view logs for
+ * @param {Function} setSelectedItem - parent's selected-item setter
+ */
+ const handleViewLogs = (item, setSelectedItem) => {
+ setSelectedItem(item);
+ logsItemRef.current = item;
+ setOpenLogsModal(true);
+ fetchExecutionLogs(
+ axiosPrivate,
+ handleException,
+ sessionDetails,
+ item,
+ setExecutionLogs,
+ setExecutionLogsTotalCount,
+ setAlertDetails,
+ 1,
+ 10,
+ setIsFetchingLogs,
+ );
+ };
+
+ return {
+ openLogsModal,
+ setOpenLogsModal,
+ executionLogs,
+ executionLogsTotalCount,
+ isFetchingLogs,
+ handleFetchLogs,
+ handleViewLogs,
+ };
+}
+
+export { useExecutionLogs };
diff --git a/frontend/src/hooks/usePaginatedList.js b/frontend/src/hooks/usePaginatedList.js
new file mode 100644
index 000000000..ce45ffa3f
--- /dev/null
+++ b/frontend/src/hooks/usePaginatedList.js
@@ -0,0 +1,44 @@
+import { useRef, useState } from "react";
+
+/**
+ * Shared hook for paginated list state and handlers.
+ * Uses a ref internally to avoid stale closure issues with fetchData.
+ *
+ * @param {Object} options
+ * @param {Function} options.fetchData - fn(page, pageSize, search) to fetch data
+ * @param {number} [options.defaultPageSize=10]
+ * @return {Object} Pagination state and handlers
+ */
+function usePaginatedList({ fetchData, defaultPageSize = 10 }) {
+ const [pagination, setPagination] = useState({
+ current: 1,
+ pageSize: defaultPageSize,
+ total: 0,
+ });
+ const [searchTerm, setSearchTerm] = useState("");
+
+ const fetchRef = useRef(fetchData);
+ fetchRef.current = fetchData;
+
+ const handlePaginationChange = (page, pageSize) => {
+ const newPage = pageSize === pagination.pageSize ? page : 1;
+ fetchRef.current?.(newPage, pageSize, searchTerm);
+ };
+
+ const handleSearch = (searchText) => {
+ const term = searchText?.trim() || "";
+ setSearchTerm(term);
+ fetchRef.current?.(1, pagination.pageSize, term);
+ };
+
+ return {
+ pagination,
+ setPagination,
+ searchTerm,
+ setSearchTerm,
+ handlePaginationChange,
+ handleSearch,
+ };
+}
+
+export { usePaginatedList };
diff --git a/frontend/src/hooks/usePostHogEvents.js b/frontend/src/hooks/usePostHogEvents.js
index d53bfed8b..6eae45b00 100644
--- a/frontend/src/hooks/usePostHogEvents.js
+++ b/frontend/src/hooks/usePostHogEvents.js
@@ -80,8 +80,12 @@ const usePostHogEvents = () => {
posthog.identify(distinctId, optionalParams);
};
- const setPostHogCustomEvent = (distinctId, optionalParams) => {
- posthog.capture(distinctId, optionalParams);
+ const setPostHogCustomEvent = (eventName, properties) => {
+ try {
+ posthog.capture(eventName, properties);
+ } catch {
+ // PostHog tracking is non-critical, safe to ignore
+ }
};
return {
diff --git a/frontend/src/hooks/useScrollRestoration.js b/frontend/src/hooks/useScrollRestoration.js
new file mode 100644
index 000000000..6d4bc4e66
--- /dev/null
+++ b/frontend/src/hooks/useScrollRestoration.js
@@ -0,0 +1,59 @@
+import { useEffect, useRef, useState } from "react";
+
+/**
+ * Shared hook for scroll restoration when navigating back to a list page.
+ * Restores pagination, search, and scroll position from location.state.
+ *
+ * @param {Object} options
+ * @param {Object} options.location - react-router location object
+ * @param {Function} options.setSearchTerm - from usePaginatedList
+ * @param {Function} options.setPagination - from usePaginatedList
+ * @param {Function} options.fetchData - fn(page, pageSize, search) to fetch data
+ * @return {Object} Scroll restoration state and helpers
+ */
+function useScrollRestoration({
+ location,
+ setSearchTerm,
+ setPagination,
+ fetchData,
+}) {
+ const [scrollRestoreId, setScrollRestoreId] = useState(null);
+ const pendingScrollIdRef = useRef(null);
+
+ const fetchRef = useRef(fetchData);
+ fetchRef.current = fetchData;
+
+ useEffect(() => {
+ if (location.state?.scrollToCardId) {
+ pendingScrollIdRef.current = location.state.scrollToCardId;
+
+ const { page, pageSize, searchTerm: savedSearch } = location.state;
+ const restoredPage = page || 1;
+ const restoredPageSize = pageSize || 10;
+ const restoredSearch = savedSearch || "";
+ setSearchTerm(restoredSearch);
+ setPagination((prev) => ({
+ ...prev,
+ current: restoredPage,
+ pageSize: restoredPageSize,
+ }));
+ fetchRef.current?.(restoredPage, restoredPageSize, restoredSearch);
+ }
+ }, [location.key]);
+
+ const activateScrollRestore = () => {
+ if (pendingScrollIdRef.current) {
+ setScrollRestoreId(pendingScrollIdRef.current);
+ pendingScrollIdRef.current = null;
+ setTimeout(() => setScrollRestoreId(null), 500);
+ }
+ };
+
+ const clearPendingScroll = () => {
+ pendingScrollIdRef.current = null;
+ };
+
+ return { scrollRestoreId, activateScrollRestore, clearPendingScroll };
+}
+
+export { useScrollRestoration };
diff --git a/frontend/src/hooks/useShareModal.js b/frontend/src/hooks/useShareModal.js
new file mode 100644
index 000000000..82d915474
--- /dev/null
+++ b/frontend/src/hooks/useShareModal.js
@@ -0,0 +1,106 @@
+import { useRef, useState } from "react";
+
+/**
+ * Shared hook for share modal state and logic.
+ * Handles fetching users, opening the modal, and applying share updates.
+ *
+ * @param {Object} options
+ * @param {Object} options.apiService - service with getAllUsers, getSharedUsers, updateSharing
+ * @param {Function} options.setSelectedItem - setter for the parent's selected item state
+ * @param {Function} options.setAlertDetails - from alert store
+ * @param {Function} options.handleException - exception handler
+ * @param {Function} options.refreshList - fn() to refresh the list after sharing
+ * @return {Object} Share modal state and handlers
+ */
+function useShareModal({
+ apiService,
+ setSelectedItem,
+ setAlertDetails,
+ handleException,
+ refreshList,
+}) {
+ const [openShareModal, setOpenShareModal] = useState(false);
+ const [allUsers, setAllUsers] = useState([]);
+ const [isLoadingShare, setIsLoadingShare] = useState(false);
+
+ const shareItemIdRef = useRef(null);
+ const refreshRef = useRef(refreshList);
+ refreshRef.current = refreshList;
+
+ const handleShare = async (item) => {
+ shareItemIdRef.current = item.id;
+ setIsLoadingShare(true);
+ try {
+ const [usersResponse, sharedUsersResponse] = await Promise.all([
+ apiService.getAllUsers(),
+ apiService.getSharedUsers(item.id),
+ ]);
+
+ let userList = [];
+ const responseData = usersResponse?.data;
+ if (Array.isArray(responseData)) {
+ userList = responseData.map((user) => ({
+ id: user.id,
+ email: user.email,
+ }));
+ } else if (responseData?.members && Array.isArray(responseData.members)) {
+ userList = responseData.members.map((member) => ({
+ id: member.id,
+ email: member.email,
+ }));
+ } else if (responseData?.users && Array.isArray(responseData.users)) {
+ userList = responseData.users.map((user) => ({
+ id: user.id,
+ email: user.email,
+ }));
+ }
+
+ const sharedUsersList = sharedUsersResponse.data?.shared_users || [];
+
+ setSelectedItem({
+ ...item,
+ shared_users: Array.isArray(sharedUsersList) ? sharedUsersList : [],
+ });
+ setAllUsers(userList);
+ setOpenShareModal(true);
+ } catch (err) {
+ setAlertDetails(
+ handleException(err, "Unable to fetch sharing information"),
+ );
+ setAllUsers([]);
+ } finally {
+ setIsLoadingShare(false);
+ }
+ };
+
+ const onShare = (sharedUsers, _, shareWithEveryone) => {
+ setIsLoadingShare(true);
+ apiService
+ .updateSharing(shareItemIdRef.current, sharedUsers, shareWithEveryone)
+ .then(() => {
+ setAlertDetails({
+ type: "success",
+ content: "Sharing permissions updated successfully",
+ });
+ setOpenShareModal(false);
+ refreshRef.current?.();
+ })
+ .catch((err) => {
+ setAlertDetails(handleException(err));
+ })
+ .finally(() => {
+ setIsLoadingShare(false);
+ });
+ };
+
+ return {
+ openShareModal,
+ setOpenShareModal,
+ allUsers,
+ isLoadingShare,
+ handleShare,
+ onShare,
+ };
+}
+
+export { useShareModal };
diff --git a/frontend/src/layouts/menu-layout/MenuLayout.jsx b/frontend/src/layouts/menu-layout/MenuLayout.jsx
index 280a43f90..52844ef10 100644
--- a/frontend/src/layouts/menu-layout/MenuLayout.jsx
+++ b/frontend/src/layouts/menu-layout/MenuLayout.jsx
@@ -35,7 +35,29 @@ function MenuLayout({ children }) {
<Button
size="small"
type="text"
- onClick={() => navigate(`/${sessionDetails.orgName}/workflows`)}
+ onClick={() => {
+ if (location.state?.from) {
+ const from = location.state.from;
+ const fromState =
+ typeof from === "object" && from.state ? from.state : {};
+ const mergedState = {
+ ...fromState,
+ ...(location.state?.scrollToCardId && {
+ scrollToCardId: location.state.scrollToCardId,
+ }),
+ };
+ const nextState = Object.keys(mergedState).length
+ ? mergedState
+ : undefined;
+ if (typeof from === "object") {
+ navigate({ ...from, state: nextState });
+ } else {
+ navigate(from, { state: nextState });
+ }
+ } else {
+ navigate(`/${sessionDetails.orgName}/workflows`);
+ }
+ }}
>
<ArrowLeftOutlined />
</Button>
diff --git a/frontend/vite.config.js b/frontend/vite.config.js
index 2ff54181e..40a66809d 100644
--- a/frontend/vite.config.js
+++ b/frontend/vite.config.js
@@ -44,7 +44,7 @@ function optionalPluginImports() {
},
load(id) {
if (id === EMPTY_MODULE_ID) {
- return "export default undefined;";
+ return "throw new Error('Optional plugin not available');";
}
return null;
},