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

fix: DB connection modal connect bug #21299

Conversation

AAfghahi
Copy link
Member

@AAfghahi AAfghahi commented Sep 1, 2022

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

  • 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

@codecov
Copy link

codecov bot commented Sep 1, 2022

Codecov Report

Merging #21299 (df47f96) into master (fbe9807) will increase coverage by 0.00%.
The diff coverage is 66.66%.

@@           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           
Flag Coverage Δ
hive 53.02% <ø> (ø)
javascript 52.49% <66.66%> (+<0.01%) ⬆️
mysql 80.82% <ø> (ø)
postgres 80.88% <ø> (ø)
presto 52.92% <ø> (ø)
python 81.35% <ø> (ø)
sqlite 79.43% <ø> (ø)
unit 50.77% <ø> (ø)

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

Impacted Files Coverage Δ
...c/views/CRUD/data/database/DatabaseModal/index.tsx 32.03% <50.00%> (ø)
...c/views/CRUD/data/database/DatabaseModal/styles.ts 76.92% <100.00%> (+0.22%) ⬆️

📣 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()}
Copy link
Contributor

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?

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 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}
Copy link
Contributor

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;
Copy link
Contributor

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 :)

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 agree, and I changed it. Thank you!

@AAfghahi AAfghahi force-pushed the arash.afghahi/sc-56572/database-connect-db-page-show-error-if-user branch from b3e76cc to f22e694 Compare September 1, 2022 18:46
Copy link
Contributor

@eric-briscoe eric-briscoe left a 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 <></>;
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

not a blocker.

Copy link
Member Author

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.

Copy link
Member Author

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

@AAfghahi AAfghahi force-pushed the arash.afghahi/sc-56572/database-connect-db-page-show-error-if-user branch from db1b89a to 3a84ad5 Compare September 1, 2022 21:07
@AAfghahi AAfghahi force-pushed the arash.afghahi/sc-56572/database-connect-db-page-show-error-if-user branch from 3a84ad5 to df47f96 Compare September 2, 2022 13:37
@AAfghahi AAfghahi merged commit 99a4f05 into master Sep 2, 2022
@AAfghahi AAfghahi deleted the arash.afghahi/sc-56572/database-connect-db-page-show-error-if-user branch September 2, 2022 16:14
sadpandajoe pushed a commit to preset-io/superset that referenced this pull request Sep 2, 2022
@sadpandajoe
Copy link
Member

🏷️ preset:2022.35

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.1.0 and removed 🚢 2.1.3 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 size/S 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants