Skip to content

Commit d086df0

Browse files
author
Adam Tackett
committed
default data source info
Signed-off-by: Adam Tackett <tackadam@amazon.com>
1 parent d53e171 commit d086df0

1 file changed

Lines changed: 15 additions & 17 deletions

File tree

src/plugins/data/common/data_views/data_views/data_views.ts

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -751,32 +751,30 @@ export class DataViewsService {
751751
// Fetch actual data source to get its title and version
752752
let dataSourceInfo;
753753
if (dataView.dataSourceRef?.id) {
754+
// Default dataSourceInfo with common fields
755+
const defaultDataSourceInfo = {
756+
id: dataView.dataSourceRef.id,
757+
title: dataView.dataSourceRef.id,
758+
type: dataView.dataSourceRef.type || DEFAULT_DATA.SOURCE_TYPES.OPENSEARCH,
759+
version: '',
760+
};
761+
754762
try {
755763
const dataSource = await this.getDataSource(dataView.dataSourceRef.id);
756764
if (dataSource) {
765+
// Override with actual data source title and version if available
757766
dataSourceInfo = {
758-
id: dataView.dataSourceRef.id,
759-
title: dataSource.attributes?.title || dataView.dataSourceRef.id,
760-
type: dataView.dataSourceRef.type || DEFAULT_DATA.SOURCE_TYPES.OPENSEARCH,
767+
...defaultDataSourceInfo,
768+
title: dataSource.attributes?.title || defaultDataSourceInfo.title,
761769
version: dataSource.attributes?.dataSourceVersion || '',
762770
};
763771
} else {
764-
// If dataSource is null/undefined, fall back to using the reference ID as title
765-
dataSourceInfo = {
766-
id: dataView.dataSourceRef.id,
767-
title: dataView.dataSourceRef.id,
768-
type: dataView.dataSourceRef.type || DEFAULT_DATA.SOURCE_TYPES.OPENSEARCH,
769-
version: '',
770-
};
772+
// If dataSource is null/undefined, use default
773+
dataSourceInfo = defaultDataSourceInfo;
771774
}
772775
} catch (error) {
773-
// If fetching fails, fall back to using the reference ID as title
774-
dataSourceInfo = {
775-
id: dataView.dataSourceRef.id,
776-
title: dataView.dataSourceRef.id,
777-
type: dataView.dataSourceRef.type || DEFAULT_DATA.SOURCE_TYPES.OPENSEARCH,
778-
version: '',
779-
};
776+
// If fetching fails, use default
777+
dataSourceInfo = defaultDataSourceInfo;
780778
}
781779
}
782780

0 commit comments

Comments
 (0)