diff --git a/src/plugins/data_source_management/framework/catlog_cache/cache_loader.tsx b/src/plugins/data_source_management/framework/catlog_cache/cache_loader.tsx index 9566aa8727c9..26d6a43e8ebe 100644 --- a/src/plugins/data_source_management/framework/catlog_cache/cache_loader.tsx +++ b/src/plugins/data_source_management/framework/catlog_cache/cache_loader.tsx @@ -285,8 +285,7 @@ export const createLoadQuery = ( export const useLoadToCache = ( loadCacheType: LoadCacheType, http: HttpStart, - notifications: NotificationsStart, - dataSourceMDSId?: string + notifications: NotificationsStart ) => { const sqlService = new SQLService(http); const [currentDataSourceName, setCurrentDataSourceName] = useState(''); @@ -297,13 +296,6 @@ export const useLoadToCache = ( ); const dataSourceMDSClientId = useRef(''); - // Set dataSourceMDSClientId.current if dataSourceMDSId is provided - useEffect(() => { - if (dataSourceMDSId !== undefined) { - dataSourceMDSClientId.current = dataSourceMDSId; - } - }, [dataSourceMDSId]); - const { data: pollingResult, loading: _pollingLoading, @@ -328,7 +320,7 @@ export const useLoadToCache = ( const startLoading = ({ dataSourceName, - dataSourceMDSId: startLoadingDataSourceMDSId, + dataSourceMDSId, databaseName, tableName, }: StartLoadingParams) => { @@ -336,9 +328,7 @@ export const useLoadToCache = ( setCurrentDataSourceName(dataSourceName); setCurrentDatabaseName(databaseName); setCurrentTableName(tableName); - if (startLoadingDataSourceMDSId !== undefined) { - dataSourceMDSClientId.current = startLoadingDataSourceMDSId; - } + dataSourceMDSClientId.current = dataSourceMDSId || ''; let requestPayload: DirectQueryRequest = { lang: 'sql', @@ -418,58 +408,34 @@ export const useLoadToCache = ( return { loadStatus, startLoading, stopLoading }; }; -export const useLoadDatabasesToCache = ( - http: HttpStart, - notifications: NotificationsStart, - dataSourceMDSId: string -) => { +export const useLoadDatabasesToCache = (http: HttpStart, notifications: NotificationsStart) => { const { loadStatus, startLoading, stopLoading } = useLoadToCache( 'databases', http, - notifications, - dataSourceMDSId + notifications ); return { loadStatus, startLoading, stopLoading }; }; -export const useLoadTablesToCache = ( - http: HttpStart, - notifications: NotificationsStart, - dataSourceMDSId: string -) => { - const { loadStatus, startLoading, stopLoading } = useLoadToCache( - 'tables', - http, - notifications, - dataSourceMDSId - ); +export const useLoadTablesToCache = (http: HttpStart, notifications: NotificationsStart) => { + const { loadStatus, startLoading, stopLoading } = useLoadToCache('tables', http, notifications); return { loadStatus, startLoading, stopLoading }; }; -export const useLoadTableColumnsToCache = ( - http: HttpStart, - notifications: NotificationsStart, - dataSourceMDSId: string -) => { +export const useLoadTableColumnsToCache = (http: HttpStart, notifications: NotificationsStart) => { const { loadStatus, startLoading, stopLoading } = useLoadToCache( 'tableColumns', http, - notifications, - dataSourceMDSId + notifications ); return { loadStatus, startLoading, stopLoading }; }; -export const useLoadAccelerationsToCache = ( - http: HttpStart, - notifications: NotificationsStart, - dataSourceMDSId: string -) => { +export const useLoadAccelerationsToCache = (http: HttpStart, notifications: NotificationsStart) => { const { loadStatus, startLoading, stopLoading } = useLoadToCache( 'accelerations', http, - notifications, - dataSourceMDSId + notifications ); return { loadStatus, startLoading, stopLoading }; }; diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/create/create_acceleration.tsx b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/create/create_acceleration.tsx index 77571f1f2a6a..4c36d6bb095d 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/create/create_acceleration.tsx +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/create/create_acceleration.tsx @@ -113,7 +113,7 @@ export const CreateAcceleration = ({ loadStatus, startLoading, stopLoading: stopLoadingTableFields, - } = useLoadTableColumnsToCache(http, notifications, dataSourceMDSId); + } = useLoadTableColumnsToCache(http, notifications); const loadColumnsToAccelerationForm = (cachedTable: CachedTable) => { const idPrefix = htmlIdGenerator()(); diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/selector_helpers/load_databases.tsx b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/selector_helpers/load_databases.tsx index ddb2389fef67..1a59ff1b5184 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/selector_helpers/load_databases.tsx +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/selector_helpers/load_databases.tsx @@ -41,14 +41,11 @@ export const SelectorLoadDatabases = ({ notifications, }: SelectorLoadDatabasesProps) => { const [isLoading, setIsLoading] = useState(false); - if (dataSourceMDSId === undefined) { - dataSourceMDSId = ''; - } const { loadStatus: loadDatabasesStatus, startLoading: startDatabasesLoading, stopLoading: stopDatabasesLoading, - } = useLoadDatabasesToCache(http, notifications, dataSourceMDSId); + } = useLoadDatabasesToCache(http, notifications); const onClickRefreshDatabases = () => { setIsLoading(true); diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/selector_helpers/load_objects.tsx b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/selector_helpers/load_objects.tsx index b2cfe85209de..34ba32111b13 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/selector_helpers/load_objects.tsx +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/selector_helpers/load_objects.tsx @@ -51,19 +51,16 @@ export const SelectorLoadObjects = ({ accelerationsStatus: false, }); const isEitherLoading = isLoading.accelerationsStatus || isLoading.tableStatus; - if (dataSourceMDSId === undefined) { - dataSourceMDSId = ''; - } const { loadStatus: loadTablesStatus, startLoading: startLoadingTables, stopLoading: stopLoadingTables, - } = useLoadTablesToCache(http, notifications, dataSourceMDSId); + } = useLoadTablesToCache(http, notifications); const { loadStatus: loadAccelerationsStatus, startLoading: startLoadingAccelerations, stopLoading: stopLoadingAccelerations, - } = useLoadAccelerationsToCache(http, notifications, dataSourceMDSId); + } = useLoadAccelerationsToCache(http, notifications); const onClickRefreshDatabases = () => { if (databaseName === '') { diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/source_selector.tsx b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/source_selector.tsx index 5db499f0b163..a3be90cb1dd2 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/source_selector.tsx +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_creation/selectors/source_selector.tsx @@ -97,7 +97,10 @@ export const AccelerationDataSourceSelector = ({ }; const loadDatabases = () => { - const dsCache = CatalogCacheManager.getOrCreateDataSource(accelerationFormData.dataSource); + const dsCache = CatalogCacheManager.getOrCreateDataSource( + accelerationFormData.dataSource, + dataSourceMDSId + ); if (dsCache.status === CachedDataSourceStatus.Updated && dsCache.databases.length > 0) { const databaseLabels = dsCache.databases.map((db) => ({ label: db.name })); @@ -121,7 +124,8 @@ export const AccelerationDataSourceSelector = ({ try { dbCache = CatalogCacheManager.getDatabase( accelerationFormData.dataSource, - accelerationFormData.database + accelerationFormData.database, + dataSourceMDSId ); if (dbCache.status === CachedDataSourceStatus.Updated && dbCache.tables.length > 0) { const tableLabels = dbCache.tables.map((tb) => ({ label: tb.name })); diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_management/acceleration_table.tsx b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_management/acceleration_table.tsx index 68d7f8ae39b6..0335137c3fd3 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_management/acceleration_table.tsx +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_acceleration_management/acceleration_table.tsx @@ -98,7 +98,7 @@ export const AccelerationTable = ({ !isCatalogCacheFetching(accelerationsLoadStatus) ) { setIsRefreshing(true); - startLoadingAccelerations({ dataSourceName }); + startLoadingAccelerations({ dataSourceName, dataSourceMDSId }); } else { setAccelerations(cachedDataSource.accelerations); setUpdatedTime(cachedDataSource.lastUpdated); @@ -125,7 +125,7 @@ export const AccelerationTable = ({ const handleRefresh = useCallback(() => { if (!isCatalogCacheFetching(accelerationsLoadStatus)) { setIsRefreshing(true); - startLoadingAccelerations({ dataSourceName }); + startLoadingAccelerations({ dataSourceName, dataSourceMDSId }); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [accelerationsLoadStatus]); diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_associated_object_management/associated_objects_details_flyout.tsx b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_associated_object_management/associated_objects_details_flyout.tsx index b51aa0ef20c2..9b59ad067f5e 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_associated_object_management/associated_objects_details_flyout.tsx +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_associated_object_management/associated_objects_details_flyout.tsx @@ -74,14 +74,7 @@ export const AssociatedObjectsDetailsFlyout = ({ dataSourceMDSId, application, }: AssociatedObjectsFlyoutProps) => { - if (dataSourceMDSId === undefined) { - dataSourceMDSId = ''; - } - const { loadStatus, startLoading } = useLoadTableColumnsToCache( - http, - notifications, - dataSourceMDSId - ); + const { loadStatus, startLoading } = useLoadTableColumnsToCache(http, notifications); const [tableColumns, setTableColumns] = useState([]); const [schemaData, setSchemaData] = useState([]); @@ -222,6 +215,7 @@ export const AssociatedObjectsDetailsFlyout = ({ databaseName: tableDetail.database, tableName: tableDetail.name, handleRefresh, + dataSourceMDSId, }) } iconType="popout" @@ -256,7 +250,8 @@ export const AssociatedObjectsDetailsFlyout = ({ const tables = CatalogCacheManager.getTable( datasourceName, tableDetail.database, - tableDetail.name + tableDetail.name, + dataSourceMDSId ); if (tables?.columns) { setTableColumns(tables?.columns); @@ -265,6 +260,7 @@ export const AssociatedObjectsDetailsFlyout = ({ dataSourceName: datasourceName, databaseName: tableDetail.database, tableName: tableDetail.name, + dataSourceMDSId, }); } } catch (error) { @@ -285,7 +281,8 @@ export const AssociatedObjectsDetailsFlyout = ({ columns = CatalogCacheManager.getTable( datasourceName, tableDetail.database, - tableDetail.name + tableDetail.name, + dataSourceMDSId ).columns; setTableColumns(columns); } catch (error) { diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_associated_object_management/associated_objects_tab.tsx b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_associated_object_management/associated_objects_tab.tsx index be61eb78ef14..786e3c590881 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_associated_object_management/associated_objects_tab.tsx +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_associated_object_management/associated_objects_tab.tsx @@ -111,7 +111,7 @@ export const AssociatedObjectsTab: React.FC = (props) const onRefreshButtonClick = () => { if (!isCatalogCacheFetching(databasesLoadStatus, tablesLoadStatus, accelerationsLoadStatus)) { - startLoadingDatabases({ dataSourceName: datasource.name }); + startLoadingDatabases({ dataSourceName: datasource.name, dataSourceMDSId }); setIsRefreshing(true); } }; @@ -172,13 +172,16 @@ export const AssociatedObjectsTab: React.FC = (props) // Load databases if empty or retrieve from cache if updated useEffect(() => { if (datasource.name) { - const datasourceCache = CatalogCacheManager.getOrCreateDataSource(datasource.name); + const datasourceCache = CatalogCacheManager.getOrCreateDataSource( + datasource.name, + dataSourceMDSId + ); if ( (datasourceCache.status === CachedDataSourceStatus.Empty || datasourceCache.status === CachedDataSourceStatus.Failed) && !isCatalogCacheFetching(databasesLoadStatus) ) { - startLoadingDatabases({ dataSourceName: datasource.name }); + startLoadingDatabases({ dataSourceName: datasource.name, dataSourceMDSId }); } else if (datasourceCache.status === CachedDataSourceStatus.Updated) { setCachedDatabases(datasourceCache.databases); setIsFirstTimeLoading(false); @@ -190,7 +193,10 @@ export const AssociatedObjectsTab: React.FC = (props) // Retrieve from cache upon load success useEffect(() => { const status = databasesLoadStatus.toLowerCase(); - const datasourceCache = CatalogCacheManager.getOrCreateDataSource(datasource.name); + const datasourceCache = CatalogCacheManager.getOrCreateDataSource( + datasource.name, + dataSourceMDSId + ); if (status === DirectQueryLoadingStatus.SUCCESS) { setCachedDatabases(datasourceCache.databases); setIsFirstTimeLoading(false); @@ -201,6 +207,7 @@ export const AssociatedObjectsTab: React.FC = (props) setDatabasesLoadFailed(true); setIsFirstTimeLoading(false); } + // eslint-disable-next-line react-hooks/exhaustive-deps }, [datasource.name, databasesLoadStatus]); const handleObjectsLoad = ( @@ -222,7 +229,11 @@ export const AssociatedObjectsTab: React.FC = (props) if (datasource.name && selectedDatabase) { let databaseCache; try { - databaseCache = CatalogCacheManager.getDatabase(datasource.name, selectedDatabase); + databaseCache = CatalogCacheManager.getDatabase( + datasource.name, + selectedDatabase, + dataSourceMDSId + ); } catch (error) { // eslint-disable-next-line no-console console.error(error); @@ -238,7 +249,11 @@ export const AssociatedObjectsTab: React.FC = (props) databaseCache.status === CachedDataSourceStatus.Failed) && !isCatalogCacheFetching(tablesLoadStatus) ) { - startLoadingTables({ dataSourceName: datasource.name, databaseName: selectedDatabase }); + startLoadingTables({ + dataSourceName: datasource.name, + databaseName: selectedDatabase, + dataSourceMDSId, + }); setIsObjectsLoading(true); } else if (databaseCache.status === CachedDataSourceStatus.Updated) { setCachedTables(databaseCache.tables); @@ -249,7 +264,7 @@ export const AssociatedObjectsTab: React.FC = (props) isRefreshing) && !isCatalogCacheFetching(accelerationsLoadStatus) ) { - startLoadingAccelerations({ dataSourceName: datasource.name }); + startLoadingAccelerations({ dataSourceName: datasource.name, dataSourceMDSId }); setIsObjectsLoading(true); } else if (accelerationsCache.status === CachedDataSourceStatus.Updated) { setCachedAccelerations(accelerationsCache.accelerations); @@ -264,7 +279,11 @@ export const AssociatedObjectsTab: React.FC = (props) const tablesStatus = tablesLoadStatus.toLowerCase(); let databaseCache; try { - databaseCache = CatalogCacheManager.getDatabase(datasource.name, selectedDatabase); + databaseCache = CatalogCacheManager.getDatabase( + datasource.name, + selectedDatabase, + dataSourceMDSId + ); } catch (error) { // eslint-disable-next-line no-console console.error(error); @@ -273,8 +292,8 @@ export const AssociatedObjectsTab: React.FC = (props) } const accelerationsStatus = accelerationsLoadStatus.toLowerCase(); const accelerationsCache = CatalogCacheManager.getOrCreateAccelerationsByDataSource( - datasource.name - // dataSourceMDSId + datasource.name, + dataSourceMDSId ); if (tablesStatus === DirectQueryLoadingStatus.SUCCESS) { setCachedTables(databaseCache.tables); diff --git a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_connection_detail/direct_query_connection_detail.tsx b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_connection_detail/direct_query_connection_detail.tsx index 599ccd1de011..8efbd9b9ff7d 100644 --- a/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_connection_detail/direct_query_connection_detail.tsx +++ b/src/plugins/data_source_management/public/components/direct_query_data_sources_components/direct_query_connection_detail/direct_query_connection_detail.tsx @@ -63,7 +63,6 @@ export const DirectQueryDataConnectionDetail: React.FC({ allowedRoles: [], name: '', @@ -82,12 +81,11 @@ export const DirectQueryDataConnectionDetail: React.FC(''); @@ -95,7 +93,7 @@ export const DirectQueryDataConnectionDetail: React.FC + + + {canManageDataSource && ( @@ -75,20 +84,6 @@ export async function mountManagementSection( )} - - - - {featureFlagStatus && ( - - - - )}