* - Changed the method for editing the test suite pipeline from PATCH to PUT
- Provided option to redploy the pipeline in the table

* Worked on comments
This commit is contained in:
Aniket Katkar 2022-10-01 11:04:55 +05:30 committed by GitHub
parent 0451de4c09
commit ecff318546
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 90 additions and 43 deletions

View File

@ -12,7 +12,6 @@
*/
import { Col, Row, Typography } from 'antd';
import { AxiosError } from 'axios';
import { compare } from 'fast-json-patch';
import { camelCase, isEmpty } from 'lodash';
import React, { useEffect, useMemo, useState } from 'react';
import { useHistory, useParams } from 'react-router-dom';
@ -20,7 +19,7 @@ import {
addIngestionPipeline,
checkAirflowStatus,
deployIngestionPipelineById,
patchIngestionPipeline,
updateIngestionPipeline as putIngestionPipeline,
} from '../../axiosAPIs/ingestionPipelineAPI';
import {
DEPLOYED_PROGRESS_VAL,
@ -137,32 +136,45 @@ const TestSuiteIngestion: React.FC<TestSuiteIngestionProps> = ({
};
const updateIngestionPipeline = async (repeatFrequency: string) => {
const updatedPipeline = {
...ingestionPipeline,
const {
airflowConfig,
description,
displayName,
loggerLevel,
name,
owner,
pipelineType,
service,
sourceConfig,
} = ingestionPipeline as IngestionPipeline;
const updatedPipelineData = {
airflowConfig: {
...ingestionPipeline?.airflowConfig,
...airflowConfig,
scheduleInterval: isEmpty(repeatFrequency)
? undefined
: repeatFrequency,
},
description,
displayName,
loggerLevel,
name,
owner,
pipelineType,
service,
sourceConfig,
};
const jsonPatch = compare(
ingestionPipeline as IngestionPipeline,
updatedPipeline
);
if (jsonPatch.length) {
try {
const response = await patchIngestionPipeline(
ingestionPipeline?.id || '',
jsonPatch
);
handleIngestionDeploy(response.id);
} catch (error) {
showErrorToast(
error as AxiosError,
jsonData['api-error-messages']['update-ingestion-error']
);
}
try {
const response = await putIngestionPipeline(
updatedPipelineData as CreateIngestionPipeline
);
handleIngestionDeploy(response.id);
} catch (error) {
showErrorToast(
error as AxiosError,
jsonData['api-error-messages']['update-ingestion-error']
);
}
};

View File

@ -203,13 +203,16 @@ const TestSuitePipelineTab = () => {
}
};
const handleDeployIngestion = async (id: string) => {
const handleDeployIngestion = async (id: string, reDeployed: boolean) => {
setCurrDeployId({ id, state: 'waiting' });
try {
await deployIngestionPipelineById(id);
setCurrDeployId({ id, state: 'success' });
setTimeout(() => setCurrDeployId({ id: '', state: '' }), 1500);
showSuccessToast(
`Pipeline ${reDeployed ? 'Re Deployed' : 'Deployed'} successfully`
);
} catch (error) {
setCurrDeployId({ id: '', state: '' });
showErrorToast(
@ -222,25 +225,48 @@ const TestSuitePipelineTab = () => {
const getTriggerDeployButton = (ingestion: IngestionPipeline) => {
if (ingestion.deployed) {
return (
<Tooltip title={editPermission ? 'Run' : NO_PERMISSION_FOR_ACTION}>
<Button
data-testid="run"
disabled={!editPermission}
type="link"
onClick={() =>
handleTriggerIngestion(ingestion.id as string, ingestion.name)
}>
{currTriggerId.id === ingestion.id ? (
currTriggerId.state === 'success' ? (
<FontAwesomeIcon icon="check" />
<>
<Tooltip title={editPermission ? 'Run' : NO_PERMISSION_FOR_ACTION}>
<Button
data-testid="run"
disabled={!editPermission}
type="link"
onClick={() =>
handleTriggerIngestion(ingestion.id as string, ingestion.name)
}>
{currTriggerId.id === ingestion.id ? (
currTriggerId.state === 'success' ? (
<FontAwesomeIcon icon="check" />
) : (
<Loader size="small" type="default" />
)
) : (
<Loader size="small" type="default" />
)
) : (
'Run'
)}
</Button>
</Tooltip>
'Run'
)}
</Button>
</Tooltip>
{separator}
<Tooltip
title={editPermission ? 'Re Deploy' : NO_PERMISSION_FOR_ACTION}>
<Button
data-testid="re-deploy-btn"
disabled={!editPermission}
type="link"
onClick={() =>
handleDeployIngestion(ingestion.id as string, true)
}>
{currDeployId.id === ingestion.id ? (
currDeployId.state === 'success' ? (
<FontAwesomeIcon icon="check" />
) : (
<Loader size="small" type="default" />
)
) : (
'Re Deploy'
)}
</Button>
</Tooltip>
</>
);
} else {
return (
@ -249,7 +275,9 @@ const TestSuitePipelineTab = () => {
data-testid="deploy"
disabled={!editPermission}
type="link"
onClick={() => handleDeployIngestion(ingestion.id as string)}>
onClick={() =>
handleDeployIngestion(ingestion.id as string, false)
}>
{currDeployId.id === ingestion.id ? (
currDeployId.state === 'success' ? (
<FontAwesomeIcon icon="check" />
@ -507,7 +535,14 @@ const TestSuitePipelineTab = () => {
];
return column;
}, [airFlowEndPoint, isKillModalOpen, isLogsModalOpen, selectedPipeline]);
}, [
airFlowEndPoint,
isKillModalOpen,
isLogsModalOpen,
selectedPipeline,
currDeployId,
currTriggerId,
]);
if (isLoading) {
return <Loader />;