Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover 2.0] Loading fix for databases #7567

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,29 @@
[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
Loading