Fix #6242 Handle Pipeline without tasks on Pipeline view (#6243)

This commit is contained in:
Sachin Chaurasiya 2022-07-21 15:10:15 +05:30 committed by GitHub
parent 12ffa9338e
commit f6b7af8c6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 5 deletions

View File

@ -12,6 +12,7 @@
*/ */
import { compare } from 'fast-json-patch'; import { compare } from 'fast-json-patch';
import { isEmpty } from 'lodash';
import { EntityTags, ExtraInfo } from 'Models'; import { EntityTags, ExtraInfo } from 'Models';
import React, { RefObject, useCallback, useEffect, useState } from 'react'; import React, { RefObject, useCallback, useEffect, useState } from 'react';
import AppState from '../../AppState'; import AppState from '../../AppState';
@ -462,13 +463,15 @@ const PipelineDetails = ({
<div <div
className="tw-flex-grow tw-w-full tw-h-full" className="tw-flex-grow tw-w-full tw-h-full"
style={{ height: 'calc(100% - 250px)' }}> style={{ height: 'calc(100% - 250px)' }}>
{tasks ? ( {!isEmpty(tasks) ? (
<TasksDAGView <TasksDAGView
selectedExec={selectedExecution} selectedExec={selectedExecution}
tasks={tasks} tasks={tasks}
/> />
) : ( ) : (
<div className="tw-mt-4 tw-ml-4 tw-flex tw-justify-center tw-font-medium tw-items-center tw-border tw-border-main tw-rounded-md tw-p-8"> <div
className="tw-mt-4 tw-ml-4 tw-flex tw-justify-center tw-font-medium tw-items-center tw-border tw-border-main tw-rounded-md tw-p-8"
data-testid="no-tasks-data">
<span>No task data is available</span> <span>No task data is available</span>
</div> </div>
)} )}

View File

@ -60,9 +60,30 @@ const mockUserTeam = [
}, },
]; ];
const mockTasks = [
{
name: 'snowflake_task',
displayName: 'Snowflake Task',
description: 'Airflow operator to perform ETL on snowflake tables',
taskUrl:
'http://localhost:8080/taskinstance/list/?flt1_dag_id_equals=assert_table_exists',
downstreamTasks: ['assert_table_exists'],
taskType: 'SnowflakeOperator',
},
{
name: 'assert_table_exists',
displayName: 'Assert Table Exists',
description: 'Assert if a table exists',
taskUrl:
'http://localhost:8080/taskinstance/list/?flt1_dag_id_equals=assert_table_exists',
downstreamTasks: [],
taskType: 'HiveOperator',
},
];
const PipelineDetailsProps = { const PipelineDetailsProps = {
pipelineUrl: '', pipelineUrl: '',
tasks: [], tasks: mockTasks,
serviceType: '', serviceType: '',
users: [], users: [],
pipelineDetails: {} as Pipeline, pipelineDetails: {} as Pipeline,
@ -216,6 +237,17 @@ describe('Test PipelineDetails component', () => {
expect(pipelineStatus).toBeInTheDocument(); expect(pipelineStatus).toBeInTheDocument();
}); });
it('Should render no tasks data placeholder is tasks list is empty', async () => {
const { findByTestId } = render(
<PipelineDetails {...PipelineDetailsProps} tasks={[]} />,
{
wrapper: MemoryRouter,
}
);
expect(await findByTestId('no-tasks-data')).toBeInTheDocument();
});
it('Check if active tab is activity feed', async () => { it('Check if active tab is activity feed', async () => {
const { container } = render( const { container } = render(
<PipelineDetails {...PipelineDetailsProps} activeTab={2} />, <PipelineDetails {...PipelineDetailsProps} activeTab={2} />,

View File

@ -320,7 +320,7 @@ const PipelineDetailsPage = () => {
}); });
setPipelineUrl(pipelineUrl); setPipelineUrl(pipelineUrl);
setTasks(tasks); setTasks(tasks || []);
setPipelineStatus( setPipelineStatus(
(pipelineStatus as Pipeline['pipelineStatus']) || [] (pipelineStatus as Pipeline['pipelineStatus']) || []
@ -329,7 +329,7 @@ const PipelineDetailsPage = () => {
fetchServiceDetails(service.type, service.name) fetchServiceDetails(service.type, service.name)
.then((hostPort: string) => { .then((hostPort: string) => {
setPipelineUrl(hostPort + pipelineUrl); setPipelineUrl(hostPort + pipelineUrl);
const updatedTasks = (tasks as Task[]).map((task) => ({ const updatedTasks = ((tasks || []) as Task[]).map((task) => ({
...task, ...task,
taskUrl: hostPort + task.taskUrl, taskUrl: hostPort + task.taskUrl,
})); }));
@ -354,6 +354,8 @@ const PipelineDetailsPage = () => {
jsonData['api-error-messages']['fetch-pipeline-details-error'] jsonData['api-error-messages']['fetch-pipeline-details-error']
); );
} }
})
.finally(() => {
setLoading(false); setLoading(false);
}); });
}; };