-
Notifications
You must be signed in to change notification settings - Fork 906
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
Add sidecar service #5920
Add sidecar service #5920
Conversation
ea7c8f6
to
09eca2f
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5920 +/- ##
==========================================
+ Coverage 67.20% 67.21% +0.01%
==========================================
Files 3328 3333 +5
Lines 64461 64553 +92
Branches 10376 10392 +16
==========================================
+ Hits 43318 43391 +73
- Misses 18610 18628 +18
- Partials 2533 2534 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Pretty cool. Will check out the implementation. In the meantime I see there are some snapshots are not updated for tests. Also wanted to check. Is it intentional that the sidecar pushes the elements over when it is mounted? |
Thank you. @kavilla
I will do some updates to snapshots.
Yes. When plugin calls |
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.
Nice job extending the existing overlays service to expose this feature although i wonder if this is the right approach? This just looks like a resizable flyout to me which can also open from the bottom. If thats what the sidecar is, why cant we just update the Flyout component on OUI? This is a feature that we also need for Discover and potentially in a few other places around the app. By enhancing the flyout in OUI, we avoid needing to declare a new service in core entirely and building a custom resizeable component as you have done here.
cc: @kgcreative @shanilpa
As for the PR itself, I havent reviewed the code yet but had a few high level comments based on the changes:
- Can you add tests to the feature? The codecov has highlighted a few good places to do so.
- Can you update the readme on how to use this feature. The other overlay services have sections in the readme on how to use them. This will really make this feature a lot easier to use
src/plugins/opensearch_dashboards_react/public/overlays/create_react_overlays.tsx
Outdated
Show resolved
Hide resolved
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 you add some tests for this service similar to the other two overlays?
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.
Sorry the test wasn't updated together. Since this PR needs to be merged before 2.13, so I planed to create PR for code review first. I will add tests later as soon as possible.
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.
Hmm, this is a custom component. Why arent we using a component from OUI for this? There is a need to make Flyouts resizeable in discover too. Instead of building a custom resizeable flyout here, we should update the flyout component in OUI to do the same. Even adding the ability to have a flyout that opens from the bottom is needed, so making a change there is the right thing to do.
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.
- When I implemented this feature, OUI didn't export this component. I'm not sure whether the date of OUI support is early or later than the target version. so I choose to implement by myself. I think this component can be removed and replaced with a component imported from OUI after OUI supports it.
- I think update a resizable container in OUI is reasonable, flyout is only one kind of container, i'm not sure whether we need to support resizable for a specific kind container in OUI.
- Flyout currently only supports expansion from right side. I think expanding from the bottom is more like modal rather than adding more direction to flyout.
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.
For what it's worth, I do agree this should be an OUI component. There are a few nuances between flyout and sidecar, but they are mostly visual.
We need the sidecar and a fly out to be able to exist together |
@kgcreative but cant the two be the same OUI component? They share a lot of features. Dont you think we can combine the two into one interface that is flexible as either? Here are some similarities.
And even of they cant be the same component, the raw component should be bult in OUI and consumed hee like the flyout and Modal. Neither are built in OSD. |
@ashwin-pc
I think it's reasonable for OUI to support a single resizable container like some others, but if it involves interacting with entire OSD and some customization requirements, i think this should be handled internally by the OSD, this should be more of a specific component inside the OSD. It may be confused and more difficult to put it as a component in generic UI library. |
@raintygao Okay i see the difference. I no longer think that the two need to be the same component, but I do still think that the component needs to come from OUI. So my hesitation with the approach is that we are defining a lot of standard UI interaction patterns in OSD for resizing that should ideally be taken care of by OUI. As for the mount point, I think the way the flyout does it is not ideal but doesnt mean we have to do it the same way. You can always pass a ref to a react component so that it can mount correctly. In this case the app container can be provided to an OUI Sidecar component and it can mount appropriately. All its states and combinations are also easier to test and validate while also abstracting away the accessibility and ui interaction code from the OSD codebase. not sure what your performance concerns are but lets chat about it.
Yes. I expects similar separation of concerns similar to how the flyout or modal behaves. The UI Library is only responsible for the UI and resize properties. The state management and what to do once actions are clicked should all be handled by the sidecar service that you have here. It also makes testing these a lot easier since UI tests are quite different from the integ tests that the service needs. |
@ashwin-pc Excluding some reused UI components above, I think the remaining content of sidecar service should be implemented in OSD instead of OUI because it is not a widely used service and currently only used by assistant plugin. Many important parts are handled in this service, such as how chrome header and app-wrapper respond respectively when the container is dragged to implement the overall push effect, some state management, some real-time configuration switching, display and hiding and many customization functions, etc. |
+1 Can you work on adding these to OUI? Lemme know if you need any help contributing that change :) |
@ashwin-pc Sidecar feature is a high property feature which was implemented in 2.12 and planned to be released in 2.13. So my suggestion is that we review and merge current implementation to ensure deliver on time and try to support new UI components in OUI from the next version. When completed, we will replace raw implementation in OSD. I think this is a balanced solution. |
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
Signed-off-by: tygao <[email protected]>
@SuZhou-Joe @ruanyl I just rebased main to resolve conflicts in changelog, and your approvals were dismissed automatically. Could you approve again? |
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-5920-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 c2c4f53f140a655705e0e8830ea14e8d958a8de9
# Push it to GitHub
git push --set-upstream origin backport/backport-5920-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x Then, create a pull request where the |
* feat: sidecar poc Signed-off-by: tygao <[email protected]> * update sidecar Signed-off-by: tygao <[email protected]> * update mouseevent Signed-off-by: tygao <[email protected]> * update type Signed-off-by: tygao <[email protected]> * update service mock Signed-off-by: tygao <[email protected]> * update sidecar config mode type Signed-off-by: tygao <[email protected]> * update docked mode enum Signed-off-by: tygao <[email protected]> * update resizable button style Signed-off-by: tygao <[email protected]> * doc: add changelog Signed-off-by: tygao <[email protected]> * test: update snapshots Signed-off-by: tygao <[email protected]> * fix typo Signed-off-by: tygao <[email protected]> * doc: update readme Signed-off-by: tygao <[email protected]> * test: add test for resizable button and service Signed-off-by: tygao <[email protected]> * test: add test for create react overlays and app container Signed-off-by: tygao <[email protected]> * test: add tests for service and components Signed-off-by: tygao <[email protected]> * test: update tests for resizable button Signed-off-by: tygao <[email protected]> * fix: update enum usage Signed-off-by: tygao <[email protected]> * update Signed-off-by: tygao <[email protected]> * fix wrong change Signed-off-by: tygao <[email protected]> * add prefix for resizableButton Signed-off-by: tygao <[email protected]> --------- Signed-off-by: tygao <[email protected]> (cherry picked from commit c2c4f53)
* feat: sidecar poc Signed-off-by: tygao <[email protected]> * update sidecar Signed-off-by: tygao <[email protected]> * update mouseevent Signed-off-by: tygao <[email protected]> * update type Signed-off-by: tygao <[email protected]> * update service mock Signed-off-by: tygao <[email protected]> * update sidecar config mode type Signed-off-by: tygao <[email protected]> * update docked mode enum Signed-off-by: tygao <[email protected]> * update resizable button style Signed-off-by: tygao <[email protected]> * doc: add changelog Signed-off-by: tygao <[email protected]> * test: update snapshots Signed-off-by: tygao <[email protected]> * fix typo Signed-off-by: tygao <[email protected]> * doc: update readme Signed-off-by: tygao <[email protected]> * test: add test for resizable button and service Signed-off-by: tygao <[email protected]> * test: add test for create react overlays and app container Signed-off-by: tygao <[email protected]> * test: add tests for service and components Signed-off-by: tygao <[email protected]> * test: update tests for resizable button Signed-off-by: tygao <[email protected]> * fix: update enum usage Signed-off-by: tygao <[email protected]> * update Signed-off-by: tygao <[email protected]> * fix wrong change Signed-off-by: tygao <[email protected]> * add prefix for resizableButton Signed-off-by: tygao <[email protected]> --------- Signed-off-by: tygao <[email protected]> (cherry picked from commit c2c4f53)
Description
Support a new layout service called sidecar in dashboard, so that external plugin can use this service as its container. This flyout supports three modes and resizable.
This flyout will only be used in dashboard assistant currently.
Issues Resolved
#5620
Screenshot
Testing the changes
Check List
yarn test:jest
yarn test:jest_integration
Test steps
core.overlays.sidecar().open
, in this method you need to pass MountPoint and sidecar config, like{ className: 'chatbot-sidecar', config: { dockedMode: 'right', paddingSize: 460 }
.After that you could see a sidecar container is mounted.
setSidecarConfig
with new config, like{ dockedMode: 'takeover', paddingSize: 500 }
hide
andshow
to implement sidecar hide and show effect.