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(explore): Dashboard list is unsorted in save modal #21317

Merged
merged 7 commits into from
Oct 3, 2022

Conversation

agl-developer
Copy link
Contributor

SUMMARY

Listed dashboards in the save chart modal should show up alphabetically.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before:
Screen Shot 2022-08-09 at 10 07 47 AM

After:
image

TESTING INSTRUCTIONS

  • Click on 'Charts' in the top menu bar
  • Select an existing chart.
  • Click on the 'Save' button on the top right.
  • Expand the dropdown under 'Add to Dashboard'

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 3, 2022

Codecov Report

Merging #21317 (c90e223) into master (4c17f0e) will increase coverage by 0.01%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master   #21317      +/-   ##
==========================================
+ Coverage   66.82%   66.84%   +0.01%     
==========================================
  Files        1798     1798              
  Lines       68827    68829       +2     
  Branches     7333     7333              
==========================================
+ Hits        45997    46012      +15     
+ Misses      20951    20932      -19     
- Partials     1879     1885       +6     
Flag Coverage Δ
javascript 53.20% <50.00%> (+0.03%) ⬆️

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

Impacted Files Coverage Δ
...t-frontend/src/explore/actions/saveModalActions.js 97.26% <50.00%> (-1.34%) ⬇️
...board/components/nativeFilters/FilterBar/index.tsx 66.18% <0.00%> (+5.75%) ⬆️
...rd/components/nativeFilters/FilterBar/keyValue.tsx 40.74% <0.00%> (+22.22%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@geido
Copy link
Member

geido commented Sep 8, 2022

/testenv up

@github-actions
Copy link
Contributor

github-actions bot commented Sep 8, 2022

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

@geido
Copy link
Member

geido commented Sep 12, 2022

@michael-s-molina I'd like your opinion here. I don't think this problem is related to this PR but testing with numeric dashboards I am getting an unwanted behaviour. I believe this could be the same problem that was reported elsewhere. Probably worth having a sync session about it.

Screenshot 2022-09-12 at 14 25 28

Comment on lines 46 to 52
if (labelA < labelB) {
return -1;
}
if (labelA > labelB) {
return 1;
}
return 0;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (labelA < labelB) {
return -1;
}
if (labelA > labelB) {
return 1;
}
return 0;
return labelA.localeCompare(labelB);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@michael-s-molina @geido Made a change so that when a string begins with a number it sorts numerically instead. Does not fix all the cases but addresses several.

Copy link
Member

Choose a reason for hiding this comment

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

@agl-developer What you're trying to achieve is a concept called Natural Sorting. This is already supported natively by localeCompare using { sensitivity: 'base', numeric: true }

@codyml
Copy link
Member

codyml commented Sep 28, 2022

@agl-developer Would you mind updating saveModalActions.test.js so sorting gets a little testing?

Comment on lines 46 to 53
choices.sort((a, b) => {
const labelA = a.label.toUpperCase();
const labelB = b.label.toUpperCase();
return labelA.localeCompare(labelB, {
sensitivity: 'base',
numeric: true,
});
});
Copy link
Member

Choose a reason for hiding this comment

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

sensitivity: 'base' already handles case sensitivity.

Suggested change
choices.sort((a, b) => {
const labelA = a.label.toUpperCase();
const labelB = b.label.toUpperCase();
return labelA.localeCompare(labelB, {
sensitivity: 'base',
numeric: true,
});
});
choices.sort((a, b) =>
a.label.localeCompare(b.label, {
sensitivity: 'base',
numeric: true,
}),
);

Copy link
Member

@michael-s-molina michael-s-molina left a comment

Choose a reason for hiding this comment

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

LGTM

@geido geido merged commit 3edc656 into apache:master Oct 3, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2022

Ephemeral environment shutdown and build artifacts deleted.

@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/XS 🚢 2.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants