@@ -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