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

View File

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