Skip to content

refactor: Bootstrap to AntD - Alert#12122

Merged
rusackas merged 1 commit into
apache:masterfrom
michael-s-molina:bootstrap-to-antd-alert
Feb 22, 2021
Merged

refactor: Bootstrap to AntD - Alert#12122
rusackas merged 1 commit into
apache:masterfrom
michael-s-molina:bootstrap-to-antd-alert

Conversation

@michael-s-molina
Copy link
Copy Markdown
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
Copy Markdown

codecov-io commented Dec 18, 2020

Codecov Report

❌ Patch coverage is 71.59091% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.01%. Comparing base (2ce7982) to head (3e67ceb).
⚠️ Report is 12600 commits behind head on master.

Files with missing lines Patch % Lines
...et-frontend/src/components/Alert/Alert.stories.tsx 0.00% 15 Missing ⚠️
...erset-frontend/src/datasource/DatasourceEditor.jsx 0.00% 3 Missing ⚠️
...erset-frontend/src/SqlLab/components/ResultSet.tsx 60.00% 2 Missing ⚠️
...et-frontend/src/messageToasts/components/Toast.tsx 87.50% 2 Missing ⚠️
...et-frontend/src/SqlLab/components/QueryHistory.jsx 0.00% 1 Missing ⚠️
...perset-frontend/src/datasource/DatasourceModal.tsx 50.00% 1 Missing ⚠️
.../src/explore/components/ControlPanelsContainer.jsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             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% <66.66%> (+5.38%) ⬆️
javascript 62.42% <71.59%> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread superset-frontend/spec/javascripts/messageToasts/components/Toast_spec.jsx Outdated
@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
Comment thread superset-frontend/src/datasource/DatasourceEditor.jsx Outdated
Comment thread superset-frontend/src/datasource/DatasourceModal.tsx Outdated
Copy link
Copy Markdown
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
Copy Markdown
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
Comment thread superset-frontend/src/messageToasts/components/Toast.tsx Outdated
@rusackas
Copy link
Copy Markdown
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
Copy Markdown
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 michael-s-molina force-pushed the bootstrap-to-antd-alert branch from 654defb to 4ff366a Compare January 5, 2021 13:10
@michael-s-molina
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member

ktmud commented Jan 5, 2021

Great. Good to hear!

@rusackas rusackas added hold! On hold requires: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
@junlincc junlincc added Turing and removed Flexiana labels Jan 27, 2021
@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
Copy Markdown
Member Author

Added new tests using React Testing Library!

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 requires:design-review Requires input/approval from a Designer labels Feb 18, 2021
@rusackas rusackas merged commit 42ab578 into apache:master Feb 22, 2021
qfcwell pushed a commit to qfcwell/superset that referenced this pull request May 12, 2026
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