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

chore: Select component refactoring - SelectControl - Iteration 5 #16510

Merged
merged 35 commits into from
Oct 4, 2021
Merged

chore: Select component refactoring - SelectControl - Iteration 5 #16510

merged 35 commits into from
Oct 4, 2021

Conversation

geido
Copy link
Member

@geido geido commented Aug 30, 2021

SUMMARY

The goal of this PR is to remove the instances of the older react-select Selects and replace them with the Antdesign Select component. It removes the SelectControl component where possible OR refactors it by mapping the props to minimize the impact.

BEFORE/AFTER FILTER BOX

filterbox_before.mp4
filterbox_after.mp4

BEFORE/AFTER SPATIAL CONTROL

spatialcontrol_before.mp4
spatialcontrol_after.mp4

BEFORE/AFTER ANNOTATION LAYERS

annotation_layers_before.mp4
annotation_layers_after.mp4

BEFORE/AFTER DATASOURCE EDITOR

datasource_editor_before.mp4
datasource_editor_after.mp4

BEFORE/AFTER CONTROLS

controls_before.mp4
controls_after.mp4

TESTING INSTRUCTIONS

Test each component individually and all possible controls

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@geido geido marked this pull request as draft August 30, 2021 15:51
@@ -48,58 +48,27 @@ describe('SelectControl', () => {
wrapper = shallow(<SelectControl {...defaultProps} />);
});

it('uses Select in onPasteSelect when freeForm=false', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

The OnPasteSelect is not used with the new Select component. These tests are included later checking whether allowNewOptions is true or false based on the SelectControl freeForm option.

expect(defaultProps.onChange.calledWith(50)).toBe(true);
});

it('returns all options on select all', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

The "Select all" option has been removed as agreed with design and all the related tests have been removed as well

@@ -161,16 +130,6 @@ describe('SelectControl', () => {
);
expect(wrapper.html()).not.toContain('add something');
});
it('shows numbers of options as a placeholder by default', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

The number of options and remaining options has been removed as agreed with design and all the related tests have been removed as well

});
});

it('returns the correct options when freeform is set to true', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

This test is not necessary with the new Select component as it is a standard behavior

@geido geido requested review from michael-s-molina, etr2460 and ktmud and removed request for michael-s-molina September 16, 2021 15:58
@geido geido removed the hold:testing! On hold for testing label Sep 16, 2021
@codecov
Copy link

codecov bot commented Sep 16, 2021

Codecov Report

Merging #16510 (5c76195) into master (4086bed) will decrease coverage by 0.04%.
The diff coverage is 66.66%.

❗ Current head 5c76195 differs from pull request most recent head 748af87. Consider uploading reports for the commit 748af87 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #16510      +/-   ##
==========================================
- Coverage   77.00%   76.96%   -0.05%     
==========================================
  Files        1018     1018              
  Lines       54654    54580      -74     
  Branches     7454     7427      -27     
==========================================
- Hits        42086    42005      -81     
- Misses      12324    12328       +4     
- Partials      244      247       +3     
Flag Coverage Δ
javascript 70.97% <66.66%> (-0.11%) ⬇️

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

Impacted Files Coverage Δ
...mponents/controls/AnnotationLayerControl/index.jsx 8.33% <0.00%> (+0.54%) ⬆️
...src/explore/components/controls/SpatialControl.jsx 6.75% <ø> (ø)
superset-frontend/src/explore/controls.jsx 29.72% <ø> (+1.15%) ⬆️
...ontrols/AnnotationLayerControl/AnnotationLayer.jsx 84.28% <50.00%> (+0.42%) ⬆️
.../src/explore/components/controls/SelectControl.jsx 80.00% <68.75%> (-9.39%) ⬇️
...erset-frontend/src/datasource/DatasourceEditor.jsx 73.85% <100.00%> (ø)
...components/controls/FilterBoxItemControl/index.jsx 73.58% <100.00%> (ø)
...rontend/src/components/Select/DeprecatedSelect.tsx 67.64% <0.00%> (-14.71%) ⬇️
.../explore/components/controls/TextControl/index.tsx 82.92% <0.00%> (-4.88%) ⬇️
superset-frontend/src/components/Select/styles.tsx 81.94% <0.00%> (-2.78%) ⬇️
... and 2 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 4086bed...748af87. Read the comment docs.

@geido
Copy link
Member Author

geido commented Sep 17, 2021

/testenv up

@github-actions
Copy link
Contributor

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

geido and others added 3 commits September 21, 2021 14:20
…yerControl/AnnotationLayer.test.tsx

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
…yerControl/AnnotationLayer.test.tsx

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
@pkdotson
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

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

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! Tested in eph env and everything works great!

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

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

This is amazing work, comparing the before/after was such a visible improvement! 🎉 LGTM!

Comment on lines +124 to +129
const DATA_TYPES = [
{ value: 'STRING', label: 'STRING' },
{ value: 'NUMERIC', label: 'NUMERIC' },
{ value: 'DATETIME', label: 'DATETIME' },
{ value: 'BOOLEAN', label: 'BOOLEAN' },
];
Copy link
Member

Choose a reason for hiding this comment

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

Not for this PR, but this probably shouldn't be a Select component at all, but rather a text field. These should be raw column types coming from the database, hence a typical STRING will be VARCHAR(x), TEXT etc.

@geido geido merged commit 3f0756f into apache:master Oct 4, 2021
@geido geido deleted the chore/select-component-refactoring-selectcontrol-iteration-5 branch October 4, 2021 15:24
@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2021

Ephemeral environment shutdown and build artifacts deleted.

opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
…ache#16510)

* Refactor Select DatasourceEditor

* Fire onChange with allowNewOptions

* Clean up

* Refactor Select in AnnotationLayer

* Handle on clear

* Update tests

* Refactor Select in SpatialControl

* Show search

* Refactor Select in FilterBox

* Remove search where unnecessary

* Update SelectControl - WIP

* Refactor Controls

* Update SelectControl tests

* Clean up

* Test allowNewOptions false

* Use SelectControl AnnotationLayer

* Use SelectControl SpatialControl

* Clean up

* Render custom label

* Show search

* Implement filterOption

* Improve filterOption

* Update Cypress

* Update Cypress table test

* Use value for defaultValue

* Merge with latest changes

* Reconcile with latest Select changes

* Update superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.test.tsx

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>

* Update superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.test.tsx

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>

* Revert changes to test

* Call onPopoverClear when v value is undefined

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
…ache#16510)

* Refactor Select DatasourceEditor

* Fire onChange with allowNewOptions

* Clean up

* Refactor Select in AnnotationLayer

* Handle on clear

* Update tests

* Refactor Select in SpatialControl

* Show search

* Refactor Select in FilterBox

* Remove search where unnecessary

* Update SelectControl - WIP

* Refactor Controls

* Update SelectControl tests

* Clean up

* Test allowNewOptions false

* Use SelectControl AnnotationLayer

* Use SelectControl SpatialControl

* Clean up

* Render custom label

* Show search

* Implement filterOption

* Improve filterOption

* Update Cypress

* Update Cypress table test

* Use value for defaultValue

* Merge with latest changes

* Reconcile with latest Select changes

* Update superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.test.tsx

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>

* Update superset-frontend/src/explore/components/controls/AnnotationLayerControl/AnnotationLayer.test.tsx

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>

* Revert changes to test

* Call onPopoverClear when v value is undefined

Co-authored-by: Michael S. Molina <70410625+michael-s-molina@users.noreply.github.com>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.0 labels Mar 13, 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 risk:refactor High risk as it involves large refactoring work size/XL 🚢 1.4.0
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

5 participants