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: A newly connected database doesn't appear in the databases list if user connected database using the 'plus' button #19967

Merged

Conversation

diegomedina248
Copy link
Contributor

SUMMARY

The database connection modal fires a callback when a db is successfully connected.
The problem is, the database list cannot listen to that callback when the modal is displayed/shown outside of the container.

This PR enables that functionality via query params, so that the database list can be notified and refreshed.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:

Screen.Recording.2022-05-05.at.22.19.44.mov

After:

new.mov

TESTING INSTRUCTIONS

Go to the dashboard list and connect a new database from the top "plus button" menu.
Ensure you can see the newly connected database without refreshing the page.

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 May 6, 2022

Codecov Report

Merging #19967 (7fe0307) into master (6f0d53e) will decrease coverage by 0.00%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master   #19967      +/-   ##
==========================================
- Coverage   66.65%   66.65%   -0.01%     
==========================================
  Files        1729     1729              
  Lines       64910    64917       +7     
  Branches     6842     6843       +1     
==========================================
+ Hits        43268    43272       +4     
- Misses      19893    19895       +2     
- Partials     1749     1750       +1     
Flag Coverage Δ
javascript 51.57% <50.00%> (+<0.01%) ⬆️

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.33% <0.00%> (ø)
...tend/src/views/CRUD/data/database/DatabaseList.tsx 67.70% <40.00%> (-1.53%) ⬇️
...perset-frontend/src/views/components/MenuRight.tsx 60.60% <100.00%> (+0.81%) ⬆️

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 6f0d53e...7fe0307. Read the comment docs.

@yousoph yousoph requested a review from stephenLYZ May 20, 2022 18:50
@stephenLYZ
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented Jun 1, 2022

@stephenLYZ Ephemeral environment spinning up at http://34.220.151.120:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

Copy link
Member

@stephenLYZ stephenLYZ left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! Left a comment.

@@ -503,7 +503,6 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
setImportingModal(false);
setPasswords({});
setConfirmedOverwrite(false);
if (onDatabaseAdd) onDatabaseAdd();
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious about the reason for the deletion here, it looks like the close method will be called in multiple places, not just the model closing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, sure.
Calling onDatabaseAdd in the onClose causes the callback to be fired when it shouldn't.
The onClose is called, for instance, if you hit in the overlay.
That causes (in master) the following:

Screen.Recording.2022-06-03.at.13.26.19.mov

The only places that should be called is when a change was actually made (which was done already in almost all places, causing a double fetch/rerender).
The only place that uses this function is DatabaseList, which only does a refresh.

@diegomedina248 diegomedina248 force-pushed the fix/show-db-created-via-plus-button branch from b8acb2c to 8fac930 Compare June 3, 2022 16:25
@diegomedina248 diegomedina248 reopened this Jun 3, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Jun 3, 2022

Ephemeral environment shutdown and build artifacts deleted.

@@ -94,6 +96,10 @@ const RightMenu = ({
state => state.dashboardInfo?.id,
);

const [, setQuery] = useQueryParams({
Copy link
Member

Choose a reason for hiding this comment

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

oh this is interesting, I hadn't seen this before. Does this bypass the variable and only create the function?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, this just ignores the value in the first position, but the function returns the whole thing.
Just a nice syntax sugar thing when destructuring

Copy link
Member

Choose a reason for hiding this comment

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

yeah I like it too!

Copy link
Member

@stephenLYZ stephenLYZ left a comment

Choose a reason for hiding this comment

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

Thanks for the fix! LGTM

@stephenLYZ stephenLYZ merged commit 8345eb4 into apache:master Jun 12, 2022
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 2.0.0 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 Preset-Patch size/M 🚢 2.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants