From 2447a55e221faa27f2bf4edeea5861c689f8b16a Mon Sep 17 00:00:00 2001 From: Devanshu Rastogi Date: Mon, 7 Jul 2025 10:37:46 +0530 Subject: [PATCH] Fix: Workflow app crashes when user clicks on response node (#13217) * Added controller and service for fetching logs and nodes seperately * Add inifinte scroll pagination for workflow logs * Fix "All Nodes" not renderd on Nodes column * Fix reducer to append logs on Logs column * Fix: incorrect code placement * Fix reducer to append logs on Nodes column * Prepend execution log on workflow run * Fix node ordering * Decouple logs panel from workflow editor * Update execution nodes when log panel is opened * Reset log selection on workflow run * Added 'updatePreviewState' function * Update ee-server submodule reference --- frontend/ee | 2 +- .../_services/workflow_executions.service.js | 18 ++++++++++++++ server/ee | 2 +- .../modules/workflows/constants/feature.ts | 2 ++ .../src/modules/workflows/constants/index.ts | 2 ++ .../workflow-executions.controller.ts | 24 ++++++++++++++++++- .../IWorkflowExecutionController.ts | 4 ++++ .../interfaces/IWorkflowExecutionsService.ts | 17 +++++++++++++ .../services/workflow-executions.service.ts | 21 ++++++++++++++++ server/src/modules/workflows/types/index.ts | 2 ++ 10 files changed, 91 insertions(+), 3 deletions(-) diff --git a/frontend/ee b/frontend/ee index b1b81cebd4..b8bb0fdd28 160000 --- a/frontend/ee +++ b/frontend/ee @@ -1 +1 @@ -Subproject commit b1b81cebd4a8f2e03d927722084c76bc3c660b41 +Subproject commit b8bb0fdd287f4cf52d044a02be8b8d4777abfbe6 diff --git a/frontend/src/_services/workflow_executions.service.js b/frontend/src/_services/workflow_executions.service.js index ecaa810733..04f9f075c9 100644 --- a/frontend/src/_services/workflow_executions.service.js +++ b/frontend/src/_services/workflow_executions.service.js @@ -10,6 +10,8 @@ export const workflowExecutionsService = { all, enableWebhook, previewQueryNode, + getPaginatedExecutions, + getPaginatedNodes, trigger, streamSSE, }; @@ -73,6 +75,22 @@ function enableWebhook(appId, value) { return fetch(`${config.apiUrl}/v2/webhooks/workflows/${appId}`, requestOptions).then(handleResponse); } +function getPaginatedExecutions(appVersionId, page = 1, perPage = 10) { + const requestOptions = { method: 'GET', headers: authHeader(), credentials: 'include' }; + return fetch( + `${config.apiUrl}/workflow_executions?appVersionId=${appVersionId}&page=${page}&per_page=${perPage}`, + requestOptions + ).then(handleResponse); +} + +function getPaginatedNodes(executionId, page = 1, perPage = 20) { + const requestOptions = { method: 'GET', headers: authHeader(), credentials: 'include' }; + return fetch( + `${config.apiUrl}/workflow_executions/${executionId}/nodes?page=${page}&per_page=${perPage}`, + requestOptions + ).then(handleResponse); +} + function trigger(workflowAppId, params, environmentId) { const currentSession = authenticationService.currentSessionValue; const body = { diff --git a/server/ee b/server/ee index 1adb563573..d5eb650e9c 160000 --- a/server/ee +++ b/server/ee @@ -1 +1 @@ -Subproject commit 1adb563573bde7d204976a45c06ef4ce96d7dad3 +Subproject commit d5eb650e9c5dc62c4a3db1a29f6216315871f195 diff --git a/server/src/modules/workflows/constants/feature.ts b/server/src/modules/workflows/constants/feature.ts index d45f218569..b127bcb934 100644 --- a/server/src/modules/workflows/constants/feature.ts +++ b/server/src/modules/workflows/constants/feature.ts @@ -8,6 +8,8 @@ export const FEATURES: FeaturesConfig = { [FEATURE_KEY.WORKFLOW_EXECUTION_STATUS]: {}, [FEATURE_KEY.WORKFLOW_EXECUTION_DETAILS]: {}, //Basic plan users can access worfklows [FEATURE_KEY.LIST_WORKFLOW_EXECUTIONS]: {}, + [FEATURE_KEY.FETCH_EXECUTION_LOGS]: {}, + [FEATURE_KEY.FETCH_EXECUTION_NODES]: {}, [FEATURE_KEY.PREVIEW_QUERY_NODE]: {}, [FEATURE_KEY.CREATE_WORKFLOW_SCHEDULE]: {}, diff --git a/server/src/modules/workflows/constants/index.ts b/server/src/modules/workflows/constants/index.ts index a55692df04..196bcc9bfa 100644 --- a/server/src/modules/workflows/constants/index.ts +++ b/server/src/modules/workflows/constants/index.ts @@ -3,6 +3,8 @@ export enum FEATURE_KEY { WORKFLOW_EXECUTION_STATUS = 'workflow_execution_status', WORKFLOW_EXECUTION_DETAILS = 'workflow_execution_details', LIST_WORKFLOW_EXECUTIONS = 'list_workflow_executions', + FETCH_EXECUTION_LOGS = 'fetch_execution_logs', + FETCH_EXECUTION_NODES = 'fetch_execution_nodes', PREVIEW_QUERY_NODE = 'preview_query_node', CREATE_WORKFLOW_SCHEDULE = 'create_workflow_schedule', diff --git a/server/src/modules/workflows/controllers/workflow-executions.controller.ts b/server/src/modules/workflows/controllers/workflow-executions.controller.ts index 0917173d7f..c4ff8cdcfe 100644 --- a/server/src/modules/workflows/controllers/workflow-executions.controller.ts +++ b/server/src/modules/workflows/controllers/workflow-executions.controller.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Get, Param, Post, Res, Sse } from '@nestjs/common'; +import { Body, Controller, Get, Param, Post, Query, Res, Sse } from '@nestjs/common'; import { Response } from 'express'; import { IWorkflowExecutionController } from '../interfaces/IWorkflowExecutionController'; import { CreateWorkflowExecutionDto } from '@dto/create-workflow-execution.dto'; @@ -44,6 +44,28 @@ export class WorkflowExecutionsController implements IWorkflowExecutionControlle throw new Error('Method not implemented.'); } + @InitFeature(FEATURE_KEY.FETCH_EXECUTION_LOGS) + @Get() + async getExecutions( + @Query('appVersionId') appVersionId: string, + @Query('page') page = '1', + @Query('per_page') perPage = '10', + @User() user + ): Promise { + throw new Error('Method not implemented.'); + } + + @InitFeature(FEATURE_KEY.FETCH_EXECUTION_NODES) + @Get(':id/nodes') + async getExecutionNodes( + @Param('id') id: string, + @Query('page') page = '1', + @Query('per_page') perPage = '10', + @User() user + ): Promise { + throw new Error('Method not implemented.'); + } + @InitFeature(FEATURE_KEY.PREVIEW_QUERY_NODE) @Post('previewQueryNode') async previewQueryNode( diff --git a/server/src/modules/workflows/interfaces/IWorkflowExecutionController.ts b/server/src/modules/workflows/interfaces/IWorkflowExecutionController.ts index 01399f46be..61547bb682 100644 --- a/server/src/modules/workflows/interfaces/IWorkflowExecutionController.ts +++ b/server/src/modules/workflows/interfaces/IWorkflowExecutionController.ts @@ -16,5 +16,9 @@ export interface IWorkflowExecutionController { index(appVersionId: any, user: any): Promise; + getExecutions(appVersionId: string, page: any, perPage: any, user: any): Promise; + + getExecutionNodes(id: string, user: any, page: any, perPage: any): Promise; + previewQueryNode(user: any, previewNodeDto: PreviewWorkflowNodeDto, response: Response): Promise<{ result: any }>; } diff --git a/server/src/modules/workflows/interfaces/IWorkflowExecutionsService.ts b/server/src/modules/workflows/interfaces/IWorkflowExecutionsService.ts index df710030b2..8ec5b78fe2 100644 --- a/server/src/modules/workflows/interfaces/IWorkflowExecutionsService.ts +++ b/server/src/modules/workflows/interfaces/IWorkflowExecutionsService.ts @@ -4,6 +4,7 @@ import { AppVersion } from 'src/entities/app_version.entity'; import { User } from 'src/entities/user.entity'; import { Response } from 'express'; import { QueryResult } from '@tooljet/plugins/dist/packages/common/lib'; +import { WorkflowExecutionNode } from 'src/entities/workflow_execution_node.entity'; export interface IWorkflowExecutionsService { create(createWorkflowExecutionDto: CreateWorkflowExecutionDto): Promise; @@ -42,4 +43,20 @@ export interface IWorkflowExecutionsService { user: User, response: Response ): Promise; + + getWorkflowExecutionsLogs(appVersionId: string, page?: number, limit?: number): Promise<{ + data: WorkflowExecution[]; + page: number; + per_page: number; + total: number; + total_pages: number; + }>; + + getWorkflowExecutionNodes(workflowExecutionId: string, page?: number, limit?: number): Promise<{ + data: WorkflowExecutionNode[]; + page: number; + per_page: number; + total: number; + total_pages: number; + }>; } diff --git a/server/src/modules/workflows/services/workflow-executions.service.ts b/server/src/modules/workflows/services/workflow-executions.service.ts index 6cdd4d4199..ea39f8a488 100644 --- a/server/src/modules/workflows/services/workflow-executions.service.ts +++ b/server/src/modules/workflows/services/workflow-executions.service.ts @@ -6,6 +6,7 @@ import { Response } from 'express'; import { IWorkflowExecutionsService } from '../interfaces/IWorkflowExecutionsService'; import { CreateWorkflowExecutionDto } from '@dto/create-workflow-execution.dto'; import { QueryResult } from '@tooljet/plugins/dist/packages/common/lib'; +import { WorkflowExecutionNode } from 'src/entities/workflow_execution_node.entity'; @Injectable() export class WorkflowExecutionsService implements IWorkflowExecutionsService { @@ -61,4 +62,24 @@ export class WorkflowExecutionsService implements IWorkflowExecutionsService { async findOne(id: string, relations?: string[]): Promise { throw new Error('Method not implemented.'); } + + async getWorkflowExecutionsLogs(appVersionId: string, page: number = 1, limit: number = 10): Promise<{ + data: WorkflowExecution[]; + page: number; + per_page: number; + total: number; + total_pages: number; + }> { + throw new Error('Method not implemented.'); + } + + async getWorkflowExecutionNodes(workflowExecutionId: string, page: number = 1, limit: number = 10): Promise<{ + data: WorkflowExecutionNode[]; + page: number; + per_page: number; + total: number; + total_pages: number; + }> { + throw new Error('Method not implemented.'); + } } diff --git a/server/src/modules/workflows/types/index.ts b/server/src/modules/workflows/types/index.ts index 5d71a8b0e6..3aaba83ec1 100644 --- a/server/src/modules/workflows/types/index.ts +++ b/server/src/modules/workflows/types/index.ts @@ -7,6 +7,8 @@ interface Features { [FEATURE_KEY.WORKFLOW_EXECUTION_STATUS]: FeatureConfig; [FEATURE_KEY.WORKFLOW_EXECUTION_DETAILS]: FeatureConfig; [FEATURE_KEY.LIST_WORKFLOW_EXECUTIONS]: FeatureConfig; + [FEATURE_KEY.FETCH_EXECUTION_LOGS]: FeatureConfig; + [FEATURE_KEY.FETCH_EXECUTION_NODES]: FeatureConfig; [FEATURE_KEY.PREVIEW_QUERY_NODE]: FeatureConfig; [FEATURE_KEY.CREATE_WORKFLOW_SCHEDULE]: FeatureConfig; [FEATURE_KEY.LIST_WORKFLOW_SCHEDULES]: FeatureConfig;