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

feat: Dynamic imports for the Icons component #14318

Merged
merged 14 commits into from
Apr 29, 2021
Merged

feat: Dynamic imports for the Icons component #14318

merged 14 commits into from
Apr 29, 2021

Conversation

geido
Copy link
Member

@geido geido commented Apr 23, 2021

SUMMARY

It enhances the Icons component with dynamic imports and auto-generation of aria-label. As a POC, it changes the existing alert-solid icon with the new Icons.AlertSolid implementation.

Remarks:

As the Icons are now dynamically imported, test cases need to wait for the Icons to be imported and re-rendered to pass without warnings. In a react-testing-library setup, this translates to using the findBy* promise-based approach as shown in this PR.

BEFORE / AFTER:

Alert

alert_b4
alert_after

Datasource Control

datasource_control_b4
datasource_control_after

Datasource Editor

datasource_editor_alert_b4
datasource_editor_alert_after

Alerts & Reports

alerts_reports_b4
alerts_reports_after

@geido geido changed the title chore: Icon migration - Iterarion 1 feat: Dynamic imports for the Icons component Apr 26, 2021
@geido geido marked this pull request as ready for review April 26, 2021 17:10
@codecov
Copy link

codecov bot commented Apr 26, 2021

Codecov Report

Merging #14318 (c857a26) into master (1c16261) will increase coverage by 0.12%.
The diff coverage is 77.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #14318      +/-   ##
==========================================
+ Coverage   76.81%   76.93%   +0.12%     
==========================================
  Files         955      955              
  Lines       48249    48021     -228     
  Branches     6032     6032              
==========================================
- Hits        37063    36947     -116     
+ Misses      10990    10876     -114     
- Partials      196      198       +2     
Flag Coverage Δ
javascript 71.57% <77.14%> (+0.20%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...re/components/controls/DatasourceControl/index.jsx 86.84% <ø> (ø)
...set-frontend/src/components/Icons/AntdEnhanced.tsx 87.50% <50.00%> (ø)
...rc/views/CRUD/alert/components/AlertStatusIcon.tsx 47.76% <53.33%> (+0.06%) ⬆️
superset-frontend/src/components/Icons/Icon.tsx 96.00% <95.00%> (-4.00%) ⬇️
superset-frontend/src/components/Alert/index.tsx 100.00% <100.00%> (ø)
superset-frontend/src/components/Icons/index.tsx 100.00% <100.00%> (ø)
...nd/src/components/WarningIconWithTooltip/index.tsx 100.00% <100.00%> (+10.00%) ⬆️
...nd/src/dashboard/components/FiltersBadge/index.tsx 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c16261...c857a26. Read the comment docs.

@pkdotson
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@pkdotson Ephemeral environment spinning up at http://52.89.241.110:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@geido geido closed this Apr 27, 2021
@geido geido reopened this Apr 27, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

Copy link
Member

@pkdotson pkdotson 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 for implementing this!

@rusackas
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@rusackas Ephemeral environment spinning up at http://54.203.92.75:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@rusackas
Copy link
Member

I'm SO tempted to merge this... I think the code LGTM. One minor naming nit remains as an open comment. The bigger issue is perf testing:

  1. Is there a flash of blank-icons and then icons slowly appearing on screen if there are a whole bunch of them being lazy-loaded?
  2. Is there indeed a smaller bundle when using this dynamic import technique vs the "import ever svg into the component" plan? I would assume so, but it'd be nice to verify. You might be able to do npm run build -- --analyzeBundle=true to get an idea of this.

@geido
Copy link
Member Author

geido commented Apr 29, 2021

Is there a flash of blank-icons and then icons slowly appearing on screen if there are a whole bunch of them being lazy-loaded?

As you can see in this video, in an unrealistic scenario where all 100+ icons are being loaded at once, you will see for a moment them loading. I haven't noticed this behavior in a real-life scenario though. Loading is basically instant.
Play Video

Is there indeed a smaller bundle when using this dynamic import technique vs the "import ever svg into the component" plan? I would assume so, but it'd be nice to verify. You might be able to do npm run build -- --analyzeBundle=true to get an idea of this.

Haven't noticed any particular improvement in the bundle size

CC @rusackas

Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

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

LGTM. Let's do this!!! :D

@rusackas rusackas merged commit 545e257 into apache:master Apr 29, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

amitmiran137 pushed a commit to nielsen-oss/superset that referenced this pull request May 3, 2021
* master: (38 commits)
  refactor(native-filters): allow cascading only for filter_select (apache#14441)
  test(maximize-chart): Add tests to maximize chart action (apache#14371)
  fix: fixing mysql error message (apache#14416)
  feat: Logic added to limiting factor column in Query model (apache#13521)
  change relationship (apache#14435)
  fix: bootstrap data permissions (apache#14348)
  fix: parse simple string error message values (apache#14360)
  chore: add stack trace to all calls of logger.error (apache#14382)
  update README with new docs and recordings (apache#14432)
  Renamed impyla from implya in impala.mdx and Renamed PIP package impyla from impala in index.mdx (apache#14425)
  fix(native-filters): fix filter scope error (apache#14426)
  feat: Adding limiting_factor column to Query model (apache#14234)
  feat: Add etag caching to dashboard APIs (apache#14357)
  chore: Moves Card to the components folder (apache#14139)
  feat: Dynamic imports for the Icons component (apache#14318)
  feat: Support env vars configuration for WebSocket server (apache#14398)
  fix: SQLLab role permissions (apache#14372)
  fix(native-filters): always show filters without dataset (apache#14409)
  fix error getting partitionQuery from table.partition (apache#14369)
  refactor: Boostrap to AntD - Tabs (apache#14048)
  ...
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* Add aria-label and twotone

* Enhance LazyIcon

* Fix tests and solve ject warnings

* Add new line

* Revert package-lock to master

* Fix failing test

* Implement icon overrides

* Fix failing storybook

* Clean up

* Improve var name
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/XL 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants