Skip to content

Commit

Permalink
Add data source info in discover url when navigating (#347)
Browse files Browse the repository at this point in the history
* add data source in url

Signed-off-by: tygao <[email protected]>

* doc: add changelog

Signed-off-by: tygao <[email protected]>

---------

Signed-off-by: tygao <[email protected]>
  • Loading branch information
raintygao authored Oct 12, 2024
1 parent 2f06c5d commit f7fde7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- fix: Fix unrecognized creating index pattern duplicate cases([#337](https://github.com/opensearch-project/dashboards-assistant/pull/337))
- fix: Remove the cache of insight agent id in node server([#343](https://github.com/opensearch-project/dashboards-assistant/pull/343))
- fix: Fix error time field and add filter for same name index patterns([#345](https://github.com/opensearch-project/dashboards-assistant/pull/345))
- refactor: Add data source info in discover url when navigating([#347](https://github.com/opensearch-project/dashboards-assistant/pull/347))


### 📈 Features/Enhancements
Expand Down
13 changes: 9 additions & 4 deletions public/utils/alerting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,17 @@ export const buildUrlQuery = async (
from: timeDsl.from,
to: timeDsl.to,
};
let indexPatternTitle = indexPattern.title;
const indexPatternTitle = indexPattern.title;
let dataSource;
if (dataSourceId) {
try {
const dataSourceObject = await savedObjects.client.get('data-source', dataSourceId);
const dataSourceTitle = dataSourceObject?.get('title');
// If index pattern refers to a data source, discover list will display data source name as dataSourceTitle::indexPatternTitle
indexPatternTitle = `${dataSourceTitle}::${indexPatternTitle}`;
const dataSourceTitle = dataSourceObject?.get('title') ?? '';
dataSource = {
id: dataSourceId,
title: dataSourceTitle,
type: 'OpenSearch',
};
} catch (e) {
console.error('Get data source object error');
}
Expand All @@ -107,6 +111,7 @@ export const buildUrlQuery = async (
id: indexPattern.id,
timeFieldName: indexPattern.timeFieldName,
title: indexPatternTitle,
...(dataSource ? { dataSource } : {}),
},
language: 'kuery',
query: '',
Expand Down

0 comments on commit f7fde7d

Please sign in to comment.