diff --git a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx
index 4441ae49f..9996ad9a4 100644
--- a/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx
+++ b/src/frontend/src/pages/FlowPage/components/PageComponent/index.tsx
@@ -89,7 +89,6 @@ export default function Page({ view }: { view?: boolean }): JSX.Element {
const setPositionDictionary = useFlowStore(
(state) => state.setPositionDictionary,
);
-
const reactFlowInstance = useFlowStore((state) => state.reactFlowInstance);
const setReactFlowInstance = useFlowStore(
(state) => state.setReactFlowInstance,
@@ -612,7 +611,9 @@ export default function Page({ view }: { view?: boolean }): JSX.Element {
Components
- {componentsToUpdate.length > 0 && }
+
+
+
state.setDismissAll);
const templates = useTypesStore((state) => state.templates);
const setErrorData = useAlertStore((state) => state.setErrorData);
- const [loadingUpdate, setLoadingUpdate] = useState(false);
-
const { mutateAsync: validateComponentCode } = usePostValidateComponentCode();
const takeSnapshot = useFlowsManagerStore((state) => state.takeSnapshot);
+ const updateNodeInternals = useUpdateNodeInternals();
const updateAllNodes = useUpdateAllNodes(setNodes, updateNodeInternals);
+ const [loadingUpdate, setLoadingUpdate] = useState(false);
const [dismissed, setDismissed] = useState(false);
- const setDismissAll = useUtilityStore((state) => state.setDismissAll);
+ const numberOfEdgesBeforeUpdate = useRef(0);
+
+ useMemo(() => {
+ if (
+ numberOfEdgesBeforeUpdate.current > 0 &&
+ edges.length !== numberOfEdgesBeforeUpdate.current
+ ) {
+ useAlertStore.getState().setNoticeData({
+ title: ERROR_MESSAGE_EDGES_LOST,
+ });
+ }
+ }, [edges]);
+
+ const getSuccessTitle = (updatedCount: number) => {
+ return `Successfully updated ${updatedCount} component${
+ updatedCount > 1 ? "s" : ""
+ }`;
+ };
const handleUpdateAllComponents = () => {
+ numberOfEdgesBeforeUpdate.current = edges.length;
setLoadingUpdate(true);
takeSnapshot();
@@ -77,23 +103,17 @@ export default function UpdateAllComponents() {
Promise.all(updatePromises)
.then(() => {
if (updatedCount > 0) {
- // Batch update all nodes at once
updateAllNodes(updates);
useAlertStore.getState().setSuccessData({
- title: `Successfully updated ${updatedCount} component${
- updatedCount > 1 ? "s" : ""
- }`,
+ title: getSuccessTitle(updatedCount),
});
}
})
.catch((error) => {
setErrorData({
- title: "Error updating components",
- list: [
- "There was an error updating the components.",
- "If the error persists, please report it on our Discord or GitHub.",
- ],
+ title: ERROR_MESSAGE_UPDATING_COMPONENTS,
+ list: ERROR_MESSAGE_UPDATING_COMPONENTS_LIST,
});
console.error(error);
})