Skip to content
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

Reducing wrapping divs from RenderingService #97017

Merged
merged 25 commits into from
Apr 26, 2021

Conversation

cchaos
Copy link
Contributor

@cchaos cchaos commented Apr 13, 2021

Page Layout Service Part 1: Reduce/Reuse/Recycle

Reducing the number of wrapping elements before getting to actual page content.

It seems that over the years, instead of fixing unnecessary layers, more continued to get added creating lots of nested divs. This is trouble for the types of layouts we try to create using flex to stretch the contents. The following is the old vs new rendered DOM:

image

Essentially it boils down to:

1. Reducing the wrappers in the rendering service

  • Removed the .content wrapper
    • There were no styles attached to this element
    • There was a data-test-subj="kibanaChrome" which is targeted by some tests, but I've moved this to the #kibana-body element (one level above). Iffy on whether that was really the appropriate element to move it to or if it needs to be within the service.
  • Removed the extraneous .app-wrapper-panel wrapping element
  • Removed the <AppContainer /> wrapper which applied a way-too-generic className of .application and is how plugins passed down the applicationClasses.
    • I've moved these classes to be applied to the <AppWrapper /> instead, but removed .application in favor of .kbnAppWrapper that most plugins can now just grab from the global variable APP_WRAPPER_CLASS.

The result of which is

ReactDOM.render(
<I18nProvider>
<>
{/* Fixed headers */}
{chromeHeader}
{/* banners$.subscribe() for things like the No data banner */}
<div id="globalBannerList">{bannerComponent}</div>
{/* The App Wrapper outside of the fixed headers that accepts custom class names from apps */}
<AppWrapper
chromeVisible$={chrome.getIsVisible$()}
classes$={chrome.getApplicationClasses$()}
>
{/* Affixes a div to restrict the position of charts tooltip to the visible viewport minus the header */}
<div id="app-fixed-viewport" />
{/* The actual plugin/app */}
{appComponent}
</AppWrapper>
</>
</I18nProvider>,
targetDomElement
);

2. Added a better and reusable class name for any elements wrapping applications

The AppWrapper component can now be reused by individual applications to ensure proper layout, or they can use the APP_WRAPPER_CLASS exported variable.

The variable is for places like Dashboard still creating elements through the document.

params.element.classList.add(APP_WRAPPER_CLASS);

3. Updated some naming of classes just to be more consistant:

  • .app-wrapper -> .kbnAppWrapper

Checklist

Delete any items that are not applicable to this PR.

For maintainers

cchaos added 6 commits April 5, 2021 14:19
Some being temporary and will need a better solution when introducing the page layout component
Can’t figure out how to have a optional Observable
`Received: "kbnAppWrapper class-name”`
…_1/reduce_wrappers

# Conflicts:
#	src/core/public/rendering/_base.scss
#	src/core/public/rendering/rendering_service.tsx
Copy link
Contributor Author

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pgayvallet Thank you for your help on this one. I've added the places where it's failing and I don't know how to fix it below.

@cchaos
Copy link
Contributor Author

cchaos commented Apr 14, 2021

Additional Fixes in this PR:

Global banners

Fixed, the left position when the global nav drawer is docked and add truncation so the text wouldn't extend beyond the established height of the banner.

image

@cchaos cchaos added v7.13.0 release_note:skip Skip the PR/issue when compiling release notes labels Apr 15, 2021
@cchaos cchaos marked this pull request as ready for review April 15, 2021 18:27
@cchaos cchaos requested review from a team as code owners April 15, 2021 18:27
@cchaos
Copy link
Contributor Author

cchaos commented Apr 15, 2021

Reviewers:

Please, please, please, check your application pages to ensure the layouts are still working correctly. Especially, if you were targeting or relying any of the following classes:

The following application wrappers needing/applying flex have been removed

  • .content
  • .application
  • .app-wrapper
  • .app-wrapper-panel, .app-wrapper-panel > *

Import and use APP_WRAPPER_CLASS from core/public or .kbnAppWrapper.


The class used for checking for hidden chrome has been renamed

  • .hidden-chrome -> .kbnAppWrapper--hiddenChrome

