fix: adds priority sorting for sidebar components and makes LanguageModel appear first (#7322)
* Added priority field to components * Added priority as 0 to LanguageModelComponent * Adds sorting based on priority * refactor: remove redundant name attribute from LanguageModelComponent * Updated custom component to include priority --------- Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
This commit is contained in:
parent
58b12b40e1
commit
7ba4bff956
5 changed files with 24 additions and 1 deletions
|
|
@ -18,6 +18,17 @@ const SidebarItemsList = ({
|
|||
.sort((a, b) => {
|
||||
const itemA = dataFilter[item.name][a];
|
||||
const itemB = dataFilter[item.name][b];
|
||||
|
||||
// Sort by priority if available
|
||||
if (itemA.priority !== undefined || itemB.priority !== undefined) {
|
||||
const priorityA = itemA.priority ?? Number.MAX_SAFE_INTEGER;
|
||||
const priorityB = itemB.priority ?? Number.MAX_SAFE_INTEGER;
|
||||
if (priorityA !== priorityB) {
|
||||
return priorityA - priorityB;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise use the existing sorting logic
|
||||
return itemA.score && itemB.score
|
||||
? itemA.score - itemB.score
|
||||
: sensitiveSort(itemA.display_name, itemB.display_name);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue