-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Banner Plugin] UI Implementation Refactor #10125
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
[Banner Plugin] UI Implementation Refactor #10125
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10125 +/- ##
=======================================
Coverage 59.70% 59.70%
=======================================
Files 4031 4031
Lines 102246 102246
Branches 16139 16139
=======================================
Hits 61051 61051
Misses 37185 37185
Partials 4010 4010
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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 post a screenshot with these changes and the new page header?
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.
some comments
@@ -28,14 +28,16 @@ | |||
* under the License. | |||
*/ | |||
|
|||
@import "src/core/public/variables"; |
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.
Was this already imported in another file? It will likely be imported twice - may want to validate (probably not problematic for this particular file, but not ideal pattern to set)
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.
Was this already imported in another file? It will likely be imported twice - may want to validate (probably not problematic for this particular file, but not ideal pattern to set)
It wasn’t imported elsewhere, but you're right — it probably makes more sense to import it at a higher level like src/plugins/home/public/application/index.scss. I’ll update that, thanks!
// Get the banner plugin configuration | ||
const bannerPluginConfig = injectedMetadata | ||
?.getPlugins() | ||
?.find((plugin: { id: string }) => plugin.id === 'banner')?.config; | ||
const isBannerEnabled = bannerPluginConfig?.enabled === true; |
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.
Isn't it a little weird for core to know about a particular plugin? Is idea that if someone else wanted to implement a banner plugin they'd have to give it the same id?
Looks like this is pre-existing code, so not a blocker
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.
Isn't it a little weird for core to know about a particular plugin? Is idea that if someone else wanted to implement a banner plugin they'd have to give it the same id?
Looks like this is pre-existing code, so not a blocker
You're right — it is a bit awkward for core to reference a specific plugin. In this case, it’s needed to ensure the plugin mount is only added to the DOM when enabled, and to conditionally apply the wrapper class.
Definitely open to better approaches if you have something in mind — would love to hear your thoughts!
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.
Do you have a point of view of why this doesn't use the banner overlay service? e.g. curious what answer to https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9989/files#r2193589565 is (@kavilla)
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.
Read the RFC (#9861) - given our reasoning this is standalone and not intended to be reused, not sure I fully understand why this is a plugin if its has a specific purpose that seems coupled to core.
Anyways, @zhongnansu is this a common practice for plugins within core to be referenced by id in core code?
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.
Anyways, @zhongnansu is this a common practice for plugins within core to be referenced by id in core code?
@virajsanghvi There are some options to reference plugin from core, the current implementation is a lightweight solution that's acceptable to me base on the use case. Tho it might not be the best practice.
One option is like implementation in this PR. Although I didn't find similar usage, but injectedMetaService -> getPlugin()
API does relay the plugin manifest from server side to client side. A use case like this is acceptable to me, which it just reads the feature flag and conditionally render UI.
A more common way is defining a interface in core and expose to plugin to register/set.
Which approach do you think we should take in this case?
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 the latter - I don't think core should really reference plugins by id (and from your comment, it seems like we don't currently do this), unless the design intent is that users can provide a plugin with this id for this behavior (although the banner plugin is a core plugin, so that seems like its not the case).
It is also odd that we're introducing a core plugin that doesn't support the direction the ux is going (new header) - is this a stop-gap solution? Do we plan to eventually support the new header?
@@ -19,47 +25,22 @@ | |||
top: 0; | |||
left: 0; | |||
right: 0; | |||
z-index: 1100; /* Higher than header z-index (1000) */ | |||
z-index: 1100; |
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.
why remove comment?
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.
why remove comment?
This comment was brought in from my previous PR. After reviewing similar cases in the codebase, I realized that z-index values typically aren’t commented this way — so I removed it for consistency.
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.
Ah, didn't realize this was all new code
.euiOverlayMask { | ||
top: calc(var(--global-banner-height) + $euiSizeXL + $euiSizeM + $euiSizeXL + $euiSizeM) !important; | ||
.headerGlobalNav--withBanner .primaryHeader:not(.newTopNavHeader) { | ||
top: calc(var(--global-banner-height) + $headerWidth); | ||
} | ||
/* stylelint-enable @osd/stylelint/no_modifying_global_selectors */ |
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.
Why is this no longer necessary?
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.
@virajsanghvi
Why is this no longer necessary?
It’s no longer necessary because body content, flyouts, and overlay masks now use shared SCSS variables like $osdHeaderOffset and $osdHeaderOffsetExpanded. These are injected into min-height, padding, and top styles, so layout shifts automatically when the banner appears.
These changes are all related to concerns raised by the already merged PR #9989.
.headerIsExpanded.euiBody--headerIsFixed { | ||
padding-top: calc(var(--global-banner-height) + $euiSizeXL + $euiSizeM + $euiSizeXL + $euiSizeM) !important; |
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.
why is this no longer necessary?
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.
It’s no longer necessary because body content, flyouts, and overlay masks now use shared SCSS variables like $osdHeaderOffset and $osdHeaderOffsetExpanded. These are injected into min-height, padding, and top styles, so layout shifts automatically when the banner appears.
These changes are all related to concerns raised by the already merged PR #9989.
Same as above.
The current banner overlaps with the new header — I plan to address this in a follow-up PR. Supporting a non-overlapping banner with the new header would require adding conditional logic in the SCSS file, which feels out of scope for this PR’s purpose. |
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.
thanks for removing the css override, re-enabling linter
Signed-off-by: Sid Wang <[email protected]>
5f5ab13
to
220a618
Compare
Why are we following up vs just fixing this now? |
374eae7
to
1e81240
Compare
Thanks for the question! I spent a good amount of time investigating possible solutions here. Unlike the default home page, the new home page and its flyout are implemented as fixed-position components. There’s currently no equivalent to The primary goal of this project is to promote new OpenSearch Dashboards features (like the new home page) to existing users. Supporting banner offsets in the new home page is out of scope for this PR. The only viable approach I found involves overriding top-level layout styles like: .content,
.euiFlyout,
.newPageTopNavExpander {
top: var(--global-banner-height);
} However, this would override existing styles and risk regressions. To avoid that, this PR conditionally hides the banner when the new home page is enabled. A proper solution is tracked in the issue, which will include a refactor of the new UI layout to introduce a --new-ui-header-offset (or equivalent) and apply it systematically across all affected components. |
If the direction of the new experience is with the new header, it is odd to me that we don't support it. |
return ( | ||
<> | ||
{isBannerEnabled && <div id="pluginGlobalBanner" />} | ||
{isBannerEnabled && !useUpdatedHeader && <div id="pluginGlobalBanner" />} |
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.
Why not always just have a space to mount global banners vs making it specific to this plugin?
// Get the banner plugin configuration | ||
const bannerPluginConfig = injectedMetadata | ||
?.getPlugins() | ||
?.find((plugin: { id: string }) => plugin.id === 'banner')?.config; | ||
const isBannerEnabled = bannerPluginConfig?.enabled === true; |
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 the latter - I don't think core should really reference plugins by id (and from your comment, it seems like we don't currently do this), unless the design intent is that users can provide a plugin with this id for this behavior (although the banner plugin is a core plugin, so that seems like its not the case).
It is also odd that we're introducing a core plugin that doesn't support the direction the ux is going (new header) - is this a stop-gap solution? Do we plan to eventually support the new header?
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.
Discussed offline, approving given:
- This has already been committed, and this improves the current implementation
- We plan on picking up new header support and this pr prevents this from showing there
- We can address proper extensibility model after this pr (as it fixes something already in the code base) - let's please just have a quick discussion with stakeholders.
One call out, can you validate that failing CI isn't an issue?
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.
Let's make sure you are tracking all the follow-up properly in separate github issues and and linked here.
None of these two could be caused by this PR. |
This will be tracked by this issue:
This will be tracked by this issue: |
Description
Adds a lightweight header wrapper and shared
--global-banner-height
/$osdHeaderOffset
variables so all headers, body content, flyouts and masks automatically shift downward whenever the Global Banner is mounted. Removes all!important
overrides and hard-coded pixel offsets.Issues Resolved
The concerns raised in #9989 (comment)
Screenshot
Implementation Details
This change avoids global OUI framework CSS overrides by dynamically offsetting headers and page content using a shared layout strategy:
Banner Mounting
#pluginGlobalBanner
Header Wrapping
.headerGlobalNav--withBanner
is conditionally applied when the banner is enabled.Shared Offsets
min-height
,padding
, andtop
styles to ensure content shifts automatically when the banner appears.Fallback Safety
--global-banner-height
defaults to0px
, preserving the existing layout when the banner is disabled.Testing the changes
Start Dashboards with banner disabled – verify no layout change.
Enable banner plugin (
opensearch_dashboards.yml
).Refresh any app page:
Resize window, and switch to dark mode – confirm offsets remain correct.
Changelog
!important
hacksCheck List
All tests pass
yarn test:jest
yarn test:jest_integration
New functionality includes testing.
New functionality has been documented.
Update [CHANGELOG.md](./../CHANGELOG.md)
Commits are signed per the DCO using
--signoff