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: upgrade react-select and make multi-select sortable #9628

Merged
merged 10 commits into from
May 19, 2020

Conversation

ktmud
Copy link
Member

@ktmud ktmud commented Apr 22, 2020

CATEGORY

  • Enhancement (new features, refinement)

SUMMARY

In order to enable easy reordering of selected metrics/columns, we need to upgrade
react-select v1 and v3.

This PR has done a lot of cleanups and refactoring to make this happen:

  1. Upgrade react-select from 1.3.0 to 3.1.0.
  2. Replace react-virtualized-select with a custom implementation based on react-window. Inspired by but simpler than react-windowed-select: we did not handle grouped options, but added typing.
  3. Added src/components/Select and SupersetStyledSelect as the all-in-one entrypoint to all Superset styled selects. It also handles API backward compatibility for the purpose of: 1). increase usability; 2) keep changes in dependent modules minimal.
  4. Virtualized list (WindowedSelect) will be used only when options list is long (currently > 100).
  5. Fix a couple of minor styling and UX bugs related ad-hoc metrics/filters.
  6. src/components/StyledSelect currently used in the new ListView will be deprecated.

Since this is a fairly large change, it'd be highly appreciated if anyone who has worked on react-select or SelectControl component in Superset before could take a close look to these changes.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

I know I have made a promise to keep all original styles, but the UI did change a bit in the end, especially the multi-value labels. The new default UI from react-select do make some sense and I don't want to add more complexity to the code just for overriding them.

Before:

image

After:

image

Another difference is that in FilterBox, selected filter values will not have bars indicate frequency. The original design doesn't make much sense anyway since each selected value is not of equal length and it kind of interferes with legibility.

Before:

Snip20200511_38

After:

Snip20200511_39

TEST PLAN

CI & Manual tests.

ADDITIONAL INFORMATION

REVIEWERS

@kristw @graceguo-supercat @evans @villebro @suddjian @mistercrunch @etr2460 @nytai

@ktmud
Copy link
Member Author

ktmud commented Apr 22, 2020

@nytai Feel free to continue your work on StyledSelect. I'll make sure to migrate the styles to v3.

cc @suddjian @rusackas

@codecov-io
Copy link

codecov-io commented Apr 22, 2020

Codecov Report

Merging #9628 into master will decrease coverage by 4.91%.
The diff coverage is 65.19%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9628      +/-   ##
==========================================
- Coverage   71.01%   66.10%   -4.92%     
==========================================
  Files         586      592       +6     
  Lines       30635    30634       -1     
  Branches     3159     3238      +79     
==========================================
- Hits        21756    20250    -1506     
- Misses       8768    10197    +1429     
- Partials      111      187      +76     
Flag Coverage Δ
#cypress ?
#javascript 59.22% <65.19%> (-0.02%) ⬇️
#python 71.01% <ø> (-0.26%) ⬇️
Impacted Files Coverage Δ
...set-frontend/src/SqlLab/components/QuerySearch.jsx 57.54% <ø> (ø)
...perset-frontend/src/addSlice/AddSliceContainer.jsx 72.72% <ø> (ø)
superset-frontend/src/components/AsyncSelect.jsx 96.29% <ø> (ø)
superset-frontend/src/components/ColumnOption.jsx 100.00% <ø> (ø)
...uperset-frontend/src/components/ExpandableList.tsx 88.88% <ø> (ø)
superset-frontend/src/components/MetricOption.jsx 100.00% <ø> (ø)
...rset-frontend/src/components/OptionDescription.jsx 100.00% <ø> (ø)
superset-frontend/src/components/TableSelector.jsx 82.67% <0.00%> (-0.91%) ⬇️
...et-frontend/src/dashboard/components/CssEditor.jsx 68.18% <ø> (ø)
.../src/dashboard/components/RefreshIntervalModal.jsx 100.00% <ø> (ø)
... and 224 more

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 7a95c52...8948497. Read the comment docs.

@nytai
Copy link
Member

nytai commented Apr 23, 2020

@ktmud thanks for taking this on. It's no easy task. Let me know if I can help!

@ktmud ktmud changed the title WIP: upgrade react-select from v1.3.0 to v3.1.0 WIP: upgrade react-select from v1.3.0 to v3.1.0 and enable sortable multi-select May 2, 2020
@ktmud ktmud force-pushed the sortable-metric-input branch 10 times, most recently from 69c63e7 to c419639 Compare May 7, 2020 22:17
@ktmud ktmud marked this pull request as ready for review May 7, 2020 22:20
@ktmud ktmud changed the title WIP: upgrade react-select from v1.3.0 to v3.1.0 and enable sortable multi-select reafactor: upgrade react-select and make multi-select sortable May 7, 2020
@ktmud ktmud changed the title reafactor: upgrade react-select and make multi-select sortable refactor: upgrade react-select and make multi-select sortable May 7, 2020
@ktmud ktmud changed the title refactor: upgrade react-select and make multi-select sortable feat: upgrade react-select and make multi-select sortable May 7, 2020
@ktmud ktmud force-pushed the sortable-metric-input branch 2 times, most recently from a19a6ec to 3106d17 Compare May 7, 2020 22:45
@ktmud ktmud force-pushed the sortable-metric-input branch 5 times, most recently from 0b0a699 to 7d0cd07 Compare May 8, 2020 01:03
Copy link
Member Author

