From 02e1f8a82e1fe0f99f38624da31b89f6946100fb Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Wed, 25 Oct 2023 19:08:35 -0300 Subject: [PATCH] fix(tabsContext.tsx): fix component key generation to include unique identifier to avoid conflicts fix(extraSidebarComponent/index.tsx): fix sorting of sidebar items to be case-sensitive fix(utils.ts): update regex pattern to remove count from string and sort function to handle alphanumeric identifiers --- src/frontend/src/contexts/tabsContext.tsx | 10 +++------- .../components/extraSidebarComponent/index.tsx | 7 ++++++- src/frontend/src/utils/utils.ts | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/frontend/src/contexts/tabsContext.tsx b/src/frontend/src/contexts/tabsContext.tsx index 98be2f1af..814340659 100644 --- a/src/frontend/src/contexts/tabsContext.tsx +++ b/src/frontend/src/contexts/tabsContext.tsx @@ -40,7 +40,6 @@ import { updateTemplate, } from "../utils/reactflowUtils"; import { - IncrementObjectKey, getRandomDescription, getRandomName, getSetFromObject, @@ -154,6 +153,7 @@ export function TabsProvider({ children }: { children: ReactNode }) { return; } if (flow.data && flow.is_component) { + console.log(flow.data.nodes[0].data); storeComponents[(flow.data.nodes[0].data as NodeDataType).type] = _.cloneDeep((flow.data.nodes[0].data as NodeDataType).node!); return; @@ -674,12 +674,8 @@ export function TabsProvider({ children }: { children: ReactNode }) { component.node!.official = false; let key = component.type; if (data["custom_components"][key] !== undefined) { - let { newKey, increment } = IncrementObjectKey( - data["custom_components"], - key - ); - key = newKey; - component.type = newKey; + let increment: number; + component.type = removeCountFromString(key) + ` (${uid()})`; let componentNodes: { [key: string]: APIClassType } = {}; Object.keys(data["custom_components"]).forEach((key) => { componentNodes[key] = data["custom_components"][key]; diff --git a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx index 70eb26f1d..c819d8f2b 100644 --- a/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx +++ b/src/frontend/src/pages/FlowPage/components/extraSidebarComponent/index.tsx @@ -309,7 +309,12 @@ export default function ExtraSidebar(): JSX.Element { >
{Object.keys(dataFilter[SBSectionName]) - .sort(sensitiveSort) + .sort((a, b) => + sensitiveSort( + dataFilter[SBSectionName][a].display_name, + dataFilter[SBSectionName][b].display_name + ) + ) .map((SBItemName: string, index) => (