Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: optimize flow saving functionality and implement manual saving #3283

Merged
merged 86 commits into from
Aug 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
42ef82d
fixed patch update flow
lucaseduoli Aug 7, 2024
4a60211
fixed update flow patch to receive id by payload
lucaseduoli Aug 7, 2024
842caba
created save flow hook with auto save and manual save functions
lucaseduoli Aug 7, 2024
b117f67
fix poetry lock
lucaseduoli Aug 7, 2024
b52fc2e
added auto save check with environment variable
lucaseduoli Aug 7, 2024
4d7a7a3
removed unused user
lucaseduoli Aug 7, 2024
05840eb
separated autosave and put the flow as a creation with nodes and edges
lucaseduoli Aug 7, 2024
f1dae3d
removed set nodes that skipped saving
lucaseduoli Aug 7, 2024
6745408
implemented auto save hook
lucaseduoli Aug 7, 2024
647ef80
removed autosave from setNodes and setEdges
lucaseduoli Aug 7, 2024
55c590c
added auto save hook and saved on viewport move and added useEffect t…
lucaseduoli Aug 7, 2024
b70cfb1
changed type of setNodes
lucaseduoli Aug 7, 2024
e9f30bf
removed unused var
lucaseduoli Aug 8, 2024
cdb61ac
removed deletion of empty flow
lucaseduoli Aug 8, 2024
7db78ac
Added saving of flow on button when autoSave is disabled
lucaseduoli Aug 8, 2024
43d75a4
disable saving when the nodes are empty
lucaseduoli Aug 8, 2024
063efd3
removed save loading as false when the access token is renewed
lucaseduoli Aug 8, 2024
1fe147e
implemented useDebounce
lucaseduoli Aug 8, 2024
dec884e
added save loading to save flow hook
lucaseduoli Aug 8, 2024
b87e0e0
removed setting nodes and edges on fetching, since they are set when …
lucaseduoli Aug 8, 2024
f3eb791
removed unused var
lucaseduoli Aug 8, 2024
65f62fb
use debounce hook to save flow
lucaseduoli Aug 8, 2024
4a61a5b
set nodes and edges on current flow id change
lucaseduoli Aug 8, 2024
210a86b
removed useplaygroundeffect
lucaseduoli Aug 8, 2024
a111b83
removed unused import
lucaseduoli Aug 8, 2024
5aaa273
put set save loading before the If
lucaseduoli Aug 8, 2024
c5c0aa1
removed flow cleaning and inputs setting, since the inputs and output…
lucaseduoli Aug 8, 2024
4164b00
updated to use ResetFlow function to update everything regarding flow
lucaseduoli Aug 8, 2024
270cb54
removed flow pool get on resetFlow, for it to be fetched only if the …
lucaseduoli Aug 8, 2024
8f0054d
updated packagelock
lucaseduoli Aug 8, 2024
5efd55a
Changed router to outlet on app.tsx to use createRouter
lucaseduoli Aug 9, 2024
332037d
Created authSettingsGuard to guard the general settings
lucaseduoli Aug 9, 2024
95d42e2
Fixed routes to use createBrowserRouter to allow the use of useBlocker
lucaseduoli Aug 9, 2024
c40dc17
Changed index.tsx to use RouterProvider and the router just created
lucaseduoli Aug 9, 2024
578e0ae
Changed flowStore to have a local flow state
lucaseduoli Aug 9, 2024
a984b6d
Implemented setting the current flow state when saving the flow
lucaseduoli Aug 9, 2024
352d8aa
Added the update of current flow when auto saving
lucaseduoli Aug 9, 2024
244370c
changed current flow to use the current flow from Flow Store instead …
lucaseduoli Aug 9, 2024
633da70
Changed codeTabsComponent Tweaks check to show if its checked
lucaseduoli Aug 9, 2024
6caa743
Removed unused variables
lucaseduoli Aug 9, 2024
02d0889
Removed browser router from context wrapper
lucaseduoli Aug 9, 2024
178bd5f
Removed unused console.log
lucaseduoli Aug 9, 2024
cadf7e6
Changed initialSetup to just run when opening the modal
lucaseduoli Aug 9, 2024
eb42521
changed confirmationModal to have destructiveCancel and to only call …
lucaseduoli Aug 9, 2024
0ab6e38
Created a SaveChangesModal that confirms if the user wants to save th…
lucaseduoli Aug 9, 2024
d14663f
Get folder by id when folder id changes too
lucaseduoli Aug 9, 2024
d85ed64
Changed reset flow calls to store whole flow
lucaseduoli Aug 9, 2024
586b73a
Added check if user is exiting page to prevent him when there are uns…
lucaseduoli Aug 9, 2024
6e887ad
Added new types on ConfirmationModalType
lucaseduoli Aug 9, 2024
734820a
Implement save on clicking the save button on the header
lucaseduoli Aug 9, 2024
3db8aa7
added save component shortcut to use save shortcut as save flow
lucaseduoli Aug 9, 2024
af81afa
added save component shortcut on shortcutsStore type
lucaseduoli Aug 9, 2024
db386ef
changed save shortcut to save component on node toolbar
lucaseduoli Aug 9, 2024
0c17b7b
added save shortcut to header menubar
lucaseduoli Aug 9, 2024
c1b4fc3
changed shortcuts name to be compatible with existing ones
lucaseduoli Aug 9, 2024
852d3c4
changed shortcuts to be backwards compatible
lucaseduoli Aug 9, 2024
4cb76c8
changed save to changes to maintain retrocompatibility
lucaseduoli Aug 9, 2024
567f524
changed save_component to save to maintain retrocompatibility
lucaseduoli Aug 9, 2024
246b9bf
Changed time difference to unsaved changes
lucaseduoli Aug 9, 2024
c91ad53
changed the toolbar select item to get the right save shortcut
lucaseduoli Aug 9, 2024
253c871
Changed save flow to use current flow from useFlowStore instead of th…
lucaseduoli Aug 9, 2024
2e62439
changed changesNotSaved to include flow name and metadata
lucaseduoli Aug 9, 2024
6d10d9f
Added way of saving the flow settings just locally instead of directl…
lucaseduoli Aug 9, 2024
17fd1bf
Changed shareModal to save flow with hook
lucaseduoli Aug 9, 2024
eeaf21a
removed old auto saving on connect
lucaseduoli Aug 9, 2024
72a40a1
Removed save functions from flowsManagerStore
lucaseduoli Aug 9, 2024
f04822b
refactor: Remove unused imports and state variables in EditFlowSettin…
lucaseduoli Aug 9, 2024
763e8c1
use current flow not saved one and refactored page to not receive flow
lucaseduoli Aug 9, 2024
3a7e8c5
added check of isFlowPage to display the menubar
lucaseduoli Aug 9, 2024
11a506e
Added checks to render playground if API key is valid and if Flows ex…
lucaseduoli Aug 9, 2024
7343b33
Added check to not display X on chat on playground page
lucaseduoli Aug 9, 2024
423f887
Merge remote-tracking branch 'origin/main' into refactor/save_flow
lucaseduoli Aug 9, 2024
a335e77
Updated flows variable to be undefined by start to prevent things fro…
lucaseduoli Aug 9, 2024
ccc0de5
Merge remote-tracking branch 'origin/main' into refactor/save_flow
lucaseduoli Aug 12, 2024
f101bd1
Implemented log builds parameter to not allow the builds to be logged…
lucaseduoli Aug 12, 2024
2fa6f71
fix flows manager store removing the setCurrentFlowId
lucaseduoli Aug 12, 2024
eb97599
Add viewport setting on setReactFlowInstance
lucaseduoli Aug 12, 2024
a852b6c
Remove unused imports
lucaseduoli Aug 12, 2024
bac3e1b
Removed setting of currentFlowId on every page and made the setting o…
lucaseduoli Aug 12, 2024
f918079
removed fit view on page
lucaseduoli Aug 12, 2024
cf76365
added auto save flow function setting on the store to allow the flow …
lucaseduoli Aug 12, 2024
4d9fa7e
Changed header to just show the save button if autosave is disabled
lucaseduoli Aug 12, 2024
fd70178
Added check to only save empty flow when it was already empty before
lucaseduoli Aug 12, 2024
a667f8b
Changed tests and added message to not fail tests about flow settings
lucaseduoli Aug 12, 2024
b0c226d
Changed on file drop to use saveFlow
lucaseduoli Aug 12, 2024
6dd99e6
Updated tests
lucaseduoli Aug 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
updated to use ResetFlow function to update everything regarding flow
  • Loading branch information
lucaseduoli committed Aug 8, 2024
commit 4164b00449ba163a6cebe150f7992794854b99d2
19 changes: 11 additions & 8 deletions src/frontend/src/stores/flowsManagerStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
UseUndoRedoOptions,
} from "../types/zustand/flowsManager";
import {
cleanEdges,
extractFieldsFromComponenents,
processFlows,
} from "../utils/reactflowUtils";
Expand All @@ -37,29 +36,33 @@ const useFlowsManagerStore = create<FlowsManagerStoreType>((set, get) => ({
set({ examples });
},
currentFlowId: "",
setCurrentFlow: (flow: FlowType) => {
setCurrentFlow: (flow: FlowType | undefined) => {
set({
currentFlow: flow,
currentFlowId: flow.id,
currentFlowId: flow?.id ?? "",
});
useFlowStore.setState({
nodes: flow?.data?.nodes ?? [],
useFlowStore.getState().resetFlow({
edges: flow?.data?.edges ?? [],
nodes: flow?.data?.nodes ?? [],
viewport: flow?.data?.viewport ?? { zoom: 1, x: 0, y: 0 },
});
},
getFlowById: (id: string) => {
return get().flows.find((flow) => flow.id === id);
},
setCurrentFlowId: (currentFlowId: string) => {
const flow = get().flows?.find((flow) => flow.id === currentFlowId);
let newEdges = cleanEdges(flow?.data!.nodes ?? [], flow?.data!.edges ?? []);
console.log(flow, "kakakkaka");
set({
currentFlowId,
currentFlow:
get().flows?.find((flow) => flow.id === currentFlowId) ?? undefined,
});

useFlowStore.setState({ edges: newEdges, nodes: flow?.data?.nodes ?? [] });
useFlowStore.getState().resetFlow({
edges: flow?.data?.edges ?? [],
nodes: flow?.data?.nodes ?? [],
viewport: flow?.data?.viewport ?? { zoom: 1, x: 0, y: 0 },
});
},
flows: [],
allFlows: [],
Expand Down