Skip to content

Commit

Permalink
[Discover 2.0] Loading fix for databases (#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 #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();

Check warning on line 290 in src/plugins/data/public/ui/dataset_navigator/dataset_navigator.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/dataset_navigator/dataset_navigator.tsx#L289-L290

Added lines #L289 - L290 were not covered by tests
if (
selectedDataSetState?.dataSourceRef &&
selectedDataSetState.dataSourceRef.type === SIMPLE_DATA_SOURCE_TYPES.EXTERNAL
) {
const dataSourceCache = CatalogCacheManager.getOrCreateDataSource(

Check warning on line 295 in src/plugins/data/public/ui/dataset_navigator/dataset_navigator.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/dataset_navigator/dataset_navigator.tsx#L295

Added line #L295 was not covered by tests
selectedDataSetState.dataSourceRef.name,
selectedDataSetState.dataSourceRef.id
);
if (status === DirectQueryLoadingStatus.SUCCESS) {
setCachedDatabases(
dataSourceCache.databases.map((db) => ({ id: db.name, title: db.name }))

Check warning on line 301 in src/plugins/data/public/ui/dataset_navigator/dataset_navigator.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/dataset_navigator/dataset_navigator.tsx#L300-L301

Added lines #L300 - L301 were not covered by tests
);
} else if (
status === DirectQueryLoadingStatus.CANCELED ||
status === DirectQueryLoadingStatus.FAILED
) {
notifications.toasts.addWarning('Error loading databases');

Check warning on line 307 in src/plugins/data/public/ui/dataset_navigator/dataset_navigator.tsx

View check run for this annotation

Codecov / codecov/patch

src/plugins/data/public/ui/dataset_navigator/dataset_navigator.tsx#L307

Added line #L307 was not covered by tests
}
}
}, [databasesLoadStatus, selectedDataSetState?.dataSourceRef, notifications.toasts]);

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

0 comments on commit 63917ef

Please sign in to comment.