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 },
|
||||
position: { x: number; y: number; paneX?: number; paneY?: number }
|
||||
) => {},
|
||||
saveComponent: (component: NodeDataType) => {},
|
||||
saveComponent: async (component: NodeDataType) => "",
|
||||
deleteComponent: (id: string, key: string) => {},
|
||||
};
|
||||
|
||||
|
|
@ -700,7 +700,7 @@ export function TabsProvider({ children }: { children: ReactNode }) {
|
|||
` (${increment})`;
|
||||
}
|
||||
}
|
||||
addFlow(true, createFlowComponent(component));
|
||||
return addFlow(true, createFlowComponent(component));
|
||||
}
|
||||
|
||||
function deleteComponent(id: string, key: string) {
|
||||
|
|
|
|||
|
|
@ -70,20 +70,21 @@ export default function NodeToolbarComponent({
|
|||
|
||||
function handleShareComponent() {
|
||||
const componentFlow = cloneDeep(data);
|
||||
saveFlowStore(createFlowComponent(componentFlow)).then(
|
||||
() => {
|
||||
saveComponent(componentFlow);
|
||||
setSuccessData({
|
||||
title: "Component shared successfully",
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
setErrorData({
|
||||
title: "Error sharing component",
|
||||
list: [err["response"]["data"]["detail"]],
|
||||
});
|
||||
}
|
||||
);
|
||||
saveComponent(componentFlow).then(() => {
|
||||
saveFlowStore(createFlowComponent(componentFlow)).then(
|
||||
(_) => {
|
||||
setSuccessData({
|
||||
title: "Component shared successfully",
|
||||
});
|
||||
},
|
||||
(err) => {
|
||||
setErrorData({
|
||||
title: "Error sharing component",
|
||||
list: [err["response"]["data"]["detail"]],
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
const handleSelectChange = (event) => {
|
||||
switch (event) {
|
||||
|
|
@ -98,7 +99,6 @@ export default function NodeToolbarComponent({
|
|||
downloadNode(createFlowComponent(cloneDeep(data)));
|
||||
break;
|
||||
case "Share":
|
||||
console.log("Share");
|
||||
setShowconfirmShare(true);
|
||||
break;
|
||||
case "SaveAll":
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ export type TabsContextType = {
|
|||
setLastCopiedSelection: (selection: { nodes: any; edges: any }) => void;
|
||||
setTweak: (tweak: tweakType) => tweakType | void;
|
||||
getTweak: tweakType;
|
||||
saveComponent: (component: NodeDataType) => void;
|
||||
saveComponent: (component: NodeDataType) => Promise<String | undefined>;
|
||||
deleteComponent: (id: string, key: string) => void;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1097,3 +1097,8 @@ export function downloadNode(NodeFLow: FlowType) {
|
|||
element.download = `${NodeFLow.name}.json`;
|
||||
element.click();
|
||||
}
|
||||
|
||||
export function updateComponentNameAndType(
|
||||
data: any,
|
||||
component: NodeDataType
|
||||
) {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue