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: Database List Sorted #15619

Merged
merged 5 commits into from
Jul 9, 2021
Merged

Conversation

AAfghahi
Copy link
Member

@AAfghahi AAfghahi commented Jul 9, 2021

SUMMARY

Screen.Recording.2021-07-09.at.1.55.10.PM.mov

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • 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

@@ -559,11 +560,8 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
onChange={setDatabaseModel}
placeholder="Choose a database..."
>
{availableDbs?.databases
?.sort((a: DatabaseForm, b: DatabaseForm) =>
a.name.localeCompare(b.name),
Copy link
Member

Choose a reason for hiding this comment

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

you're losing your sorting here by name.

@@ -342,6 +342,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
const dbImages = getDatabaseImages();
const connectionAlert = getConnectionAlert();
const isEditMode = !!databaseId;
const sortedAvailableDBs = availableDbs?.databases.sort();
Copy link
Member

Choose a reason for hiding this comment

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

this won't actually sort because the databases are objects... see note below.

@@ -613,7 +611,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({

const renderPreferredSelector = () => (
<div className="preferred">
{availableDbs?.databases
{sortedAvailableDBs
Copy link
Member

Choose a reason for hiding this comment

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

This should keep the original sort order from the api response.

@codecov
Copy link

codecov bot commented Jul 9, 2021

Codecov Report

Merging #15619 (6f2bf3f) into master (f67e402) will increase coverage by 0.07%.
The diff coverage is 81.81%.

❗ Current head 6f2bf3f differs from pull request most recent head 46eecbd. Consider uploading reports for the commit 46eecbd to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##           master   #15619      +/-   ##
==========================================
+ Coverage   76.88%   76.95%   +0.07%     
==========================================
  Files         976      976              
  Lines       51325    51325              
  Branches     6910     6912       +2     
==========================================
+ Hits        39459    39496      +37     
+ Misses      11647    11608      -39     
- Partials      219      221       +2     
Flag Coverage Δ
javascript 71.41% <81.81%> (-0.01%) ⬇️

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

Impacted Files Coverage Δ
superset-frontend/src/views/CRUD/hooks.ts 48.23% <ø> (ø)
...s/CRUD/data/database/DatabaseModal/ModalHeader.tsx 89.18% <66.66%> (-2.48%) ⬇️
...et-frontend/src/messageToasts/components/Toast.tsx 92.50% <85.71%> (-0.19%) ⬇️
...c/views/CRUD/data/database/DatabaseModal/index.tsx 47.56% <100.00%> (-0.31%) ⬇️
superset/models/core.py 90.02% <0.00%> (+0.26%) ⬆️
superset/connectors/sqla/models.py 89.90% <0.00%> (+1.40%) ⬆️
superset/db_engine_specs/presto.py 89.89% <0.00%> (+5.47%) ⬆️

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 f67e402...46eecbd. Read the comment docs.

@pull-request-size pull-request-size bot added size/L and removed size/S labels Jul 9, 2021
const renderAvailableSelector = () => {
let sortedAvailableDBs;
if (availableDbs) {
sortedAvailableDBs = availableDbs?.databases.slice();
Copy link
Member

Choose a reason for hiding this comment

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

you can also make a simple copy with the spread operator.

const renderAvailableSelector = () => {
let sortedAvailableDBs;
if (availableDbs) {
sortedAvailableDBs = [...(availableDbs?.databases || [])];
Copy link
Member

Choose a reason for hiding this comment

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

one last thing.. can you move this down to line 568 and remove a few lines of code that way?

@pull-request-size pull-request-size bot added size/S and removed size/L labels Jul 9, 2021
{database.name}
</Select.Option>
))}
{availableDbs &&
Copy link
Member

Choose a reason for hiding this comment

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

since you have the conditional operator below, you don't need to check for availableDbs again here.

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

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

Looks great!

@eschutho eschutho merged commit faf6fcd into apache:master Jul 9, 2021
@eschutho eschutho deleted the ch19555_shuffleFiles branch July 9, 2021 20:06
@rosemarie-chiu
Copy link
Contributor

🏷 2021.27

henryyeh pushed a commit to preset-io/superset that referenced this pull request Jul 13, 2021
* sorted the database list

* revisions

* cloned the array

* one more time with feeling

* added documentation link as well

(cherry picked from commit faf6fcd)
cccs-RyanS pushed a commit to CybercentreCanada/superset that referenced this pull request Dec 17, 2021
* sorted the database list

* revisions

* cloned the array

* one more time with feeling

* added documentation link as well
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 29, 2021
* sorted the database list

* revisions

* cloned the array

* one more time with feeling

* added documentation link as well
cccs-rc pushed a commit to CybercentreCanada/superset that referenced this pull request Mar 6, 2024
* sorted the database list

* revisions

* cloned the array

* one more time with feeling

* added documentation link as well
@mistercrunch mistercrunch added the 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels label Mar 12, 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:2021.27 size/S 🚢 1.3.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants