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

[triggersActionsUi] Reduce page load bundle to under 100kB #97770

Merged

Conversation

YulNaumenko
Copy link
Contributor

@YulNaumenko YulNaumenko commented Apr 21, 2021

Resolves #95871

Summary

Current PR resolves the first part of the scope defined for the #95871:

  1. changed all SVG files to be lazy loaded as a React components. Use the tool which is recommended by EUI team.
  2. did the next minor code improvements:
    • moved shared components props definitions to the x-pack/plugins/triggers_actions_ui/public/types.ts ;
    • removed the usage duplication for x-pack/plugins/triggers_actions_ui/public/common/get_add_alert_flyout.tsx, x-pack/plugins/triggers_actions_ui/public/common/get_add_connector_flyout.tsx, x-pack/plugins/triggers_actions_ui/public/common/get_edit_alert_flyout.tsx, x-pack/plugins/triggers_actions_ui/public/common/get_edit_connector_flyout.tsx;
    • replaced <Fragment></Fragment> with shorter version <></>;
    • renamed some labels path to match the naming convention in Kibana translations

Screen Shot 2021-05-24 at 10 19 23 AM

@YulNaumenko YulNaumenko self-assigned this Apr 21, 2021
@YulNaumenko YulNaumenko added Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) Feature:Actions Feature:Alerting v7.14.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes labels May 21, 2021
@YulNaumenko YulNaumenko marked this pull request as ready for review May 23, 2021 22:47
@YulNaumenko YulNaumenko requested review from a team as code owners May 23, 2021 22:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

Copy link
Contributor

@tylersmalley tylersmalley left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@ymao1
Copy link
Contributor

ymao1 commented May 24, 2021

Great changes! The bundle size is looking great! A few things I noticed:

The JIRA logo is super small now
Screen Shot 2021-05-24 at 1 37 31 PM

It used to look like this:
Screen Shot 2021-05-24 at 1 37 37 PM

When creating a new rule, I see this in the browser console:

react.development.js:167 Warning: Each child in a list should have a unique "key" prop.

Check the render method of `AlertForm`. See https://fb.me/react-warning-keys for more information.
    in Fragment (created by AlertForm)
    in AlertForm (created by AlertAdd)
    in div (created by EuiFlyoutBody)
    in div (created by EuiFlyoutBody)
    in div (created by EuiFlyoutBody)
    in EuiFlyoutBody (created by AlertAdd)
    in HealthCheck (created by AlertAdd)
    in HealthContextProvider (created by AlertAdd)
    in div (created by EuiFlyout)
    in div (created by ForwardRef)
    in ForwardRef (created by ForwardRef)
    in ForwardRef (created by ForwardRef)
    in ForwardRef (created by ForwardRef)
    in ForwardRef (created by EuiFocusTrap)
    in EuiFocusTrap (created by EuiFlyout)
    in EuiFlyout (created by AlertAdd)
    in EuiPortal (created by AlertAdd)
    in AlertAdd

@@ -206,13 +206,13 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent<IndexThr
....

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add guidance in the README about using React components for logos instead of directly importing SVGs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add this

@YulNaumenko YulNaumenko requested a review from ymao1 May 24, 2021 21:27
@ymao1
Copy link
Contributor

ymao1 commented May 25, 2021

Getting some more browser errors:

After creating a rule when the rules list loads:

Warning: Each child in a list should have a unique "key" prop.

Check the render method of `TypeFilter`. See https://fb.me/react-warning-keys for more information.
    in Fragment (created by TypeFilter)
    in TypeFilter (created by AlertsList)
    in div (created by EuiFlexItem)
    in EuiFlexItem (created by AlertsList)
    in div (created by EuiFlexGroup)
    in EuiFlexGroup (created by AlertsList)
    in div (created by EuiFlexItem)
    in EuiFlexItem (created by AlertsList)
    in div (created by EuiFlexGroup)
    in EuiFlexGroup (created by AlertsList)
    in section (created by AlertsList)
    in AlertsList
    in Suspense
    in Unknown (created by Context.Consumer)
    in Route (created by TriggersActionsUIHome)
    in Switch (created by TriggersActionsUIHome)
    in HealthCheck (created by TriggersActionsUIHome)
    in HealthContextProvider (created by TriggersActionsUIHome)
    in div (created by EuiPanel)
    in EuiPanel (created by EuiPageContent)
    in EuiPageContent (created by TriggersActionsUIHome)
    in main (created by EuiPageBody)
    in EuiPageBody (created by TriggersActionsUIHome)
    in TriggersActionsUIHome

When creating an index threshold rule:

Warning: Each child in a list should have a unique "key" prop.

Check the render method of `ThresholdExpression`. See https://fb.me/react-warning-keys for more information.
    in Fragment (created by ThresholdExpression)
    in ThresholdExpression
    in Suspense
    in Unknown (created by IndexThresholdAlertTypeExpression)
    in IndexThresholdAlertTypeExpression (created by AlertForm)
    in Suspense (created by AlertForm)
    in EuiErrorBoundary (created by AlertForm)
    in div (created by EuiForm)
    in EuiForm (created by AlertForm)
    in AlertForm (created by AlertAdd)
    in div (created by EuiFlyoutBody)
    in div (created by EuiFlyoutBody)
    in div (created by EuiFlyoutBody)
    in EuiFlyoutBody (created by AlertAdd)
    in HealthCheck (created by AlertAdd)
    in HealthContextProvider (created by AlertAdd)
    in div (created by EuiFlyout)
    in div (created by ForwardRef)
    in ForwardRef (created by ForwardRef)
    in ForwardRef (created by ForwardRef)
    in ForwardRef (created by ForwardRef)
    in ForwardRef (created by EuiFocusTrap)
    in EuiFocusTrap (created by EuiFlyout)
    in EuiFlyout (created by AlertAdd)
    in EuiPortal (created by AlertAdd)
    in AlertAdd

@YulNaumenko
Copy link
Contributor Author

Getting some more browser errors:

After creating a rule when the rules list loads:

Warning: Each child in a list should have a unique "key" prop.

When creating an index threshold rule:

Warning: Each child in a list should have a unique "key" prop.

Thank you for catching this, @ymao1 ! Fixed in the commit.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
triggersActionsUi 236 232 -4

Async chunks

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

id before after diff
triggersActionsUi 1.5MB 1.6MB +92.0KB

Page load bundle

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

id before after diff
triggersActionsUi 105.7KB 96.7KB -9.1KB
Unknown metric groups

API count

id before after diff
triggersActionsUi 245 241 -4

async chunk count

id before after diff
triggersActionsUi 41 50 +9

miscellaneous assets size

id before after diff
triggersActionsUi 37.7KB 0.0B -37.7KB

References to deprecated APIs

id before after diff
crossClusterReplication 8 6 -2
globalSearch 4 2 -2
indexManagement 12 7 -5
infra 261 149 -112
lens 67 45 -22
licensing 18 15 -3
total -146

History

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

cc @YulNaumenko

Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

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

LGTM! Nice job!

@YulNaumenko YulNaumenko merged commit 5ebded2 into elastic:master May 26, 2021
jloleysens added a commit to jloleysens/kibana that referenced this pull request May 26, 2021
…deprecation-ilm-policy

* 'master' of github.com:elastic/kibana: (101 commits)
  [ftr] migrate "docTable" service to FtrService class (elastic#100595)
  [ftr] migrate "listingTable" service to FtrService class (elastic#100606)
  Fixed comparing real value with formatted according to mode. (elastic#100456)
  [ftr] migrate "dataGrid" service to FtrService class (elastic#100593)
  [ftr] migrate "fieldEditor" to FtrService class (elastic#100597)
  [ftr] migrate "filterBar" service to FtrService class (elastic#100601)
  [triggersActionsUi] Reduce page load bundle to under 100kB (elastic#97770)
  [build] Clean jest configs (elastic#100594)
  refact(NA): remove extra pkg_npm target and add specific target folders for @kbn/analytics on Bazel (elastic#100569)
  Update dependency @elastic/charts to v29.2.0 (elastic#100587)
  [Maps] convert LayerPanel to typescript (elastic#100481)
  [Upgrade Assistant] Address copy feedback (elastic#99632)
  Open/Closed filter for observability alerts page (elastic#99217)
  One liner to expose the EQL query for debugging for users (elastic#100565)
  [KibanaPageLayout] Solution Nav specific styles & props (elastic#100089)
  [ftr] implement FtrService classes and migrate common services (elastic#99546)
  [XY] [Lens] Adds opacity slider (elastic#100453)
  [Reporting] ILM policy for managing reporting indices (elastic#100130)
  [Reporting] ILM policy for managing reporting indices (elastic#100130)
  [DOCS] Remove redundant maps attribute (elastic#100426)
  ...

# Conflicts:
#	x-pack/plugins/reporting/server/lib/store/report_ilm_policy.ts
#	x-pack/plugins/reporting/server/lib/store/store.test.ts
#	x-pack/plugins/reporting/server/lib/store/store.ts
ecezalp pushed a commit to ecezalp/kibana that referenced this pull request May 26, 2021
…7770)

* [triggersActionsUi] Reduce page load bundle to under 100kB

* removed old code

* removed fragment

* changed svg logo to lazy react components

* fixed type checks and translations

* fixed type checks

* fixed type checks

* fixed type checks

* fixed tests

* fixed tests

* fixed iconClass

* fixed due to comments

* added info about new IconType to readme file

* fixed key errors
ecezalp pushed a commit to ecezalp/kibana that referenced this pull request May 26, 2021
…7770)

* [triggersActionsUi] Reduce page load bundle to under 100kB

* removed old code

* removed fragment

* changed svg logo to lazy react components

* fixed type checks and translations

* fixed type checks

* fixed type checks

* fixed type checks

* fixed tests

* fixed tests

* fixed iconClass

* fixed due to comments

* added info about new IconType to readme file

* fixed key errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Actions Feature:Alerting release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) v7.14.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[triggersActionsUi] Reduce page load bundle to under 100kB
5 participants