From 1e76aae76b189d31c8020b38dab7e9bb6f2da332 Mon Sep 17 00:00:00 2001 From: darth-coder00 <86726556+darth-coder00@users.noreply.github.com> Date: Thu, 21 Apr 2022 22:33:27 +0530 Subject: [PATCH] Fix #4251: Ingestion button redirects to airflow (#4322) --- .../resources/ui/src/axiosAPIs/miscAPI.ts | 4 ++ .../Ingestion/Ingestion.component.tsx | 28 +++++++- .../components/Ingestion/Ingestion.test.tsx | 37 ++++++++++- .../Ingestion/ingestion.interface.ts | 1 + .../src/main/resources/ui/src/jsons/en.ts | 2 + .../resources/ui/src/pages/service/index.tsx | 64 +++++++++++++------ 6 files changed, 115 insertions(+), 21 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/axiosAPIs/miscAPI.ts b/openmetadata-ui/src/main/resources/ui/src/axiosAPIs/miscAPI.ts index 90570966ae2..8c2f4337fcc 100644 --- a/openmetadata-ui/src/main/resources/ui/src/axiosAPIs/miscAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/axiosAPIs/miscAPI.ts @@ -61,6 +61,10 @@ export const fetchSandboxConfig = (): Promise => { return APIClient.get('/config/sandbox'); }; +export const fetchAirflowConfig = (): Promise => { + return APIClient.get('/config/airflow'); +}; + export const getSuggestions: Function = ( queryString: string, searchIndex?: string diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Ingestion/Ingestion.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Ingestion/Ingestion.component.tsx index 02394bd436d..cfadce3285d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Ingestion/Ingestion.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Ingestion/Ingestion.component.tsx @@ -29,6 +29,7 @@ import { } from '../../generated/entity/services/ingestionPipelines/ingestionPipeline'; import { useAuth } from '../../hooks/authHooks'; import { isEven } from '../../utils/CommonUtils'; +import SVGIcons, { Icons } from '../../utils/SvgUtils'; import { showInfoToast } from '../../utils/ToastUtils'; import AddIngestion from '../AddIngestion/AddIngestion.component'; import { Button } from '../buttons/Button/Button'; @@ -41,6 +42,7 @@ import EntityDeleteModal from '../Modals/EntityDeleteModal/EntityDeleteModal'; import { IngestionProps, ModifiedConfig } from './ingestion.interface'; const Ingestion: React.FC = ({ + airflowEndpoint, serviceDetails, serviceName, serviceCategory, @@ -270,6 +272,7 @@ const Ingestion: React.FC = ({ Type Schedule Recent Runs + Airflow DAG Actions @@ -311,7 +314,30 @@ const Ingestion: React.FC = ({
{getStatuses(ingestion)}
- + + {airflowEndpoint ? ( + + + View + + + + ) : ( + No endpoint + )} + { { { expect(ingestionTable).toBeInTheDocument(); expect(tableHeaderContainer).toBeInTheDocument(); - expect(tableHeaders.length).toBe(5); + expect(tableHeaders.length).toBe(6); expect(tableHeaders).toStrictEqual([ 'Name', 'Type', 'Schedule', 'Recent Runs', + 'Airflow DAG', 'Actions', ]); expect(runButton).toBeInTheDocument(); @@ -186,6 +189,7 @@ describe('Test Ingestion page', () => { { { { expect(ingestionModal).toBeInTheDocument(); }); + + it('Airflow DAG view button should be present if endpoint is available', async () => { + const { container } = render( + , + { + wrapper: MemoryRouter, + } + ); + + const viewButton = await findByTestId(container, 'airflow-tree-view'); + + expect(viewButton).toBeInTheDocument(); + }); }); diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Ingestion/ingestion.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/Ingestion/ingestion.interface.ts index a36c8b615d9..b7d555742b5 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Ingestion/ingestion.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/Ingestion/ingestion.interface.ts @@ -54,6 +54,7 @@ export interface IngestionData { } export interface IngestionProps { + airflowEndpoint: string; serviceDetails: DataObj; serviceName?: string; serviceCategory: ServiceCategory; diff --git a/openmetadata-ui/src/main/resources/ui/src/jsons/en.ts b/openmetadata-ui/src/main/resources/ui/src/jsons/en.ts index 1a2e101577d..ac0e1495a5d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/jsons/en.ts +++ b/openmetadata-ui/src/main/resources/ui/src/jsons/en.ts @@ -57,6 +57,8 @@ const jsonData = { 'deploy-ingestion-error': 'Error while deploying ingestion workflow!', + 'fetch-airflow-config-error': + 'Error occurred while fetching airflow configs!', 'fetch-auth-config-error': 'Error occurred while fetching auth configs!', 'fetch-chart-error': 'Error while fetching charts!', 'fetch-dashboard-details-error': 'Error while fetching dashboard details!', diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx index bdcb6fa92b3..e4003ea1b04 100644 --- a/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/pages/service/index.tsx @@ -29,6 +29,7 @@ import { triggerIngestionPipelineById, updateIngestionPipeline, } from '../../axiosAPIs/ingestionPipelineAPI'; +import { fetchAirflowConfig } from '../../axiosAPIs/miscAPI'; import { getPipelines } from '../../axiosAPIs/pipelineAPI'; import { getServiceByFQN, updateService } from '../../axiosAPIs/serviceAPI'; import { getTopics } from '../../axiosAPIs/topicsAPI'; @@ -113,6 +114,7 @@ const ServicePage: FunctionComponent = () => { const [currentPage, setCurrentPage] = useState(1); const [ingestionCurrentPage, setIngestionCurrentPage] = useState(1); + const [airflowEndpoint, setAirflowEndpoint] = useState(); const getCountLabel = () => { switch (serviceName) { @@ -234,6 +236,25 @@ const ServicePage: FunctionComponent = () => { .finally(() => setIsloading(false)); }; + const getAirflowEndpoint = () => { + fetchAirflowConfig() + .then((res) => { + if (res.data?.apiEndpoint) { + setAirflowEndpoint(res.data.apiEndpoint); + } else { + setAirflowEndpoint(''); + + throw jsonData['api-error-messages']['unexpected-server-response']; + } + }) + .catch((err: AxiosError) => { + showErrorToast( + err, + jsonData['api-error-messages']['fetch-airflow-config-error'] + ); + }); + }; + const triggerIngestionById = ( id: string, displayName: string @@ -689,6 +710,7 @@ const ServicePage: FunctionComponent = () => { // getDatabaseServices(); getAllIngestionWorkflows(); } + getAirflowEndpoint(); }, []); const onCancel = () => { @@ -942,25 +964,29 @@ const ServicePage: FunctionComponent = () => { )} - {activeTab === 2 && ( -
- -
- )} + {activeTab === 2 && + (isUndefined(airflowEndpoint) ? ( + + ) : ( +
+ +
+ ))} {activeTab === 3 && (isAdminUser || isAuthDisabled) && (