-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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(Alert): Migrate Alert component to Ant Design V5 #31168
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. I gave it a first-pass review. I am wondering if we need to upgrade more references to the updated class selectors throughout the code ant5-{something}
for the Alert component.
@@ -62,7 +62,7 @@ describe('Visualization > Line', () => { | |||
'not.exist', | |||
); | |||
|
|||
cy.get('.ant-alert-warning').should('not.exist'); | |||
cy.get('.antd-v5-alert-warning').should('not.exist'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cy.get('.antd-v5-alert-warning').should('not.exist'); | |
cy.get('.antd5-alert-warning').should('not.exist'); |
@@ -71,7 +71,7 @@ describe('Visualization > Line', () => { | |||
cy.get('#controlSections-tab-display').click(); | |||
cy.get('span').contains('Y Axis Bounds').scrollIntoView(); | |||
cy.get('input[placeholder="Min"]').type('-0.1', { delay: 100 }); | |||
cy.get('.ant-alert-warning').should('not.exist'); | |||
cy.get('.antd-v5-alert-warning').should('not.exist'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cy.get('.antd-v5-alert-warning').should('not.exist'); | |
cy.get('.antd5-alert-warning').should('not.exist'); |
@@ -94,7 +94,7 @@ export const databasesPage = { | |||
dbDropdown: '[class="ant-select-selection-search-input"]', | |||
dbDropdownMenu: '.rc-virtual-list-holder-inner', | |||
dbDropdownMenuItem: '[class="ant-select-item-option-content"]', | |||
infoAlert: '.ant-alert', | |||
infoAlert: '.antd-v5-alert', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
infoAlert: '.antd-v5-alert', | |
infoAlert: '.antd5-alert', |
@@ -103,7 +103,7 @@ export const databasesPage = { | |||
helperBottom: '.helper-bottom', | |||
postgresDatabase: '[name="database"]', | |||
dbInput: '[name="database_name"]', | |||
alertMessage: '.ant-alert-message', | |||
alertMessage: '.antd-v5-alert-message', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alertMessage: '.antd-v5-alert-message', | |
alertMessage: '.antd5-alert-message', |
@@ -166,7 +166,7 @@ export const sqlLabView = { | |||
renderedTableHeader: '.ReactVirtualized__Table__headerRow', | |||
renderedTableRow: '.ReactVirtualized__Table__row', | |||
errorBody: '.error-body', | |||
alertMessage: '.ant-alert-message', | |||
alertMessage: '.antd-v5-alert-message', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alertMessage: '.antd-v5-alert-message', | |
alertMessage: '.antd5-alert-message', |
@@ -325,7 +325,7 @@ export const nativeFilters = { | |||
confirmCancelButton: dataTestLocator( | |||
'native-filter-modal-confirm-cancel-button', | |||
), | |||
alertXUnsavedFilters: '.ant-alert-message', | |||
alertXUnsavedFilters: '.antd-v5-alert-message', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alertXUnsavedFilters: '.antd-v5-alert-message', | |
alertXUnsavedFilters: '.antd5-alert-message', |
@@ -82,6 +84,7 @@ InteractiveAlert.args = { | |||
message: smallText, | |||
description: bigText, | |||
showIcon: true, | |||
closeIcon: <span aria-label="close icon">x</span>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we do not need the closeIcon
to be one of the storybook args as it accepts a ReactNode and it is hard to configure this in the storybook UI
@@ -44,6 +44,7 @@ export const AlertGallery = () => ( | |||
type={type} | |||
showIcon | |||
closable | |||
closeIcon={<span aria-label="close icon">x</span>} // Custom close icon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove closeIcon
from here and create a separate Alert component with a custom close icon just to show this option in storybook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion! I opted to showcase the closeIcon directly in the existing AlertGallery to keep things simple and avoid adding extra components. Since closeIcon isn't part of the Storybook args, I think this approach still effectively demonstrates its customization without adding another component.
closeIcon={closable && <Icons.XSmall aria-label="close icon" />} | ||
message={children || 'Default message'} | ||
description={description} | ||
style={{ | ||
marginBottom: roomBelow ? gridUnit * 4 : 0, | ||
padding: `${gridUnit * 2}px ${gridUnit * 3}px`, | ||
alignItems: 'flex-start', | ||
border: 0, | ||
backgroundColor: baseColor.light2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you have removed a bunch of custom styles, which is good, but should we bring these in the component theme instead, including also those that you kept? You can see examples here
@LevisNgigi should this PR be a refactor instead of a chore? |
@sadpandajoe Let me change it |
closeIcon={closable && <Icons.XSmall aria-label="close icon" />} | ||
message={children || 'Default message'} | ||
description={description} | ||
style={{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need these styles here?
4dda84f
to
bab51f1
Compare
/testenv up |
@geido Ephemeral environment spinning up at http://null:8080. Credentials are |
Co-authored-by: Diego Pucci <[email protected]> (cherry picked from commit 79aff68)
SUMMARY
This PR upgrades the Alert component to Ant Design V5
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Before
After
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION