fix(tabsContext.tsx): change return type of saveComponent function to Promise<String | undefined> for better error handling and consistency
fix(nodeToolbarComponent/index.tsx): fix saveComponent function call to return a Promise and handle success and error cases properly fix(types/tabs/index.ts): change return type of saveComponent function to void for consistency with implementation feat(reactflowUtils.ts): add updateComponentNameAndType function to update component name and type
This commit is contained in:
parent
b006f11a3d
commit
a718ac2f4b
4 changed files with 23 additions and 18 deletions
|
|
@ -80,7 +80,7 @@ const TabsContextInitialValue: TabsContextType = {
|
||||||
selection: { nodes: any; edges: any },
|
selection: { nodes: any; edges: any },
|
||||||
position: { x: number; y: number; paneX?: number; paneY?: number }
|
position: { x: number; y: number; paneX?: number; paneY?: number }
|
||||||
) => {},
|
) => {},
|
||||||
saveComponent: (component: NodeDataType) => {},
|
saveComponent: async (component: NodeDataType) => "",
|
||||||
deleteComponent: (id: string, key: string) => {},
|
deleteComponent: (id: string, key: string) => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -700,7 +700,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
||||||
` (${increment})`;
|
` (${increment})`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addFlow(true, createFlowComponent(component));
|
return addFlow(true, createFlowComponent(component));
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteComponent(id: string, key: string) {
|
function deleteComponent(id: string, key: string) {
|
||||||
|
|
|
||||||
|
|
@ -70,9 +70,9 @@ export default function NodeToolbarComponent({
|
||||||
|
|
||||||
function handleShareComponent() {
|
function handleShareComponent() {
|
||||||
const componentFlow = cloneDeep(data);
|
const componentFlow = cloneDeep(data);
|
||||||
|
saveComponent(componentFlow).then(() => {
|
||||||
saveFlowStore(createFlowComponent(componentFlow)).then(
|
saveFlowStore(createFlowComponent(componentFlow)).then(
|
||||||
() => {
|
(_) => {
|
||||||
saveComponent(componentFlow);
|
|
||||||
setSuccessData({
|
setSuccessData({
|
||||||
title: "Component shared successfully",
|
title: "Component shared successfully",
|
||||||
});
|
});
|
||||||
|
|
@ -84,6 +84,7 @@ export default function NodeToolbarComponent({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
const handleSelectChange = (event) => {
|
const handleSelectChange = (event) => {
|
||||||
switch (event) {
|
switch (event) {
|
||||||
|
|
@ -98,7 +99,6 @@ export default function NodeToolbarComponent({
|
||||||
downloadNode(createFlowComponent(cloneDeep(data)));
|
downloadNode(createFlowComponent(cloneDeep(data)));
|
||||||
break;
|
break;
|
||||||
case "Share":
|
case "Share":
|
||||||
console.log("Share");
|
|
||||||
setShowconfirmShare(true);
|
setShowconfirmShare(true);
|
||||||
break;
|
break;
|
||||||
case "SaveAll":
|
case "SaveAll":
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ export type TabsContextType = {
|
||||||
setLastCopiedSelection: (selection: { nodes: any; edges: any }) => void;
|
setLastCopiedSelection: (selection: { nodes: any; edges: any }) => void;
|
||||||
setTweak: (tweak: tweakType) => tweakType | void;
|
setTweak: (tweak: tweakType) => tweakType | void;
|
||||||
getTweak: tweakType;
|
getTweak: tweakType;
|
||||||
saveComponent: (component: NodeDataType) => void;
|
saveComponent: (component: NodeDataType) => Promise<String | undefined>;
|
||||||
deleteComponent: (id: string, key: string) => void;
|
deleteComponent: (id: string, key: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1097,3 +1097,8 @@ export function downloadNode(NodeFLow: FlowType) {
|
||||||
element.download = `${NodeFLow.name}.json`;
|
element.download = `${NodeFLow.name}.json`;
|
||||||
element.click();
|
element.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function updateComponentNameAndType(
|
||||||
|
data: any,
|
||||||
|
component: NodeDataType
|
||||||
|
) {}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue