-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
fix: DB connection modal connect bug #21299
fix: DB connection modal connect bug #21299
Conversation
Codecov Report
@@ Coverage Diff @@
## master #21299 +/- ##
=======================================
Coverage 66.45% 66.45%
=======================================
Files 1789 1789
Lines 68296 68297 +1
Branches 7275 7275
=======================================
+ Hits 45387 45388 +1
Misses 21034 21034
Partials 1875 1875
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@@ -1509,6 +1511,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |||
show={show} | |||
title={<h4>{t('Connect a database')}</h4>} | |||
footer={renderModalFooter()} |
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.
@AAfghahi Do you want to be using the modalFooter variable here?
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.
This is referencing line 1511? If so, no I don't think so becuase it comes after a ternary that checks for isEditMode
@@ -1509,6 +1511,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |||
show={show} | |||
title={<h4>{t('Connect a database')}</h4>} | |||
footer={renderModalFooter()} | |||
hideFooter={renderModalFooter() ? false : true} |
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.
You can use simpler truthy/falsey statement here with the existing modalFooter
variable:
hideFooter={!modalFooter}
@@ -156,7 +156,7 @@ export const antDModalStyles = (theme: SupersetTheme) => css` | |||
} | |||
|
|||
.ant-modal-body { | |||
height: ${theme.gridUnit * 180.5}px; | |||
height: ${theme.gridUnit * 188}px; |
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.
A good practice is to define numbers as a const with a comment providing its purpose, then use the const. Referred to commonly as a "magic number" because there is no context to what the value means. Having a const with a comment will help future developers understand what this number represents, and how changing it will affect the rendering of the component.
I this case you would define a const outside of the style rendering block like:
const DESCRIPTIVE_NAME:number = 188 // Description of what this is for...
Then in the styling block use it like:
height: ${theme.gridUnit * DESCRIPTIVE_NAME}px;
I know you did not define this originally, but this is a simple opportunity to make code more readable for future devs :)
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 agree, and I changed it. Thank you!
b3e76cc
to
f22e694
Compare
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.
Looks good, fixes issue
@@ -901,7 +901,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |||
); | |||
} | |||
|
|||
return []; | |||
return <></>; |
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.
just a style nit, but most times that I've seen components render nothing, it would be a return null
here.
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.
not a blocker.
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.
ok let me test to make sure that this still renders the expected behavior.
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.
Ok no, that would render the default footer component because of the logic here:
https://github.com/apache/superset/blob/master/superset-frontend/src/components/Modal/Modal.tsx#L256
db1b89a
to
3a84ad5
Compare
3a84ad5
to
df47f96
Compare
(cherry picked from commit 99a4f05)
🏷️ preset:2022.35 |
SUMMARY
This was a bug that occurs because we have a default footer in our modal styles that let us connect when there is no database, which gave users a connection error. This hides the footer in the first stage of the DB modal, which is what it was according to its original design.
I also added some height to the modal so that the first stage doesn't need a scroll, happy to revert that.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Screen.Recording.2022-09-01.at.2.56.48.PM.mov
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION