-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
feat: add modal to import databases #11884
Conversation
f7b1602
to
1556c25
Compare
1556c25
to
91f3b14
Compare
cc: @eschutho |
Codecov Report
@@ Coverage Diff @@
## master #11884 +/- ##
==========================================
- Coverage 64.45% 60.52% -3.94%
==========================================
Files 937 891 -46
Lines 45319 43517 -1802
Branches 4317 3841 -476
==========================================
- Hits 29211 26339 -2872
- Misses 15948 17178 +1230
+ Partials 160 0 -160
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
superset-frontend/src/database/components/ImportModal/ImportModal.test.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/src/database/components/ImportModal/ImportModal.test.tsx
Show resolved
Hide resolved
superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx
Outdated
Show resolved
Hide resolved
superset-frontend/src/views/CRUD/data/database/DatabaseList.tsx
Outdated
Show resolved
Hide resolved
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.
🚢
type="password" | ||
value={passwords[fileName]} | ||
onChange={event => | ||
setPasswords({ ...passwords, [fileName]: event.target.value }) |
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.
put this in a handleStyleContainerInputChange function at the top for consistency
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'll do that in #11936, so I only have to do it once.
90569fd
to
5fb717c
Compare
SUMMARY
This PR adds a new button to import databases from the UI if the
VERSIONED_EXPORT
feature flag is enabled. It allows users to import databases in the new format proposed in #11167.The biggest challenge in importing databases is that we export them without passwords, extra security information, nor certificates. When importing database we can inspect the
sqlalchemy_uri
attribute and see if it has a masked password (XXXXXXXX
), and if true we can prompt the user for the password.The second biggest challenge is that we don't know how many databases are present in the imported file, since users can export multiple databases at once in a single file. We also don't know how many of those require passwords, since not all databases use them.
To work around this when the user tries to import a file the frontend will upload it to the backend. The backend performs validation on the file, and if there are databases with masked passwords it returns a validation error (422). The frontend will parse the error message, and if the only errors are from missing passwords it will prompt the user for the passwords and resubmit the file, this time with the associated passwords.
This PR adds the backend validation, as well as the import modal. For the API calls I created a new hook similar to
useSingleViewResource
calleduseImportResource
, which will be reused for other imports (dataset, chart, dashboard and saved queries).BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
Manually tested importing a database, and confirmed it prompts for the password and the database is configured correctly.
Also added tests.
ADDITIONAL INFORMATION