mirror of
https://github.com/apache/airflow.git
synced 2026-11-04 07:12:48 +00:00
Fix registry providers page not sorting by downloads on initial load (#63764)
The sort dropdown defaulted to "Most Downloads" but the sort logic only ran on the `change` event, so providers stayed in alphabetical order (the template render order) until the user manually toggled the dropdown.
This commit is contained in:
1 parent
fac3cca9fd
commit
9a33a25c48
1 file changed
+21
-18
@@ -132,29 +132,32 @@
|
||||
});
|
||||
}
|
||||
|
||||
if (sortSelect) {
|
||||
sortSelect.addEventListener('change', () => {
|
||||
const sortBy = sortSelect.value;
|
||||
const items = Array.from(providerItems);
|
||||
function sortProviders() {
|
||||
const sortBy = sortSelect.value;
|
||||
const items = Array.from(providerItems);
|
||||
|
||||
items.sort((a, b) => {
|
||||
switch (sortBy) {
|
||||
case 'downloads':
|
||||
return Number(b.dataset.downloads || 0) - Number(a.dataset.downloads || 0);
|
||||
case 'name':
|
||||
return (a.dataset.name || '').localeCompare(b.dataset.name || '');
|
||||
case 'updated':
|
||||
return (b.dataset.updated || '').localeCompare(a.dataset.updated || '');
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
items.forEach(item => providerGrid.appendChild(item));
|
||||
items.sort((a, b) => {
|
||||
switch (sortBy) {
|
||||
case 'downloads':
|
||||
return Number(b.dataset.downloads || 0) - Number(a.dataset.downloads || 0);
|
||||
case 'name':
|
||||
return (a.dataset.name || '').localeCompare(b.dataset.name || '');
|
||||
case 'updated':
|
||||
return (b.dataset.updated || '').localeCompare(a.dataset.updated || '');
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
|
||||
items.forEach(item => providerGrid.appendChild(item));
|
||||
}
|
||||
|
||||
if (sortSelect) {
|
||||
sortSelect.addEventListener('change', sortProviders);
|
||||
}
|
||||
|
||||
readURLParams();
|
||||
sortProviders();
|
||||
if (currentCategory !== 'all' || currentLifecycle !== 'all' || currentSearch) {
|
||||
filterProviders();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user