From 62d0331b53a39faba8029c2bdeb6e657db74cbbe Mon Sep 17 00:00:00 2001 From: karanh37 <33024356+karanh37@users.noreply.github.com> Date: Sun, 31 Dec 2023 01:05:52 +0530 Subject: [PATCH] revert search index disabling from ui (#14272) --- .../AppRunsHistory.component.tsx | 16 +-- .../AppRunsHistory.interface.ts | 1 - .../AppSchedule/AppSchedule.component.tsx | 98 ++----------------- 3 files changed, 10 insertions(+), 105 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppRunsHistory/AppRunsHistory.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppRunsHistory/AppRunsHistory.component.tsx index 7b5e2f734b6..cd7339e2a9d 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppRunsHistory/AppRunsHistory.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppRunsHistory/AppRunsHistory.component.tsx @@ -59,12 +59,7 @@ import { const AppRunsHistory = forwardRef( ( - { - appData, - maxRecords, - showPagination = true, - runsData, - }: AppRunsHistoryProps, + { appData, maxRecords, showPagination = true }: AppRunsHistoryProps, ref ) => { const { t } = useTranslation(); @@ -276,13 +271,8 @@ const AppRunsHistory = forwardRef( })); useEffect(() => { - if (runsData) { - setAppRunsHistoryData(runsData); - setIsLoading(false); - } else { - fetchAppHistory(); - } - }, [fqn, pageSize, runsData]); + fetchAppHistory(); + }, [fqn, pageSize]); return ( diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppRunsHistory/AppRunsHistory.interface.ts b/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppRunsHistory/AppRunsHistory.interface.ts index d268b6407b8..f7382e3f0b6 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppRunsHistory/AppRunsHistory.interface.ts +++ b/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppRunsHistory/AppRunsHistory.interface.ts @@ -26,5 +26,4 @@ export interface AppRunsHistoryProps { maxRecords?: number; appData?: App; showPagination?: boolean; - runsData?: AppRunRecordWithId[]; } diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppSchedule/AppSchedule.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppSchedule/AppSchedule.component.tsx index afb3dd88fe4..bc87ac5411c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppSchedule/AppSchedule.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Applications/AppSchedule/AppSchedule.component.tsx @@ -11,7 +11,6 @@ * limitations under the License. */ import { Button, Col, Divider, Modal, Row, Space, Typography } from 'antd'; -import { AxiosError } from 'axios'; import cronstrue from 'cronstrue'; import React, { useCallback, @@ -25,26 +24,13 @@ import { AppScheduleClass, AppType, } from '../../../generated/entity/applications/app'; -import { Status } from '../../../generated/entity/applications/appRunRecord'; -import { - PipelineState, - PipelineStatus, - PipelineType, -} from '../../../generated/entity/services/ingestionPipelines/ingestionPipeline'; -import { Paging } from '../../../generated/type/paging'; -import { getApplicationRuns } from '../../../rest/applicationAPI'; +import { PipelineType } from '../../../generated/entity/services/ingestionPipelines/ingestionPipeline'; import { getIngestionPipelineByFqn } from '../../../rest/ingestionPipelineAPI'; -import { getStatusFromPipelineState } from '../../../utils/ApplicationUtils'; import { getIngestionFrequency } from '../../../utils/CommonUtils'; -import { getEpochMillisForPastDays } from '../../../utils/date-time/DateTimeUtils'; -import { showErrorToast } from '../../../utils/ToastUtils'; import TestSuiteScheduler from '../../AddDataQualityTest/components/TestSuiteScheduler'; import Loader from '../../Loader/Loader'; import AppRunsHistory from '../AppRunsHistory/AppRunsHistory.component'; -import { - AppRunRecordWithId, - AppRunsHistoryRef, -} from '../AppRunsHistory/AppRunsHistory.interface'; +import { AppRunsHistoryRef } from '../AppRunsHistory/AppRunsHistory.interface'; import { AppScheduleProps } from './AppScheduleProps.interface'; const AppSchedule = ({ @@ -58,22 +44,6 @@ const AppSchedule = ({ const appRunsHistoryRef = useRef(null); const [isPipelineDeployed, setIsPipelineDeployed] = useState(false); const [isLoading, setIsLoading] = useState(true); - const [appRunsHistoryData, setAppRunsHistoryData] = useState< - AppRunRecordWithId[] - >([]); - - const isExternalApp = useMemo( - () => appData?.appType === AppType.External, - [appData] - ); - - const isAppRunning = useMemo(() => { - if (appRunsHistoryData.length > 0) { - return appRunsHistoryData[0].status === Status.Running; - } else { - return false; - } - }, [appRunsHistoryData]); const fetchPipelineDetails = useCallback(async () => { setIsLoading(true); @@ -97,60 +67,6 @@ const AppSchedule = ({ } }, [appData]); - const fetchAppHistory = useCallback( - async (pagingOffset?: Paging) => { - try { - setIsLoading(true); - - if (isExternalApp) { - const currentTime = Date.now(); - // past 30 days - const startDay = getEpochMillisForPastDays(30); - - const { data } = await getApplicationRuns( - appData.fullyQualifiedName ?? '', - { - startTs: startDay, - endTs: currentTime, - } - ); - - setAppRunsHistoryData( - data - .map((item) => ({ - ...item, - status: getStatusFromPipelineState( - (item as PipelineStatus).pipelineState ?? PipelineState.Failed - ), - id: (item as PipelineStatus).runId ?? '', - })) - .slice(0, 1) - ); - } else { - const { data } = await getApplicationRuns( - appData.fullyQualifiedName ?? '', - { - offset: pagingOffset?.offset ?? 0, - limit: 1, - } - ); - - setAppRunsHistoryData( - data.map((item) => ({ - ...item, - id: `${item.appId}-${item.runType}-${item.timestamp}`, - })) - ); - } - } catch (err) { - showErrorToast(err as AxiosError); - } finally { - setIsLoading(false); - } - }, - [appData] - ); - const cronString = useMemo(() => { if (appData.appSchedule) { const cronExp = @@ -179,7 +95,7 @@ const AppSchedule = ({ const onAppTrigger = async () => { await onDemandTrigger(); - await fetchAppHistory(); + appRunsHistoryRef.current?.refreshAppHistory(); }; const appRunHistory = useMemo(() => { @@ -192,7 +108,6 @@ const AppSchedule = ({ appData={appData} maxRecords={1} ref={appRunsHistoryRef} - runsData={appRunsHistoryData} showPagination={false} /> ); @@ -211,11 +126,10 @@ const AppSchedule = ({ {t('message.no-ingestion-pipeline-found')} ); - }, [appData, isPipelineDeployed, appRunsHistoryRef, appRunsHistoryData]); + }, [appData, isPipelineDeployed, appRunsHistoryRef]); useEffect(() => { fetchPipelineDetails(); - fetchAppHistory(); }, []); if (isLoading) { @@ -260,6 +174,7 @@ const AppSchedule = ({ {appData.appType === AppType.External && (