-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
fix: Database List Sorted #15619
Conversation
d790d5f
to
5cb434c
Compare
@@ -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), |
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'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(); |
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 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 |
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 should keep the original sort order from the api response.
Codecov Report
@@ 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
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
const renderAvailableSelector = () => { | ||
let sortedAvailableDBs; | ||
if (availableDbs) { | ||
sortedAvailableDBs = availableDbs?.databases.slice(); |
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 also make a simple copy with the spread operator.
1ffc3a3
to
7569da5
Compare
const renderAvailableSelector = () => { | ||
let sortedAvailableDBs; | ||
if (availableDbs) { | ||
sortedAvailableDBs = [...(availableDbs?.databases || [])]; |
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.
one last thing.. can you move this down to line 568 and remove a few lines of code that way?
{database.name} | ||
</Select.Option> | ||
))} | ||
{availableDbs && |
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.
since you have the conditional operator below, you don't need to check for availableDbs again 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.
Looks great!
🏷 2021.27 |
* sorted the database list * revisions * cloned the array * one more time with feeling * added documentation link as well (cherry picked from commit faf6fcd)
* sorted the database list * revisions * cloned the array * one more time with feeling * added documentation link as well
* sorted the database list * revisions * cloned the array * one more time with feeling * added documentation link as well
* sorted the database list * revisions * cloned the array * one more time with feeling * added documentation link as well
SUMMARY
Screen.Recording.2021-07-09.at.1.55.10.PM.mov
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION