From 6bcb0af67d61202469c3db2e85b7ad1d2473895f Mon Sep 17 00:00:00 2001 From: Sumukh Swamy Date: Thu, 23 May 2024 10:41:31 -0700 Subject: [PATCH] Bug fix for data-sources page (#1830) * added fix for failing data-sources page Signed-off-by: sumukhswamy * added change for job with the id Signed-off-by: sumukhswamy * addressed pr comments Signed-off-by: sumukhswamy * added fix for flyput Signed-off-by: sumukhswamy * added fix for flyout Signed-off-by: sumukhswamy * refactored the flyout objects with an interface Signed-off-by: sumukhswamy --------- Signed-off-by: sumukhswamy --- common/types/data_connections.ts | 22 ++++ .../accelerations/acceleration_table.tsx | 8 +- .../selector_helpers/load_databases.tsx | 4 +- .../selector_helpers/load_objects.tsx | 6 +- .../selectors/source_selector.tsx | 4 +- .../utils/acceleration_utils.tsx | 31 +++--- .../associated_objects_details_flyout.tsx | 33 +++--- .../associated_objects_tab.tsx | 8 +- .../modules/associated_objects_table.tsx | 51 ++++++--- .../components/manage/data_connection.tsx | 4 +- .../manage/manage_data_connections_table.tsx | 8 +- public/components/hooks/use_polling.ts | 1 - .../framework/catalog_cache/cache_loader.tsx | 1 - public/plugin.tsx | 102 +++++++++--------- public/services/requests/sql.ts | 2 +- public/types.ts | 40 +++---- 16 files changed, 193 insertions(+), 132 deletions(-) diff --git a/common/types/data_connections.ts b/common/types/data_connections.ts index a5585aca76..a15a05e479 100644 --- a/common/types/data_connections.ts +++ b/common/types/data_connections.ts @@ -252,3 +252,25 @@ export interface StartLoadingParams { databaseName?: string; tableName?: string; } + +export interface RenderAccelerationFlyoutParams { + dataSource: string; + dataSourceMDSId?: string; + databaseName?: string; + tableName?: string; + handleRefresh?: () => void; +} + +export interface RenderAssociatedObjectsDetailsFlyoutParams { + tableDetail: AssociatedObject; + dataSourceName: string; + handleRefresh?: () => void; + dataSourceMDSId?: string; +} + +export interface RenderAccelerationDetailsFlyoutParams { + acceleration: CachedAcceleration; + dataSourceName: string; + handleRefresh?: () => void; + dataSourceMDSId?: string; +} diff --git a/public/components/datasources/components/manage/accelerations/acceleration_table.tsx b/public/components/datasources/components/manage/accelerations/acceleration_table.tsx index e3e386d3ad..dbe4033c75 100644 --- a/public/components/datasources/components/manage/accelerations/acceleration_table.tsx +++ b/public/components/datasources/components/manage/accelerations/acceleration_table.tsx @@ -134,7 +134,7 @@ export const AccelerationTable = ({ const handleRefresh = useCallback(() => { if (!isCatalogCacheFetching(accelerationsLoadStatus)) { setIsRefreshing(true); - startLoadingAccelerations(dataSourceName); + startLoadingAccelerations({ dataSourceName }); } }, [accelerationsLoadStatus]); @@ -246,7 +246,11 @@ export const AccelerationTable = ({ return ( { - renderAccelerationDetailsFlyout(acceleration, dataSourceName, handleRefresh); + renderAccelerationDetailsFlyout({ + acceleration, + dataSourceName, + handleRefresh, + }); }} > {displayName} diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx index c49438f1f9..8a47f71d26 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_databases.tsx @@ -24,6 +24,7 @@ interface SelectorLoadDatabasesProps { }> >; tableFieldsLoading: boolean; + dataSourceMDSId?: string; } export const SelectorLoadDatabases = ({ @@ -32,6 +33,7 @@ export const SelectorLoadDatabases = ({ loadingComboBoxes, setLoadingComboBoxes, tableFieldsLoading, + dataSourceMDSId, }: SelectorLoadDatabasesProps) => { const [isLoading, setIsLoading] = useState(false); const { @@ -42,7 +44,7 @@ export const SelectorLoadDatabases = ({ const onClickRefreshDatabases = () => { setIsLoading(true); - startDatabasesLoading({ dataSourceName }); + startDatabasesLoading({ dataSourceName, dataSourceMDSId }); }; useEffect(() => { diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx index 7976196c04..18fdbf32f4 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/selector_helpers/load_objects.tsx @@ -29,6 +29,7 @@ interface SelectorLoadDatabasesProps { }> >; tableFieldsLoading: boolean; + dataSourceMDSId?: string; } export const SelectorLoadObjects = ({ @@ -38,6 +39,7 @@ export const SelectorLoadObjects = ({ loadingComboBoxes, setLoadingComboBoxes, tableFieldsLoading, + dataSourceMDSId, }: SelectorLoadDatabasesProps) => { const { setToast } = useToast(); const [isLoading, setIsLoading] = useState({ @@ -65,8 +67,8 @@ export const SelectorLoadObjects = ({ tableStatus: true, accelerationsStatus: true, }); - startLoadingTables({ dataSourceName, databaseName }); - startLoadingAccelerations({ dataSourceName }); + startLoadingTables({ dataSourceName, databaseName, dataSourceMDSId }); + startLoadingAccelerations({ dataSourceName, dataSourceMDSId }); }; useEffect(() => { diff --git a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/source_selector.tsx b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/source_selector.tsx index 9f127faf55..1d61000b2c 100644 --- a/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/source_selector.tsx +++ b/public/components/datasources/components/manage/accelerations/create_accelerations_flyout/selectors/source_selector.tsx @@ -74,7 +74,7 @@ export const AccelerationDataSourceSelector = ({ const loadDataSource = () => { setLoadingComboBoxes({ ...loadingComboBoxes, dataSource: true }); http - .get(DATACONNECTIONS_BASE + `/dataSourceMDSId=${dataSourceMDSId}`) + .get(`${DATACONNECTIONS_BASE}/dataSourceMDSId=${dataSourceMDSId ?? ''}`) .then((res) => { const isValidDataSource = res.some( (connection: any) => @@ -232,6 +232,7 @@ export const AccelerationDataSourceSelector = ({ loadingComboBoxes={loadingComboBoxes} setLoadingComboBoxes={setLoadingComboBoxes} tableFieldsLoading={tableFieldsLoading} + dataSourceMDSId={dataSourceMDSId} /> @@ -281,6 +282,7 @@ export const AccelerationDataSourceSelector = ({ loadingComboBoxes={loadingComboBoxes} setLoadingComboBoxes={setLoadingComboBoxes} tableFieldsLoading={tableFieldsLoading} + dataSourceMDSId={dataSourceMDSId} /> diff --git a/public/components/datasources/components/manage/accelerations/utils/acceleration_utils.tsx b/public/components/datasources/components/manage/accelerations/utils/acceleration_utils.tsx index 23ededc738..0b7d7d9ddd 100644 --- a/public/components/datasources/components/manage/accelerations/utils/acceleration_utils.tsx +++ b/public/components/datasources/components/manage/accelerations/utils/acceleration_utils.tsx @@ -6,12 +6,14 @@ import { EuiButton, EuiHealth } from '@elastic/eui'; import React from 'react'; import { DATA_SOURCE_TYPES } from '../../../../../../../common/constants/data_sources'; -import { CachedAcceleration } from '../../../../../../../common/types/data_connections'; +import { + CachedAcceleration, + RenderAccelerationFlyoutParams, +} from '../../../../../../../common/types/data_connections'; import { redirectToExplorerOSIdx, redirectToExplorerWithDataSrc, } from '../../associated_objects/utils/associated_objects_tab_utils'; - export const ACC_PANEL_TITLE = 'Accelerations'; export const ACC_PANEL_DESC = 'Accelerations optimize query performance by indexing external data into OpenSearch.'; @@ -91,26 +93,23 @@ export const CreateAccelerationFlyoutButton = ({ handleRefresh, }: { dataSourceName: string; - renderCreateAccelerationFlyout: ( - dataSource: string, - dataSourceMDSId?: string, - databaseName?: string, - tableName?: string, - handleRefresh?: () => void - ) => void; + renderCreateAccelerationFlyout: ({ + dataSource, + databaseName, + tableName, + handleRefresh, + dataSourceMDSId, + }: RenderAccelerationFlyoutParams) => void; handleRefresh: () => void; }) => { return ( <> - renderCreateAccelerationFlyout( - dataSourceName, - undefined, - undefined, - undefined, - handleRefresh - ) + renderCreateAccelerationFlyout({ + dataSource: dataSourceName, + handleRefresh, + }) } fill > diff --git a/public/components/datasources/components/manage/associated_objects/associated_objects_details_flyout.tsx b/public/components/datasources/components/manage/associated_objects/associated_objects_details_flyout.tsx index 5cd6414113..7520995cd0 100644 --- a/public/components/datasources/components/manage/associated_objects/associated_objects_details_flyout.tsx +++ b/public/components/datasources/components/manage/associated_objects/associated_objects_details_flyout.tsx @@ -93,13 +93,12 @@ export const AssociatedObjectsDetailsFlyout = ({ return ( - renderCreateAccelerationFlyout( - datasourceName, - '', - tableDetail.database, - tableDetail.name, - handleRefresh - ) + renderCreateAccelerationFlyout({ + dataSource: datasourceName, + databaseName: tableDetail.database, + tableName: tableDetail.name, + handleRefresh, + }) } > @@ -156,7 +155,12 @@ export const AssociatedObjectsDetailsFlyout = ({ return ( - renderAccelerationDetailsFlyout(item, datasourceName, handleRefresh, dataSourceMDSId) + renderAccelerationDetailsFlyout({ + acceleration: item, + dataSourceName: datasourceName, + handleRefresh, + dataSourceMDSId, + }) } > {name} @@ -196,13 +200,12 @@ export const AssociatedObjectsDetailsFlyout = ({ color="primary" fill onClick={() => - renderCreateAccelerationFlyout( - datasourceName, - '', - tableDetail.database, - tableDetail.name, - handleRefresh - ) + renderCreateAccelerationFlyout({ + dataSource: datasourceName, + databaseName: tableDetail.database, + tableName: tableDetail.name, + handleRefresh, + }) } iconType="popout" iconSide="left" diff --git a/public/components/datasources/components/manage/associated_objects/associated_objects_tab.tsx b/public/components/datasources/components/manage/associated_objects/associated_objects_tab.tsx index 31ddabeb9f..a19c67651c 100644 --- a/public/components/datasources/components/manage/associated_objects/associated_objects_tab.tsx +++ b/public/components/datasources/components/manage/associated_objects/associated_objects_tab.tsx @@ -100,7 +100,7 @@ export const AssociatedObjectsTab: React.FC = (props) const onRefreshButtonClick = () => { if (!isCatalogCacheFetching(databasesLoadStatus, tablesLoadStatus, accelerationsLoadStatus)) { - startLoadingDatabases({ databaseName: datasource.name }); + startLoadingDatabases({ dataSourceName: datasource.name }); setIsRefreshing(true); } }; @@ -167,7 +167,7 @@ export const AssociatedObjectsTab: React.FC = (props) datasourceCache.status === CachedDataSourceStatus.Failed) && !isCatalogCacheFetching(databasesLoadStatus) ) { - startLoadingDatabases(datasource.name); + startLoadingDatabases({ dataSourceName: datasource.name }); } else if (datasourceCache.status === CachedDataSourceStatus.Updated) { setCachedDatabases(datasourceCache.databases); setIsFirstTimeLoading(false); @@ -224,7 +224,7 @@ export const AssociatedObjectsTab: React.FC = (props) databaseCache.status === CachedDataSourceStatus.Failed) && !isCatalogCacheFetching(tablesLoadStatus) ) { - startLoadingTables(datasource.name, selectedDatabase); + startLoadingTables({ dataSourceName: datasource.name, databaseName: selectedDatabase }); setIsObjectsLoading(true); } else if (databaseCache.status === CachedDataSourceStatus.Updated) { setCachedTables(databaseCache.tables); @@ -235,7 +235,7 @@ export const AssociatedObjectsTab: React.FC = (props) isRefreshing) && !isCatalogCacheFetching(accelerationsLoadStatus) ) { - startLoadingAccelerations(datasource.name); + startLoadingAccelerations({ dataSourceName: datasource.name }); setIsObjectsLoading(true); } else if (accelerationsCache.status === CachedDataSourceStatus.Updated) { setCachedAccelerations(accelerationsCache.accelerations); diff --git a/public/components/datasources/components/manage/associated_objects/modules/associated_objects_table.tsx b/public/components/datasources/components/manage/associated_objects/modules/associated_objects_table.tsx index 3371797fe7..3f3e69d0ed 100644 --- a/public/components/datasources/components/manage/associated_objects/modules/associated_objects_table.tsx +++ b/public/components/datasources/components/manage/associated_objects/modules/associated_objects_table.tsx @@ -3,15 +3,18 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React, { useEffect, useState } from 'react'; -import _ from 'lodash'; import { EuiInMemoryTable, EuiLink, - SearchFilterConfig, EuiTableFieldDataColumnType, + SearchFilterConfig, } from '@elastic/eui'; import { i18n } from '@osd/i18n'; +import React, { useEffect, useState } from 'react'; +import { + ACCELERATION_INDEX_TYPES, + DATA_SOURCE_TYPES, +} from '../../../../../../../common/constants/data_sources'; import { AssociatedObject, CachedAcceleration, @@ -21,6 +24,7 @@ import { getRenderAssociatedObjectsDetailsFlyout, getRenderCreateAccelerationFlyout, } from '../../../../../../plugin'; +import { getAccelerationName } from '../../accelerations/utils/acceleration_utils'; import { ASSC_OBJ_TABLE_ACC_COLUMN_NAME, ASSC_OBJ_TABLE_SEARCH_HINT, @@ -28,11 +32,6 @@ import { redirectToExplorerOSIdx, redirectToExplorerWithDataSrc, } from '../utils/associated_objects_tab_utils'; -import { getAccelerationName } from '../../accelerations/utils/acceleration_utils'; -import { - ACCELERATION_INDEX_TYPES, - DATA_SOURCE_TYPES, -} from '../../../../../../../common/constants/data_sources'; interface AssociatedObjectsTableProps { datasourceName: string; @@ -70,11 +69,18 @@ export const AssociatedObjectsTable = (props: AssociatedObjectsTableProps) => { { if (item.type === 'table') { - renderAssociatedObjectsDetailsFlyout(item, datasourceName, handleRefresh); + renderAssociatedObjectsDetailsFlyout({ + tableDetail: item, + dataSourceName: datasourceName, + handleRefresh, + }); } else { const acceleration = cachedAccelerations.find((acc) => acc.indexName === item.id); if (acceleration) { - renderAccelerationDetailsFlyout(acceleration, datasourceName); + renderAccelerationDetailsFlyout({ + acceleration, + dataSourceName: datasourceName, + }); } } }} @@ -109,7 +115,11 @@ export const AssociatedObjectsTable = (props: AssociatedObjectsTableProps) => { return ( - renderAccelerationDetailsFlyout(accelerations[0], datasourceName, handleRefresh) + renderAccelerationDetailsFlyout({ + acceleration: accelerations[0], + dataSourceName: datasourceName, + handleRefresh, + }) } > {name} @@ -119,7 +129,11 @@ export const AssociatedObjectsTable = (props: AssociatedObjectsTableProps) => { return ( - renderAssociatedObjectsDetailsFlyout(obj, datasourceName, handleRefresh) + renderAssociatedObjectsDetailsFlyout({ + tableDetail: obj, + dataSourceName: datasourceName, + handleRefresh, + }) } > View all {accelerations.length} @@ -129,7 +143,11 @@ export const AssociatedObjectsTable = (props: AssociatedObjectsTableProps) => { return ( - renderAssociatedObjectsDetailsFlyout(accelerations, datasourceName, handleRefresh) + renderAssociatedObjectsDetailsFlyout({ + tableDetail: accelerations, + dataSourceName: datasourceName, + handleRefresh, + }) } > {accelerations.name} @@ -186,7 +204,12 @@ export const AssociatedObjectsTable = (props: AssociatedObjectsTableProps) => { icon: 'bolt', available: (item: AssociatedObject) => item.type === 'table', onClick: (item: AssociatedObject) => - renderCreateAccelerationFlyout(datasourceName, item.database, item.name, handleRefresh), + renderCreateAccelerationFlyout({ + dataSource: datasourceName, + databaseName: item.database, + tableName: item.tableName, + handleRefresh, + }), }, ], }, diff --git a/public/components/datasources/components/manage/data_connection.tsx b/public/components/datasources/components/manage/data_connection.tsx index 1a67284127..fee2e748d0 100644 --- a/public/components/datasources/components/manage/data_connection.tsx +++ b/public/components/datasources/components/manage/data_connection.tsx @@ -35,13 +35,13 @@ import { useLoadDatabasesToCache, useLoadTablesToCache, } from '../../../../../public/framework/catalog_cache/cache_loader'; -import { redirectToExplorerS3 } from './associated_objects/utils/associated_objects_tab_utils'; import { coreRefs } from '../../../../framework/core_refs'; import { getRenderCreateAccelerationFlyout } from '../../../../plugin'; import { NoAccess } from '../no_access'; import { AccelerationTable } from './accelerations/acceleration_table'; import { AccessControlTab } from './access_control_tab'; import { AssociatedObjectsTab } from './associated_objects/associated_objects_tab'; +import { redirectToExplorerS3 } from './associated_objects/utils/associated_objects_tab_utils'; import { InactiveDataConnectionCallout } from './inactive_data_connection'; import { InstallIntegrationFlyout, @@ -123,7 +123,7 @@ export const DataConnection = (props: { dataSource: string }) => { ) : null; const onclickAccelerationsCard = () => { - renderCreateAccelerationFlyout(dataSource); + renderCreateAccelerationFlyout({ dataSource }); }; const onclickDiscoverCard = () => { diff --git a/public/components/datasources/components/manage/manage_data_connections_table.tsx b/public/components/datasources/components/manage/manage_data_connections_table.tsx index 2a95458dde..c62c5845b9 100644 --- a/public/components/datasources/components/manage/manage_data_connections_table.tsx +++ b/public/components/datasources/components/manage/manage_data_connections_table.tsx @@ -28,16 +28,16 @@ import { DatasourceType, } from '../../../../../common/types/data_connections'; import { coreRefs } from '../../../../../public/framework/core_refs'; +import { getRenderCreateAccelerationFlyout } from '../../../../../public/plugin'; import { DeleteModal } from '../../../common/helpers/delete_modal'; import { useToast } from '../../../common/toast'; import { HomeProps } from '../../home'; import PrometheusLogo from '../../icons/prometheus-logo.svg'; import S3Logo from '../../icons/s3-logo.svg'; import { DataConnectionsHeader } from '../data_connections_header'; -import { DataConnectionsDescription } from './manage_data_connections_description'; -import { getRenderCreateAccelerationFlyout } from '../../../../../public/plugin'; -import { InstallIntegrationFlyout } from './integrations/installed_integrations_table'; import { redirectToExplorerS3 } from './associated_objects/utils/associated_objects_tab_utils'; +import { InstallIntegrationFlyout } from './integrations/installed_integrations_table'; +import { DataConnectionsDescription } from './manage_data_connections_description'; interface DataConnection { connectionType: DatasourceType; @@ -147,7 +147,7 @@ export const ManageDataConnectionsTable = (props: HomeProps) => { type: 'icon', available: (datasource: DataConnection) => datasource.connectionType !== 'PROMETHEUS', onClick: (datasource: DataConnection) => { - renderCreateAccelerationFlyout(datasource.name); + renderCreateAccelerationFlyout({ dataSource: datasource.name }); }, 'data-test-subj': 'action-accelerate', }, diff --git a/public/components/hooks/use_polling.ts b/public/components/hooks/use_polling.ts index 30127fa0f9..74fedd6cf1 100644 --- a/public/components/hooks/use_polling.ts +++ b/public/components/hooks/use_polling.ts @@ -111,7 +111,6 @@ export function usePolling( try { const result = await fetchFunction(params); setData(result); - console.log(result); // Check the success condition and stop polling if it's met if (onPollingSuccess && onPollingSuccess(result, configurations)) { stopPolling(); diff --git a/public/framework/catalog_cache/cache_loader.tsx b/public/framework/catalog_cache/cache_loader.tsx index f1775eb908..294346c441 100644 --- a/public/framework/catalog_cache/cache_loader.tsx +++ b/public/framework/catalog_cache/cache_loader.tsx @@ -339,7 +339,6 @@ export const useLoadToCache = (loadCacheType: LoadCacheType) => { sqlService .fetch(requestPayload, dataSourceMDSId) .then((result) => { - console.log(result); setAsyncSessionId(dataSourceName, getObjValue(result, 'sessionId', null)); if (result.queryId) { startPolling({ diff --git a/public/plugin.tsx b/public/plugin.tsx index c6ac1f8299..251bb4348c 100644 --- a/public/plugin.tsx +++ b/public/plugin.tsx @@ -3,9 +3,9 @@ * SPDX-License-Identifier: Apache-2.0 */ -import React from 'react'; -import { i18n } from '@osd/i18n'; import { htmlIdGenerator } from '@elastic/eui'; +import { i18n } from '@osd/i18n'; +import React from 'react'; import { AppCategory, AppMountParameters, @@ -18,6 +18,12 @@ import { } from '../../../src/core/public'; import { toMountPoint } from '../../../src/plugins/opensearch_dashboards_react/public/'; import { createGetterSetter } from '../../../src/plugins/opensearch_dashboards_utils/public'; +import { + DATA_SOURCE_TYPES, + OBS_S3_DATA_SOURCE, + S3_DATA_SOURCE_GROUP_DISPLAY_NAME, + S3_DATA_SOURCE_GROUP_SPARK_DISPLAY_NAME, +} from '../common/constants/data_sources'; import { CREATE_TAB_PARAM, CREATE_TAB_PARAM_KEY, TAB_CHART_ID } from '../common/constants/explorer'; import { DATACONNECTIONS_BASE, @@ -50,7 +56,11 @@ import { observabilityTracesTitle, } from '../common/constants/shared'; import { QueryManager } from '../common/query_manager'; -import { AssociatedObject, CachedAcceleration } from '../common/types/data_connections'; +import { + RenderAccelerationDetailsFlyoutParams, + RenderAccelerationFlyoutParams, + RenderAssociatedObjectsDetailsFlyoutParams, +} from '../common/types/data_connections'; import { VISUALIZATION_SAVED_OBJECT } from '../common/types/observability_saved_object_attributes'; import { setOSDHttp, @@ -96,12 +106,6 @@ import { ObservabilityStart, SetupDependencies, } from './types'; -import { - DATA_SOURCE_TYPES, - OBS_S3_DATA_SOURCE, - S3_DATA_SOURCE_GROUP_DISPLAY_NAME, - S3_DATA_SOURCE_GROUP_SPARK_DISPLAY_NAME, -} from '../common/constants/data_sources'; interface PublicConfig { query_assist: { @@ -116,37 +120,37 @@ export const [ getRenderAccelerationDetailsFlyout, setRenderAccelerationDetailsFlyout, ] = createGetterSetter< - ( - acceleration: CachedAcceleration, - dataSourceName: string, - handleRefresh?: () => void, - dataSourceMDSId?: string - ) => void + ({ + acceleration, + dataSourceName, + handleRefresh, + dataSourceMDSId, + }: RenderAccelerationDetailsFlyoutParams) => void >('renderAccelerationDetailsFlyout'); export const [ getRenderAssociatedObjectsDetailsFlyout, setRenderAssociatedObjectsDetailsFlyout, ] = createGetterSetter< - ( - tableDetail: AssociatedObject, - datasourceName: string, - handleRefresh?: () => void, - dataSourceMDSId?: string - ) => void + ({ + tableDetail, + dataSourceName, + handleRefresh, + dataSourceMDSId, + }: RenderAssociatedObjectsDetailsFlyoutParams) => void >('renderAssociatedObjectsDetailsFlyout'); export const [ getRenderCreateAccelerationFlyout, setRenderCreateAccelerationFlyout, ] = createGetterSetter< - ( - dataSource: string, - dataSourceMDSId?: string, - databaseName?: string, - tableName?: string, - handleRefresh?: () => void - ) => void + ({ + dataSource, + dataSourceMDSId, + databaseName, + tableName, + handleRefresh, + }: RenderAccelerationFlyoutParams) => void >('renderCreateAccelerationFlyout'); export class ObservabilityPlugin @@ -473,12 +477,12 @@ export class ObservabilityPlugin }); // Use overlay service to render flyouts - const renderAccelerationDetailsFlyout = ( - acceleration: CachedAcceleration, - dataSourceName: string, - handleRefresh?: () => void, - dataSourceMDSId?: string - ) => { + const renderAccelerationDetailsFlyout = ({ + acceleration, + dataSourceName, + handleRefresh, + dataSourceMDSId, + }: RenderAccelerationDetailsFlyoutParams) => { const accelerationDetailsFlyout = core.overlays.openFlyout( toMountPoint( void, - dataSourceMDSId?: string - ) => { + const renderAssociatedObjectsDetailsFlyout = ({ + tableDetail, + dataSourceName, + handleRefresh, + dataSourceMDSId, + }: RenderAssociatedObjectsDetailsFlyoutParams) => { const associatedObjectsDetailsFlyout = core.overlays.openFlyout( toMountPoint( associatedObjectsDetailsFlyout.close()} handleRefresh={handleRefresh} dataSourceMDSId={dataSourceMDSId} @@ -513,17 +517,17 @@ export class ObservabilityPlugin }; setRenderAssociatedObjectsDetailsFlyout(renderAssociatedObjectsDetailsFlyout); - const renderCreateAccelerationFlyout = ( - selectedDatasource: string, - dataSourceMDSId?: string, - databaseName?: string, - tableName?: string, - handleRefresh?: () => void - ) => { + const renderCreateAccelerationFlyout = ({ + dataSource, + databaseName, + tableName, + handleRefresh, + dataSourceMDSId, + }: RenderAccelerationFlyoutParams) => { const createAccelerationFlyout = core.overlays.openFlyout( toMountPoint( createAccelerationFlyout.close()} databaseName={databaseName} tableName={tableName} diff --git a/public/services/requests/sql.ts b/public/services/requests/sql.ts index 9b9bd9f933..fc577ca5f7 100644 --- a/public/services/requests/sql.ts +++ b/public/services/requests/sql.ts @@ -38,7 +38,7 @@ export class SQLService { errorHandler?: (error: any) => void ) => { return this.http - .get(`/api/observability/query/jobs/${params.queryId}/${dataSourceMDSId}`) + .get(`/api/observability/query/jobs/${params.queryId}/${dataSourceMDSId ?? ''}`) .catch((error) => { console.error('fetch error: ', error.body); if (errorHandler) errorHandler(error); diff --git a/public/types.ts b/public/types.ts index 86ca51e65c..0075f1ce27 100644 --- a/public/types.ts +++ b/public/types.ts @@ -17,9 +17,10 @@ import { NavigationPublicPluginStart } from '../../../src/plugins/navigation/pub import { UiActionsStart } from '../../../src/plugins/ui_actions/public'; import { VisualizationsSetup } from '../../../src/plugins/visualizations/public'; import { - AssociatedObject, - CachedAcceleration, LoadCachehookOutput, + RenderAccelerationDetailsFlyoutParams, + RenderAccelerationFlyoutParams, + RenderAssociatedObjectsDetailsFlyoutParams, } from '../common/types/data_connections'; import { CatalogCacheManager } from './framework/catalog_cache/cache_manager'; import { AssistantSetup } from './types'; @@ -49,23 +50,24 @@ export interface SetupDependencies { export interface ObservabilitySetup {} export interface ObservabilityStart { - renderAccelerationDetailsFlyout: ( - acceleration: CachedAcceleration, - datasourceName: string, - handleRefresh?: () => void - ) => void; - renderAssociatedObjectsDetailsFlyout: ( - tableDetail: AssociatedObject, - datasourceName: string, - handleRefresh?: () => void - ) => void; - renderCreateAccelerationFlyout: ( - dataSource: string, - dataSourceMDSId?: string, - databaseName?: string, - tableName?: string, - handleRefresh?: () => void - ) => void; + renderAccelerationDetailsFlyout: ({ + acceleration, + dataSourceName, + handleRefresh, + dataSourceMDSId, + }: RenderAccelerationDetailsFlyoutParams) => void; + renderAssociatedObjectsDetailsFlyout: ({ + tableDetail, + dataSourceName, + handleRefresh, + }: RenderAssociatedObjectsDetailsFlyoutParams) => void; + renderCreateAccelerationFlyout: ({ + dataSource, + dataSourceMDSId, + databaseName, + tableName, + handleRefresh, + }: RenderAccelerationFlyoutParams) => void; CatalogCacheManagerInstance: typeof CatalogCacheManager; useLoadDatabasesToCacheHook: () => LoadCachehookOutput; useLoadTablesToCacheHook: () => LoadCachehookOutput;