-
Notifications
You must be signed in to change notification settings - Fork 894
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
[MD]Allow create and distinguish index pattern with same name but from different datasources #3604
[MD]Allow create and distinguish index pattern with same name but from different datasources #3604
Conversation
…datasources Signed-off-by: Su <szhongna@amazon.com>
45323e7
to
1601f23
Compare
Signed-off-by: Su <szhongna@amazon.com>
1601f23
to
c402636
Compare
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #3604 +/- ##
==========================================
- Coverage 66.43% 66.42% -0.02%
==========================================
Files 3210 3210
Lines 61677 61722 +45
Branches 9522 9530 +8
==========================================
+ Hits 40977 40996 +19
- Misses 18419 18440 +21
- Partials 2281 2286 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Could we add some screenshots for the view across updated pages? |
847ac7d
to
f29f3ac
Compare
In the case where plugins or core interact directly through indices but not through index pattern. Maybe we could open an issue to track it? This could be solved by a global datasource picker in long term but still pending on the design. Looking for your thoughts on this :D - Overall LGTM |
This is an issue opened for a global datasource picker, still under discussion. #2841. For plugins to interact with indices in datasource. We provide the sever side API |
Signed-off-by: Su <szhongna@amazon.com>
src/plugins/discover/public/application/components/sidebar/discover_index_pattern.tsx
Show resolved
Hide resolved
Last comment, I think |
Signed-off-by: Su <szhongna@amazon.com>
…n-poc Signed-off-by: Su <szhongna@amazon.com>
const savedObjects = await Promise.all( | ||
findResponse.saved_objects.map(async (obj) => { | ||
if (obj.type === 'index-pattern') { | ||
const result = { ...obj }; | ||
result.attributes.title = await getIndexPatternTitle( | ||
obj.attributes.title, | ||
obj.references, | ||
getDataSource | ||
); | ||
return result; | ||
} else { | ||
return obj; | ||
} | ||
}) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my other comment above, this logic shouldn't be here, it should be accounted for in the saved object management definition: https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/data/server/saved_objects/index_patterns.ts#L42-L44
if (obj.type === 'index-pattern') { | ||
const result = { ...obj }; | ||
result.attributes.title = await getIndexPatternTitle( | ||
obj.attributes.title!, | ||
obj.references, | ||
getDataSource | ||
); | ||
return result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing an explicit type check within the generalized saved_object
plugin seems like an antipattern. Ideally, any logic unique to a particular saved object should exist in that saved object definition (index-pattern
, in this case).
Luckily, there are better patterns available to do what we're doing here. One option is to provide a custom title
getter method in the index-pattern saved object definition, if we always want the title to have the appended data source. Alternatively, if we sometimes need just the index pattern title, and other times need the appended version, we can just define a new custom property, such as "displayTitle" and have this logic in the getter for that.
As an example, see how the visualize
plugin provides its own custom finder method as part of the saved object loader: https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/visualizations/public/saved_visualizations/saved_visualizations.ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prepending datasource to title requires fetching datasource name first, which replies on a saved object client to make a call. This should happen where there's a client to use.
saved object management definition
doesn't provide client , passing it tomagement -> getTitlte()
will change the interface that shard by other saved object. And to pass it for index-pattern type only, again need explicit check.index-pattern saved object
can't provide client, because unfortunately unlikesavedVis
that you referred to, there's noSavedIndexPattern extends SavedObjectClass
exists. Don't think it's worth to create one only for prepending datasource to the title for display purpose. Comparing to visualization, index patterns are comparatively simpler objects
Besides, there's an issue under discussion about having an OUI component that can be used to select datasource then index pattern when creating Visualzaiton/Dashboards/Discover. #2841. The logic we have here may need be refactored after that discussion is settled.
Thanks for bringing this up, this might not be a good pattern to use, but it might not be a blocker for this PR. Can we create an issue to track and address in the future improvements? Does it sound good to you? @joshuarrrr
@joshuarrrr @ananzh @kristenTian Add some more context to help with review Two issues we are addressing in this PR
|
…m different datasources (#3604) *[Multiple Datasource] Allow create and distinguish index pattern with same name but from different datasources Signed-off-by: Su <szhongna@amazon.com> (cherry picked from commit b656658) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…m different datasources (#3604) (#3801) *[Multiple Datasource] Allow create and distinguish index pattern with same name but from different datasources (cherry picked from commit b656658) Signed-off-by: Su <szhongna@amazon.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…m different datasources (opensearch-project#3604) *[Multiple Datasource] Allow create and distinguish index pattern with same name but from different datasources Signed-off-by: Su <szhongna@amazon.com> Signed-off-by: David Sinclair <david@sinclair.tech>
Description
Prepend datasource name to index pattern title in UI to distinguish across different data source. This is aligned with UX designer
getIndexPatternTitle()
util function in data plugin -> index pattern service to prepend datasource name to index pattern title for display purpose. E.gmy-datasource.my-index-pattern
getIndexPatternTitle()
util function provided by data pluginScreenshots
current "create index pattern" flow:
updated to allow creating same index pattern name with different datasources
updated saved object management view:
updated index pattern display in Discover
updated index pattern display in create visualization
Issues Resolved
#2592
#2599
Check List
yarn test:jest
yarn test:jest_integration
yarn test:ftr