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,
|
updateTemplate,
|
||||||
} from "../utils/reactflowUtils";
|
} from "../utils/reactflowUtils";
|
||||||
import {
|
import {
|
||||||
IncrementObjectKey,
|
|
||||||
getRandomDescription,
|
getRandomDescription,
|
||||||
getRandomName,
|
getRandomName,
|
||||||
getSetFromObject,
|
getSetFromObject,
|
||||||
|
|
@ -154,6 +153,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (flow.data && flow.is_component) {
|
if (flow.data && flow.is_component) {
|
||||||
|
console.log(flow.data.nodes[0].data);
|
||||||
storeComponents[(flow.data.nodes[0].data as NodeDataType).type] =
|
storeComponents[(flow.data.nodes[0].data as NodeDataType).type] =
|
||||||
_.cloneDeep((flow.data.nodes[0].data as NodeDataType).node!);
|
_.cloneDeep((flow.data.nodes[0].data as NodeDataType).node!);
|
||||||
return;
|
return;
|
||||||
|
|
@ -674,12 +674,8 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
component.node!.official = false;
|
component.node!.official = false;
|
||||||
let key = component.type;
|
let key = component.type;
|
||||||
if (data["custom_components"][key] !== undefined) {
|
if (data["custom_components"][key] !== undefined) {
|
||||||
let { newKey, increment } = IncrementObjectKey(
|
let increment: number;
|
||||||
data["custom_components"],
|
component.type = removeCountFromString(key) + ` (${uid()})`;
|
||||||
key
|
|
||||||
);
|
|
||||||
key = newKey;
|
|
||||||
component.type = newKey;
|
|
||||||
let componentNodes: { [key: string]: APIClassType } = {};
|
let componentNodes: { [key: string]: APIClassType } = {};
|
||||||
Object.keys(data["custom_components"]).forEach((key) => {
|
Object.keys(data["custom_components"]).forEach((key) => {
|
||||||
componentNodes[key] = data["custom_components"][key];
|
componentNodes[key] = data["custom_components"][key];
|
||||||
|
|
|
||||||
|
|
@ -309,7 +309,12 @@ export default function ExtraSidebar(): JSX.Element {
|
||||||
>
|
>
|
||||||
<div className="side-bar-components-gap">
|
<div className="side-bar-components-gap">
|
||||||
{Object.keys(dataFilter[SBSectionName])
|
{Object.keys(dataFilter[SBSectionName])
|
||||||
.sort(sensitiveSort)
|
.sort((a, b) =>
|
||||||
|
sensitiveSort(
|
||||||
|
dataFilter[SBSectionName][a].display_name,
|
||||||
|
dataFilter[SBSectionName][b].display_name
|
||||||
|
)
|
||||||
|
)
|
||||||
.map((SBItemName: string, index) => (
|
.map((SBItemName: string, index) => (
|
||||||
<ShadTooltip
|
<ShadTooltip
|
||||||
content={
|
content={
|
||||||
|
|
|
||||||
|
|
@ -571,7 +571,7 @@ export function IncrementObjectKey(
|
||||||
|
|
||||||
export function removeCountFromString(input: string): string {
|
export function removeCountFromString(input: string): string {
|
||||||
// Define a regex pattern to match the count in parentheses
|
// 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
|
// Use the `replace` method to remove the matched pattern
|
||||||
const result = input.replace(pattern, "");
|
const result = input.replace(pattern, "");
|
||||||
|
|
@ -581,7 +581,7 @@ export function removeCountFromString(input: string): string {
|
||||||
|
|
||||||
export function sensitiveSort(a: string, b: string): number {
|
export function sensitiveSort(a: string, b: string): number {
|
||||||
// Extract the name and number from each string using regular expressions
|
// Extract the name and number from each string using regular expressions
|
||||||
const regex = /(.+) \((\d+)\)/;
|
const regex = /(.+) \((\w+)\)/;
|
||||||
const matchA = a.match(regex);
|
const matchA = a.match(regex);
|
||||||
const matchB = b.match(regex);
|
const matchB = b.match(regex);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue