diff --git a/openmetadata-ui/src/main/resources/ui/src/components/TriggerReIndexing/TriggerReIndexing.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/TriggerReIndexing/TriggerReIndexing.component.tsx deleted file mode 100644 index 421f948c72b..00000000000 --- a/openmetadata-ui/src/main/resources/ui/src/components/TriggerReIndexing/TriggerReIndexing.component.tsx +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Copyright 2023 Collate. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { AxiosError } from 'axios'; -import { isEqual } from 'lodash'; -import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { useTranslation } from 'react-i18next'; -import { useParams } from 'react-router-dom'; -import { useWebSocketConnector } from '../../components/web-scoket/web-scoket.provider'; -import { SOCKET_EVENTS } from '../../constants/constants'; -import { - ELASTIC_SEARCH_INDEX_ENTITIES, - ELASTIC_SEARCH_INITIAL_VALUES, -} from '../../constants/elasticsearch.constant'; -import { ELASTIC_SEARCH_RE_INDEX_PAGE_TABS } from '../../enums/ElasticSearch.enum'; -import { CreateEventPublisherJob } from '../../generated/api/createEventPublisherJob'; -import { - EventPublisherJob, - RunMode, -} from '../../generated/system/eventPublisherJob'; -import { - getBatchJobReIndexStatus, - getStreamJobReIndexStatus, - reIndexByPublisher, - stopBatchJobReIndex, -} from '../../rest/elasticSearchReIndexAPI'; -import { getJobDetailsCard } from '../../utils/EventPublisherUtils'; -import { showErrorToast, showSuccessToast } from '../../utils/ToastUtils'; -import ReIndexAllModal from './ElasticSearchReIndexModal.component'; - -function TriggerReIndexing() { - const { t } = useTranslation(); - const { fqn } = useParams<{ fqn: string }>(); - const [batchJobData, setBatchJobData] = useState(); - const [streamJobData, setStreamJobData] = useState(); - - const [batchLoading, setBatchLoading] = useState(false); - const [streamLoading, setStreamLoading] = useState(false); - const [confirmLoading, setConfirmLoading] = useState(false); - - const [isModalOpen, setIsModalOpen] = useState(false); - - const { socket } = useWebSocketConnector(); - - const isOnDemandTab = useMemo( - () => fqn === ELASTIC_SEARCH_RE_INDEX_PAGE_TABS.ON_DEMAND, - [fqn] - ); - - const showReIndexAllModal = () => { - setIsModalOpen(true); - }; - - const fetchBatchReIndexedData = useCallback(async () => { - try { - setBatchLoading(true); - const response = await getBatchJobReIndexStatus(); - - setBatchJobData(response); - } catch (error) { - showErrorToast( - error as AxiosError, - t('server.fetch-re-index-data-error') - ); - } finally { - setBatchLoading(false); - } - }, [setBatchJobData, setBatchLoading]); - - const stopBatchReIndexedJob = useCallback(async () => { - if (batchJobData) { - try { - await stopBatchJobReIndex(batchJobData?.id); - showSuccessToast(t('server.re-indexing-stopped')); - } catch (error) { - showErrorToast(error as AxiosError, t('server.stop-re-indexing-error')); - } - } - }, [batchJobData]); - - const fetchStreamReIndexedData = useCallback(async () => { - try { - setStreamLoading(true); - const response = await getStreamJobReIndexStatus(); - - setStreamJobData(response); - } catch (error) { - // Error will be logged to console - } finally { - setStreamLoading(false); - } - }, [setStreamJobData, setStreamLoading]); - - const performReIndexAll = useCallback( - async (data: CreateEventPublisherJob) => { - try { - setConfirmLoading(true); - await reIndexByPublisher({ - ...data, - entities: isEqual( - data.entities, - ELASTIC_SEARCH_INITIAL_VALUES.entities - ) - ? ELASTIC_SEARCH_INDEX_ENTITIES.map((e) => e.value) - : data.entities ?? [], - runMode: RunMode.Batch, - } as CreateEventPublisherJob); - - showSuccessToast(t('server.re-indexing-started')); - } catch (err) { - showErrorToast(err as AxiosError, t('server.re-indexing-error')); - } finally { - setIsModalOpen(false); - setConfirmLoading(false); - } - }, - [setIsModalOpen, setConfirmLoading] - ); - - useEffect(() => { - if (socket) { - socket.on(SOCKET_EVENTS.JOB_STATUS, (newActivity) => { - if (newActivity) { - const activity = JSON.parse(newActivity) as EventPublisherJob; - if (activity.runMode === RunMode.Batch) { - setBatchJobData(activity); - } else { - setStreamJobData(activity); - } - } - }); - } - - return () => { - socket && socket.off(SOCKET_EVENTS.JOB_STATUS); - }; - }, [socket]); - - const jobDetailsCard = useMemo( - () => - isOnDemandTab - ? getJobDetailsCard( - batchLoading, - fetchBatchReIndexedData, - batchJobData, - batchJobData?.failure?.sourceError, - showReIndexAllModal, - stopBatchReIndexedJob - ) - : getJobDetailsCard( - streamLoading, - fetchStreamReIndexedData, - streamJobData, - streamJobData?.failure?.sinkError - ), - [ - isOnDemandTab, - batchLoading, - streamLoading, - fetchBatchReIndexedData, - fetchStreamReIndexedData, - batchJobData, - streamJobData, - ] - ); - - useEffect(() => { - if (isOnDemandTab) { - fetchBatchReIndexedData(); - } else { - fetchStreamReIndexedData(); - } - }, [isOnDemandTab]); - - return ( - <> - {jobDetailsCard} - setIsModalOpen(false)} - onSave={performReIndexAll} - /> - - ); -} - -export default TriggerReIndexing; diff --git a/openmetadata-ui/src/main/resources/ui/src/components/router/GlobalSettingRouter.tsx b/openmetadata-ui/src/main/resources/ui/src/components/router/GlobalSettingRouter.tsx index f4a5c0c557a..4c770364747 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/router/GlobalSettingRouter.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/router/GlobalSettingRouter.tsx @@ -105,15 +105,6 @@ const UserListPageV1 = withSuspenseFallback( React.lazy(() => import('../../pages/UserListPage/UserListPageV1')) ); -const ElasticSearchIndexPage = withSuspenseFallback( - React.lazy( - () => - import( - '../../pages/ElasticSearchIndexPage/ElasticSearchReIndexPage.component' - ) - ) -); - const DataInsightsSettingsPage = withSuspenseFallback( React.lazy( () => @@ -244,17 +235,6 @@ const GlobalSettingRouter = () => { )} /> - - { true )} /> + = [ { @@ -36,14 +39,15 @@ export const INGESTION_ACTION_TYPE = { }; export const PIPELINE_TYPE_LOCALIZATION = { - dataInsight: 'data-insight', - dbt: 'dbt-lowercase', - elasticSearchReindex: 'elastic-search-re-index', - lineage: 'lineage', - metadata: 'metadata', - profiler: 'profiler', - TestSuite: 'test-suite', - usage: 'usage', + [PipelineType.DataInsight]: 'data-insight', + [PipelineType.Dbt]: 'dbt-lowercase', + [PipelineType.ElasticSearchReindex]: 'elastic-search-re-index', + [PipelineType.Lineage]: 'lineage', + [PipelineType.Metadata]: 'metadata', + [PipelineType.Profiler]: 'profiler', + [PipelineType.TestSuite]: 'test-suite', + [PipelineType.Usage]: 'usage', + [PipelineType.Application]: 'application', }; export const DBT_CLASSIFICATION_DEFAULT_VALUE = 'dbtTags'; diff --git a/openmetadata-ui/src/main/resources/ui/src/pages/ElasticSearchIndexPage/ElasticSearchReIndexPage.component.tsx b/openmetadata-ui/src/main/resources/ui/src/pages/ElasticSearchIndexPage/ElasticSearchReIndexPage.component.tsx deleted file mode 100644 index fa2f70ba1aa..00000000000 --- a/openmetadata-ui/src/main/resources/ui/src/pages/ElasticSearchIndexPage/ElasticSearchReIndexPage.component.tsx +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2022 Collate. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { Col, Row, Tabs, TabsProps } from 'antd'; -import React, { useCallback, useMemo } from 'react'; -import { useTranslation } from 'react-i18next'; -import { useHistory, useParams } from 'react-router-dom'; -import PageHeader from '../../components/header/PageHeader.component'; -import SettingsIngestion from '../../components/SettingsIngestion/SettingsIngestion.component'; -import TriggerReIndexing from '../../components/TriggerReIndexing/TriggerReIndexing.component'; -import { - GlobalSettingOptions, - GlobalSettingsMenuCategory, -} from '../../constants/GlobalSettings.constants'; -import { ELASTIC_SEARCH_RE_INDEX_PAGE_TABS } from '../../enums/ElasticSearch.enum'; -import { PipelineType } from '../../generated/api/services/ingestionPipelines/createIngestionPipeline'; -import { getSettingsPathWithFqn } from '../../utils/RouterUtils'; -import './ElasticSearchReIndex.style.less'; - -const ElasticSearchIndexPage = () => { - const { t } = useTranslation(); - const history = useHistory(); - const { fqn } = useParams<{ fqn: string }>(); - - const tabItems: TabsProps['items'] = useMemo( - () => [ - { - key: ELASTIC_SEARCH_RE_INDEX_PAGE_TABS.ON_DEMAND, - label: t('label.on-demand'), - children: , - }, - { - key: ELASTIC_SEARCH_RE_INDEX_PAGE_TABS.LIVE, - label: t('label.live'), - children: , - }, - { - key: ELASTIC_SEARCH_RE_INDEX_PAGE_TABS.SCHEDULE, - label: t('label.schedule'), - children: ( - - ), - }, - ], - [] - ); - - const handleTabClick = useCallback((activeKey: string) => { - history.replace( - getSettingsPathWithFqn( - GlobalSettingsMenuCategory.OPEN_METADATA, - GlobalSettingOptions.SEARCH, - activeKey - ) - ); - }, []); - - return ( - - - - - - - - - ); -}; - -export default ElasticSearchIndexPage; diff --git a/openmetadata-ui/src/main/resources/ui/src/rest/elasticSearchReIndexAPI.ts b/openmetadata-ui/src/main/resources/ui/src/rest/elasticSearchReIndexAPI.ts index 47c4628f9ef..2d6aa82de3f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/rest/elasticSearchReIndexAPI.ts +++ b/openmetadata-ui/src/main/resources/ui/src/rest/elasticSearchReIndexAPI.ts @@ -13,14 +13,13 @@ import { AxiosResponse } from 'axios'; import axiosClient from '.'; -import { CreateEventPublisherJob } from '../generated/api/createEventPublisherJob'; import { - EventPublisherJob, + CreateEventPublisherJob, PublisherType, -} from '../generated/system/eventPublisherJob'; +} from '../generated/api/createEventPublisherJob'; export const getStreamJobReIndexStatus = async () => { - const res = await axiosClient.get( + const res = await axiosClient.get( `/search/reindex/stream/status` ); @@ -28,7 +27,9 @@ export const getStreamJobReIndexStatus = async () => { }; export const getBatchJobReIndexStatus = async () => { - const res = await axiosClient.get(`search/reindex/latest`); + const res = await axiosClient.get( + `search/reindex/latest` + ); return res.data; }; @@ -47,7 +48,7 @@ export const reIndexByPublisher = async (data: CreateEventPublisherJob) => { const res = await axiosClient.post< CreateEventPublisherJob, - AxiosResponse + AxiosResponse >('/search/reindex', payload); return res.data; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/EventPublisherUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/EventPublisherUtils.tsx deleted file mode 100644 index 106b8bc71dd..00000000000 --- a/openmetadata-ui/src/main/resources/ui/src/utils/EventPublisherUtils.tsx +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright 2022 Collate. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { ReloadOutlined } from '@ant-design/icons'; -import { Badge, Button, Card, Col, Divider, Row, Space } from 'antd'; -import { t } from 'i18next'; -import { isEmpty, startCase } from 'lodash'; -import React from 'react'; -import { ReactComponent as IconFailBadge } from '../assets/svg/fail-badge.svg'; -import { ReactComponent as IconTaskOpen } from '../assets/svg/in-progress.svg'; -import { ReactComponent as IconTaskStopped } from '../assets/svg/pending-badge.svg'; -import { ReactComponent as IconSuccessBadge } from '../assets/svg/success-badge.svg'; -import RichTextEditorPreviewer from '../components/common/rich-text-editor/RichTextEditorPreviewer'; -import Loader from '../components/Loader/Loader'; -import { - EventPublisherJob, - SourceError, - Status, -} from '../generated/system/eventPublisherJob'; -import { formatDateTimeWithTimezone } from './date-time/DateTimeUtils'; - -export const getStatusResultBadgeIcon = (status?: string) => { - switch (status) { - case Status.Stopped: - return ; - case Status.Completed: - return ; - - case Status.Failed: - case Status.ActiveWithError: - return ; - - case Status.Running: - case Status.Started: - return ; - - case Status.Active: - default: - return ; - } -}; - -export const getEventPublisherStatusText = (status?: string) => { - switch (status) { - case Status.Stopped: - return t('label.stopped'); - case Status.Failed: - return t('label.failed'); - case Status.Running: - return t('label.running'); - case Status.Completed: - return t('label.completed'); - case Status.Active: - return t('label.active'); - - case Status.ActiveWithError: - return t('label.active-with-error'); - - case Status.Started: - return t('label.started'); - - default: - return status || ''; - } -}; - -export const getJobDetailsCard = ( - loadingState: boolean, - fetchJobData: () => Promise, - jobData?: EventPublisherJob, - error?: SourceError, - showReIndexAllModal?: () => void, - stopBatchReIndexedJob?: () => void -) => { - return ( - - - ) : ( - - ))} - - } - loading={loadingState} - size="small" - title={t('label.elasticsearch')}> - - - -
- {`${t('label.mode')}:`} - - {startCase(jobData?.runMode) || '--'} - -
- -
- {`${t('label.status')}:`} - - - {getStatusResultBadgeIcon(jobData?.status)} - - {getEventPublisherStatusText(jobData?.status) || '--'} - - -
- - {showReIndexAllModal && ( -
- {`${t( - 'label.index-states' - )}:`} - - {!isEmpty(jobData) ? ( - - - - - - - - ) : ( - '--' - )} - -
- )} - -
- {`${t( - 'label.last-updated' - )}:`} - - {jobData?.timestamp - ? formatDateTimeWithTimezone(jobData?.timestamp) - : '--'} - -
- -
- {`${t( - 'label.last-failed-at' - )}:`} -

- {error - ? formatDateTimeWithTimezone(error?.lastFailedAt ?? 0) - : '--'} -

-
-
- - - {`${t( - 'label.failure-context' - )}:`} - - {error?.context ? ( - - ) : ( - '--' - )} - - - - {`${t('label.last-error')}:`} - - {error?.lastFailedReason ? ( - - ) : ( - '--' - )} - - -
-
- ); -};