Going forward

If your application also has another custom class simply to provide column, flex layout for stretching you can replace your custom class with the APP_WRAPPER_CLASS from core/public.

Copy link
Contributor

@wylieconlon wylieconlon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the Kibana App owned apps in Firefox and Safari and wasn't able to find any issues. LGTM

@botelastic botelastic bot added the Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability label Apr 15, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime (Team:uptime)

Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, with banner disabled then enabled:

  • dashboard
  • dashboard full screen
  • visualize
  • maps
  • canvas
  • login page

All seems ok.

LGTM

src/core/public/core_system.ts Show resolved Hide resolved
src/core/tsconfig.json Outdated Show resolved Hide resolved
@cchaos cchaos added v7.14.0 and removed v7.13.0 labels Apr 19, 2021
@alvarezmelissa87
Copy link
Contributor

Tested locally for ML - LGTM 👍

Copy link
Member

@azasypkin azasypkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes in Platform Security functional tests LGTM.

Copy link
Contributor

@sebelga sebelga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested the ES UI apps and didn't spot any regression 👍 Thanks for doing that @cchaos !

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code only review: Presentation team changes LGTM!

Tested locally on chrome, Dashboard changes LGTM. Focused on dashboard layout, fullscreen mode, embed mode & overlays. Everything LGTM!

@cchaos
Copy link
Contributor Author

cchaos commented Apr 26, 2021

@elasticmachine merge upstream

Copy link
Contributor

@dominiqueclarke dominiqueclarke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested for Uptime and it LGTM, except we do have one view relying on flex from one of the removed wrappers.
Screen Shot 2021-04-26 at 12 50 11 PM
We can create an issue to address this using the APP_WRAPPER_CLASS.
CC: @shahzad31 @justinkambic

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
core 363 364 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
canvas 1.2MB 1.2MB -288.0B
dashboard 138.9KB 138.8KB -126.0B
monitoring 728.8KB 728.5KB -286.0B
securitySolution 7.0MB 7.0MB +2.0B
uptime 1.2MB 1.2MB -31.0B
total -729.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
banners 11.7KB 11.7KB +29.0B
canvas 518.4KB 518.4KB +2.0B
core 404.1KB 400.9KB -3.2KB
dashboard 313.0KB 313.0KB +8.0B
total -3.1KB
Unknown metric groups

API count

id before after diff
core 2180 2182 +2

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Contributor

@FrankHassanabad FrankHassanabad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@andreadelrio andreadelrio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design changes LGTM 🎉

@cchaos cchaos merged commit f07ebc8 into elastic:master Apr 26, 2021
cchaos added a commit that referenced this pull request Apr 26, 2021
* Reducing wrapping divs from RenderingService

* Applying more styles to .kbnAppWrapper

Some being temporary and will need a better solution when introducing the page layout component

* Almost fixing tests for rendering service

Can’t figure out how to have a optional Observable
`Received: "kbnAppWrapper class-name”`

* Adding some comments

* [Dashboard] Using the APP_WRAPPER_CLASS

* fix test & ts types

* Fixin a few more tests that were using `.app-wrapper`

* Creating docs for new var and cleaning up some selectors

* Fixing reporting

* Fixing banner position and truncation

* Fixed CSS error in loading screen and jump in animation

* Fixing selectors in Canvas

* Remove unused var

* Added `APP_WRAPPER_CLASS` export from `server` and updated reporting to use it

* Fix monitoring icon clicks

* move APP_WRAPPER_CLASS definition to src/core/common

* Fixing Monitoring snapshots and wrapper class

* Moved `APP_WRAPPER_CLASS` utils but exported from `public` and `server`

* Remove old folder

* Fix dashboard test by only showing HR in edit mode

Co-authored-by: pgayvallet
Co-authored-by:  tsullivan
@cchaos cchaos mentioned this pull request Jun 9, 2021
3 tasks
@cchaos cchaos deleted the pageLayouts/stage_1/reduce_wrappers branch March 11, 2022 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:skip Skip the PR/issue when compiling release notes Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.14.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.