Add priority sidebar order constant and use it for sorting keys in extraSidebarComponent

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-03-05 21:47:09 -03:00
commit 94122cbe44
2 changed files with 16 additions and 11 deletions

View file

@ -727,3 +727,14 @@ export const STATUS_BUILD = "Build to validate status.";
export const STATUS_BUILDING = "Building...";
export const SAVED_HOVER = "Last saved at ";
export const RUN_TIMESTAMP_PREFIX = "Last Run: ";
export const PRIORITY_SIDEBAR_ORDER = [
"saved_components",
"inputs",
"outputs",
"prompts",
"data",
"prompt",
"models",
"helpers",
];

View file

@ -1,16 +1,10 @@
import { PRIORITY_SIDEBAR_ORDER } from "../../../../constants/constants";
export function sortKeys(a: string, b: string) {
// Define the order of specific keys
const order = [
"saved_components",
"inputs",
"outputs",
"prompts",
"data",
"models",
"utilities",
];
const indexA = order.indexOf(a.toLowerCase());
const indexB = order.indexOf(b.toLowerCase());
const indexA = PRIORITY_SIDEBAR_ORDER.indexOf(a.toLowerCase());
const indexB = PRIORITY_SIDEBAR_ORDER.indexOf(b.toLowerCase());
// Check if both keys are in the predefined order
if (indexA !== -1 && indexB !== -1) {