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

refactor: Bootstrap to AntD - Alert #12122

Merged
merged 1 commit into from
Feb 22, 2021

Conversation

michael-s-molina
Copy link
Member

@michael-s-molina michael-s-molina commented Dec 18, 2020

SUMMARY

Migrates Alert component from Bootstrap to AntD and creates a storybook with full controls support.

BEFORE/AFTER SCREENSHOTS

1-before

Screen Shot 2021-02-04 at 10 14 52 AM

2-before

Screen Shot 2021-02-03 at 7 54 32 PM

3-before

Screen Shot 2021-02-03 at 7 55 08 PM

New Storybook!

Screen Shot 2021-02-04 at 10 10 05 AM

Screen Shot 2021-02-03 at 8 08 17 PM

Toast had a dependency on Alert. I removed this dependency by emulating the same behavior with a styled div. I also added an icon for every status.

toast-error

toast-info

toast-success

toast-warning

We should consider replacing Toast code with AntD Notification.

@rusackas @junlincc @mihir174

Closes #12101

See: #10254

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

@codecov-io
Copy link

codecov-io commented Dec 18, 2020

Codecov Report

Merging #12122 (3e67ceb) into master (2ce7982) will increase coverage by 19.95%.
The diff coverage is 65.38%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master   #12122       +/-   ##
===========================================
+ Coverage   53.06%   73.01%   +19.95%     
===========================================
  Files         489      553       +64     
  Lines       17314    20359     +3045     
  Branches     4482     5332      +850     
===========================================
+ Hits         9187    14866     +5679     
+ Misses       8127     5365     -2762     
- Partials        0      128      +128     
Flag Coverage Δ
cypress 58.44% <72.64%> (+5.38%) ⬆️
javascript 62.42% <51.75%> (?)

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

Impacted Files Coverage Δ
.../src/SqlLab/components/EstimateQueryCostButton.jsx 20.83% <ø> (ø)
...end/src/SqlLab/components/ExploreResultsButton.jsx 92.00% <ø> (+84.00%) ⬆️
...et-frontend/src/SqlLab/components/QueryHistory.jsx 50.00% <0.00%> (ø)
...end/src/SqlLab/components/RunQueryActionButton.tsx 64.28% <ø> (+11.50%) ⬆️
...erset-frontend/src/SqlLab/components/SouthPane.jsx 82.05% <ø> (+17.94%) ⬆️
superset-frontend/src/chart/Chart.jsx 59.64% <ø> (+1.75%) ⬆️
superset-frontend/src/chart/ChartContainer.jsx 100.00% <ø> (ø)
superset-frontend/src/chart/ChartRenderer.jsx 77.02% <0.00%> (+0.31%) ⬆️
...perset-frontend/src/common/components/Dropdown.tsx 54.76% <ø> (+4.76%) ⬆️
...et-frontend/src/components/Alert/Alert.stories.tsx 0.00% <0.00%> (ø)
... and 501 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 9c9becc...3e67ceb. Read the comment docs.

@michael-s-molina michael-s-molina force-pushed the bootstrap-to-antd-alert branch 2 times, most recently from f8cb19d to 8746a36 Compare December 21, 2020 17:26
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.

This is looking AWESOME. Only a couple of minor questions, hoping to steer things a little more toward consistency (i.e. fewer style overrides) if it makes sense. If the ones I asked about need to be that way, then so be it, I'll approve and merge!

@michael-s-molina
Copy link
Member Author

michael-s-molina commented Dec 22, 2020

@rusackas Those were great observations. For me these specific properties (margins) are related to positioning of the component in a screen so they are not generic but layout based. With that in mind, Alert already have properties for this scenario: style and className. What styled is actually doing is passing a className for the Alert component but in a non direct manner so I thought of replacing that with the css property.

<Alert
     css={theme => ({
       marginTop: theme.gridUnit * 4,
       marginBottom: theme.gridUnit * 4,
     })}
     ...
/>

This makes more clear the we are positioning the element and have the benefit of autocompletion and type checking.

You were totally wright about the mismatching grid units. I changed all to 4.

Let me know if you agree with that 😉

@michael-s-molina michael-s-molina force-pushed the bootstrap-to-antd-alert branch 2 times, most recently from 0f6896d to 654defb Compare December 28, 2020 12:16
@michael-s-molina michael-s-molina changed the title refactor: Migrate Bootstrap Alert to AntD (#12101) refactor: Bootstrap to AntD - Alert (#12101) Jan 4, 2021
@rusackas
Copy link
Member

rusackas commented Jan 4, 2021

@rusackas Those were great observations. For me these specific properties (margins) are related to positioning of the component in a screen so they are not generic but layout based. With that in mind, Alert already have properties for this scenario: style and className. What styled is actually doing is passing a className for the Alert component but in a non direct manner so I thought of replacing that with the css property.

<Alert
     css={theme => ({
       marginTop: theme.gridUnit * 4,
       marginBottom: theme.gridUnit * 4,
     })}
     ...
/>

This makes more clear the we are positioning the element and have the benefit of autocompletion and type checking.

You were totally wright about the mismatching grid units. I changed all to 4.

Let me know if you agree with that 😉

If these are one-off, situational tweaks, then I prefer the way you have it here, using the css prop. Somehow that looks more like a contextual tweak, whereas styled makes it look (to me, at least) more like we're creating a new variant of the component.

@rusackas
Copy link
Member

rusackas commented Jan 4, 2021

I think if we add @lilykuang 's suggested tweak (nice catch!) this PR will be good to go!

@michael-s-molina
Copy link
Member Author

michael-s-molina commented Jan 5, 2021

@rusackas Accepted @lilykuang suggestion. I did a forced push to preserve commit history. I wish they implemented --amend in suggested changes.

@rusackas rusackas closed this Jan 5, 2021
@rusackas rusackas reopened this Jan 5, 2021
@ktmud
Copy link
Member

ktmud commented Jan 5, 2021

Need some design input, but have we considered using different colors by status for toasts as well? Icons are great, but still not very differentiable.

@michael-s-molina
Copy link
Member Author

Need some design input, but have we considered using different colors by status for toasts as well? Icons are great, but still not very differentiable.

@ktmud We have considered but chose to keep the same style until we migrate Toast to AntD Notification in a specific PR.

This is how it looks like in AntD:

Screen Shot 2021-01-05 at 3 50 32 PM

@ktmud
Copy link
Member

ktmud commented Jan 5, 2021

Great. Good to hear!

@rusackas rusackas added hold! On hold need:design-review Requires input/approval from a Designer labels Jan 6, 2021
@michael-s-molina michael-s-molina force-pushed the bootstrap-to-antd-alert branch 2 times, most recently from e4a9e36 to 8c8b05b Compare January 26, 2021 21:21
@rusackas rusackas removed the hold! On hold label Jan 27, 2021
@michael-s-molina michael-s-molina changed the title refactor: Bootstrap to AntD - Alert (#12101) refactor: Bootstrap to AntD - Alert Jan 29, 2021
@michael-s-molina michael-s-molina force-pushed the bootstrap-to-antd-alert branch 2 times, most recently from 4a0e857 to 7b708ec Compare February 2, 2021 19:36
@pull-request-size pull-request-size bot added size/XL and removed size/L labels Feb 4, 2021
@michael-s-molina michael-s-molina force-pushed the bootstrap-to-antd-alert branch 3 times, most recently from b74bb2b to 878c5a1 Compare February 5, 2021 16:35
@michael-s-molina
Copy link
Member Author

Added new tests using React Testing Library!

Copy link
Member Author

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

Merged with master

border: 0,
backgroundColor: baseColor.light2,
'& .ant-alert-icon': {
marginRight: 10,
Copy link
Member

Choose a reason for hiding this comment

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

2 * gridUnit?

Copy link
Member Author

Choose a reason for hiding this comment

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

Here I'm following the exact design specification values. If we want to change this maybe we should talk with the design team to use multiples of 4 when dealing with margins, padding, etc.

icon={<Icon name={iconName} aria-label={`${type} icon`} />}
closeText={closable && <Icon name="x-small" aria-label="close icon" />}
css={{
padding: '6px 10px',
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if it makes sense to round these up or down to the nearest gridUnit

Copy link
Member Author

Choose a reason for hiding this comment

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

Same as the previous comment.

'We recommend your summarize your data further before following that flow. ',
) +
t('If activated you can use the ')}
<strong>CREATE TABLE AS </strong>
Copy link
Member

@rusackas rusackas Feb 18, 2021

Choose a reason for hiding this comment

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

Suggested change
<strong>CREATE TABLE AS </strong>
<strong>{t("Create table as").toUpperCase()} </strong>

I'm guessing this would work? ¯\_(ツ)_/¯

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think this should be translated because it's referencing a command that doesn't have a translation.

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.

Noted a few minor nits, but again this PR looks great to me in general, so I'll stamp it, and circle back soon to merge whether or not those nits lead to any changes ;)

@rusackas rusackas removed hold! On hold need:design-review Requires input/approval from a Designer labels Feb 18, 2021
@rusackas rusackas merged commit 42ab578 into apache:master Feb 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[up coming change]Replace Alert (react-bootstrap -> AntD migration)
6 participants