-
Notifications
You must be signed in to change notification settings - Fork 885
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
[Multiple Datasource] Add data source selection service to support storing and getting selected data source updates #6827
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6827 +/- ##
==========================================
+ Coverage 67.38% 67.43% +0.04%
==========================================
Files 3443 3444 +1
Lines 67797 67834 +37
Branches 11033 11031 -2
==========================================
+ Hits 45688 45741 +53
+ Misses 19440 19427 -13
+ Partials 2669 2666 -3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
Hi Tianyu. Could you help me to better understanding what we are trying to do here? I see that we have add the pops of DataSourceSelectable and states of ComponenId. What are we trying to achieve here? Thanks |
@raintygao looks like there are lots of UI change, would you add a few screenshot and video to help the review. |
@@ -133,6 +136,7 @@ describe('TopNavMenu', () => { | |||
fullWidth: true, | |||
activeOption: [{ label: 'what', id: '1' }], | |||
}, | |||
dataSourceSelection, |
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.
Does it mean all the places that are using data source pickers need to pass the dataSourceSelection explicitly? I thought it is an internal state and plugins do not need to be aware of this context.
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.
There is no need to pass this instance manually, because usually all components are created by functions provided by DSM and passed within the function. Except for some test cases when manually rendering components that need to pass.
Hi Ella, unlike other plugins that need to select their own data sources, chatbot needs to get the data source selected by other applications from the OSD page. As these selector components don't store selected value and there isn't a centralized way in DSM to manage this, so this PR mainly does two things:
|
Sure. Although this PR makes updates in each UI component, it only adds the logic to store selected value in service after selecting the data source, and doesn't not make any changes to the UI view. The changes to assistant plugin are still in progress and depending on this PR, I have added a sample video to the PR content to demonstrate the purpose. |
@raintygao could you update the PR description as well to includes the backgrounds of why you need to introduce these changes? I'm afraid many people don't have enough context to review the changes. |
Sure. Already shared background and design offline. Created a new issue in plugin repo opensearch-project/dashboards-assistant#192 and link to provide more context. |
@@ -40,6 +41,7 @@ export interface DataSourceMenuProps<T = any> { | |||
uiSettings?: IUiSettingsClient; | |||
application?: ApplicationStart; | |||
setMenuMountPoint?: (menuMount: MountPoint | undefined) => void; | |||
dataSourceSelection: DataSourceSelection; |
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.
I think this should be part of componentConfig since not all components need to provide this as prop. Also, enforcing this prop as required would break all consumers, since it is provided by the DSM plugin, we can make it optional?
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.
I prefer to let it out of componentConfig because this instance should be passed from DSM not other plugins. As this instance is shared and limited in DSM, so we can set it as strict required.
I initially thought that other plugins only can render DS selector components through the two functions ui.DataSourceSelector
and ui.getDataSourceMenu
(like this way https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/dev_tools/public/application.tsx#L118), so I only need to pass the dataSourceSelection instance to the component through this two functions of DSM.
Until I saw home plugin directly importing component class for rendering without using two functions above(https://github.com/opensearch-project/OpenSearch-Dashboards/blob/main/src/plugins/home/public/application/components/tutorial_directory.js#L236), in this way the dataSourceSelection would be missing in the component.
So I'm thinking that in order to safely share dataSourceSelection instance among all components and be compatible with all usage ways, what about using a getter in each component to get instance directly (like this way https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6827/files#diff-ec5b6ef64504177e50cad326dcc07ada2135faafe924d25b0f4df088bc7b4823R80), so that I no longer have to manually pass dataSourceSelection through ui.DataSourceSelector
and ui.getDataSourceMenu
.
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.
Using getter sounds good
import { BehaviorSubject } from 'rxjs'; | ||
import { DataSourceOption } from '../components/data_source_menu/types'; | ||
|
||
export class DataSourceSelection { |
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.
Can the class name match the module name like DataSourceSelectionService
?
Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: tygao <tygao@amazon.com>
…oring and getting selected data source updates (#6827) * add data source selection service Signed-off-by: tygao <tygao@amazon.com> * export generateComponentId in util Signed-off-by: tygao <tygao@amazon.com> * update tests and type Signed-off-by: tygao <tygao@amazon.com> * update tests Signed-off-by: tygao <tygao@amazon.com> * update bind in components Signed-off-by: tygao <tygao@amazon.com> * Changeset file for PR #6827 created/updated * test: add tests for service Signed-off-by: tygao <tygao@amazon.com> * move dataSourceSelection out of componoent props Signed-off-by: tygao <tygao@amazon.com> * update service class name Signed-off-by: tygao <tygao@amazon.com> * use getter to replace dataSourceSelection props Signed-off-by: tygao <tygao@amazon.com> * add fallback for getter Signed-off-by: tygao <tygao@amazon.com> * test: add selection test case for component Signed-off-by: tygao <tygao@amazon.com> --------- Signed-off-by: tygao <tygao@amazon.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Co-authored-by: Lu Yu <nluyu@amazon.com> (cherry picked from commit e2c0df2) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
…oring and getting selected data source updates (#6827) (#6875) * add data source selection service * export generateComponentId in util * update tests and type * update tests * update bind in components * Changeset file for PR #6827 created/updated * test: add tests for service * move dataSourceSelection out of componoent props * update service class name * use getter to replace dataSourceSelection props * add fallback for getter * test: add selection test case for component --------- (cherry picked from commit e2c0df2) Signed-off-by: tygao <tygao@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> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Co-authored-by: Lu Yu <nluyu@amazon.com>
…oring and getting selected data source updates (opensearch-project#6827) * add data source selection service Signed-off-by: tygao <tygao@amazon.com> * export generateComponentId in util Signed-off-by: tygao <tygao@amazon.com> * update tests and type Signed-off-by: tygao <tygao@amazon.com> * update tests Signed-off-by: tygao <tygao@amazon.com> * update bind in components Signed-off-by: tygao <tygao@amazon.com> * Changeset file for PR opensearch-project#6827 created/updated * test: add tests for service Signed-off-by: tygao <tygao@amazon.com> * move dataSourceSelection out of componoent props Signed-off-by: tygao <tygao@amazon.com> * update service class name Signed-off-by: tygao <tygao@amazon.com> * use getter to replace dataSourceSelection props Signed-off-by: tygao <tygao@amazon.com> * add fallback for getter Signed-off-by: tygao <tygao@amazon.com> * test: add selection test case for component Signed-off-by: tygao <tygao@amazon.com> --------- Signed-off-by: tygao <tygao@amazon.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Co-authored-by: Lu Yu <nluyu@amazon.com>
Description
Screenshot
case1.mp4
Set selected value and other plugins can get selected value.
case2.mp4
A component lifecycle from mount and select data source to unmount and remove.
Multiple selector components in page and data stored.
Issues Resolved
#6825
opensearch-project/dashboards-assistant#192
Changelog
Check List
yarn test:jest
yarn test:jest_integration