@ktmud ktmud left a comment

Choose a reason for hiding this comment

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

@ All, this is finally ready for review! Apologies in advance for the giant diff.

Added some comments as pointers. For starters, the most important file to look at is https://github.com/apache/incubator-superset/pull/9628/files#diff-650ab8c9d74299035d13f427d0eaf5df

@ktmud ktmud force-pushed the sortable-metric-input branch 3 times, most recently from 8948497 to d803d81 Compare May 18, 2020 20:06
@ktmud
Copy link
Member Author

ktmud commented May 18, 2020

@kristw @etr2460 This is now conflict free. Would you mind taking another look?

ktmud added 9 commits May 19, 2020 16:25
Upgrade `react-select`, replace `react-virtualized-select` with a custom
solution implemented with `react-window`.

Future plans include deprecate `react-virtualized` used in other places, too.

Migrate all react-select related components to `src/Components/Select`.
TODO: add typing support for AsyncSelect props.
@codecov-commenter
Copy link

codecov-commenter commented May 19, 2020

Codecov Report

Merging #9628 into master will increase coverage by 0.10%.
The diff coverage is 88.39%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #9628      +/-   ##
==========================================
+ Coverage   71.02%   71.13%   +0.10%     
==========================================
  Files         583      589       +6     
  Lines       30615    30797     +182     
  Branches     3162     3241      +79     
==========================================
+ Hits        21745    21907     +162     
- Misses       8759     8779      +20     
  Partials      111      111              
Flag Coverage Δ
#cypress 54.02% <79.88%> (+0.46%) ⬆️
#javascript 59.28% <65.19%> (-0.02%) ⬇️
#python 71.27% <ø> (ø)
Impacted Files Coverage Δ
...set-frontend/src/SqlLab/components/QuerySearch.jsx 57.54% <ø> (ø)
...perset-frontend/src/addSlice/AddSliceContainer.jsx 72.72% <ø> (ø)
superset-frontend/src/components/AsyncSelect.jsx 96.29% <ø> (ø)
superset-frontend/src/components/ColumnOption.jsx 100.00% <ø> (ø)
...uperset-frontend/src/components/ExpandableList.tsx 88.88% <ø> (ø)
superset-frontend/src/components/MetricOption.jsx 100.00% <ø> (ø)
superset-frontend/src/components/TableSelector.jsx 88.18% <0.00%> (+4.60%) ⬆️
...et-frontend/src/dashboard/components/CssEditor.jsx 68.18% <ø> (ø)
.../src/dashboard/components/RefreshIntervalModal.jsx 100.00% <ø> (ø)
...ashboard/components/gridComponents/ChartHolder.jsx 81.35% <ø> (ø)
... and 56 more

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 68832d2...5721a03. Read the comment docs.

@kristw
Copy link
Contributor

kristw commented May 19, 2020

LGTM.
Will leave it to @etr2460.

@etr2460 etr2460 merged commit 81ab8dd into apache:master May 19, 2020
@ktmud ktmud deleted the sortable-metric-input branch May 20, 2020 18:06
ktmud added a commit to ktmud/superset-ui that referenced this pull request May 21, 2020
This property for AdhocMetric has been removed by
apache/superset#9628
ktmud added a commit to ktmud/superset-ui that referenced this pull request Jun 17, 2020
auxten pushed a commit to auxten/incubator-superset that referenced this pull request Nov 20, 2020
* feat: upgrade react-select v1.3.0 to v3.1.0

Upgrade `react-select`, replace `react-virtualized-select` with a custom
solution implemented with `react-window`.

Future plans include deprecate `react-virtualized` used in other places, too.

Migrate all react-select related components to `src/Components/Select`.

* Fix new list view

* Fix tests

* Address PR comments

* Fix a flacky Cypress test

* Adjust styles for Select in CRUD ListView

* Fix loadOptions for owners select in chart PropertiesModal

TODO: add typing support for AsyncSelect props.

* Address PR comments; allow isMulti in SelectControl, too

* Clean up NaN in table filter values

* Fix flacky test
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.37.0 labels Feb 28, 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/XXL 🚢 0.37.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants