Skip to content

Commit

Permalink
[Discover 2.0] Loading fix for databases (opensearch-project#7567)
Browse files Browse the repository at this point in the history
* add back in useeffect for loading databases

Signed-off-by: Sean Li <[email protected]>

* Changeset file for PR opensearch-project#7567 created/updated

---------

Signed-off-by: Sean Li <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and ananzh committed Jul 30, 2024
1 parent ea4071c commit 63917ef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/7567.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fix:
- Fixes databases not being displayed upon success ([#7567](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/7567))
23 changes: 23 additions & 0 deletions src/plugins/data/public/ui/dataset_navigator/dataset_navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,29 @@ export const DataSetNavigator: React.FC<DataSetNavigatorProps> = ({
[selectedDataSetState?.dataSourceRef, tablesLoadStatus, startLoadingTables]
);

useEffect(() => {
const status = databasesLoadStatus.toLowerCase();
if (
selectedDataSetState?.dataSourceRef &&
selectedDataSetState.dataSourceRef.type === SIMPLE_DATA_SOURCE_TYPES.EXTERNAL
) {
const dataSourceCache = CatalogCacheManager.getOrCreateDataSource(
selectedDataSetState.dataSourceRef.name,
selectedDataSetState.dataSourceRef.id
);
if (status === DirectQueryLoadingStatus.SUCCESS) {
setCachedDatabases(
dataSourceCache.databases.map((db) => ({ id: db.name, title: db.name }))
);
} else if (
status === DirectQueryLoadingStatus.CANCELED ||
status === DirectQueryLoadingStatus.FAILED
) {
notifications.toasts.addWarning('Error loading databases');
}
}
}, [databasesLoadStatus, selectedDataSetState?.dataSourceRef, notifications.toasts]);

useEffect(() => {
if (
selectedDataSetState?.dataSourceRef &&
Expand Down

0 comments on commit 63917ef

Please sign in to comment.