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
This commit is contained in:
parent
a718ac2f4b
commit
02e1f8a82e
3 changed files with 11 additions and 10 deletions
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -309,7 +309,12 @@ export default function ExtraSidebar(): JSX.Element {
|
|||
>
|
||||
<div className="side-bar-components-gap">
|
||||
{Object.keys(dataFilter[SBSectionName])
|
||||
.sort(sensitiveSort)
|
||||
.sort((a, b) =>
|
||||
sensitiveSort(
|
||||
dataFilter[SBSectionName][a].display_name,
|
||||
dataFilter[SBSectionName][b].display_name
|
||||
)
|
||||
)
|
||||
.map((SBItemName: string, index) => (
|
||||
<ShadTooltip
|
||||
content={
|
||||
|
|
|
|||
|
|
@ -571,7 +571,7 @@ export function IncrementObjectKey(
|
|||
|
||||
export function removeCountFromString(input: string): string {
|
||||
// Define a regex pattern to match the count in parentheses
|
||||
const pattern = /\s*\(\d+\)\s*$/;
|
||||
const pattern = /\s*\(\w+\)\s*$/;
|
||||
|
||||
// Use the `replace` method to remove the matched pattern
|
||||
const result = input.replace(pattern, "");
|
||||
|
|
@ -581,7 +581,7 @@ export function removeCountFromString(input: string): string {
|
|||
|
||||
export function sensitiveSort(a: string, b: string): number {
|
||||
// Extract the name and number from each string using regular expressions
|
||||
const regex = /(.+) \((\d+)\)/;
|
||||
const regex = /(.+) \((\w+)\)/;
|
||||
const matchA = a.match(regex);
|
||||
const matchB = b.match(regex);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue