From 478db6aa2e62ba19dfc03e47c2113bfcb9ed0b07 Mon Sep 17 00:00:00 2001 From: Emir Karabeg Date: Fri, 28 Feb 2025 20:29:11 -0800 Subject: [PATCH] improvement(store): cleaned up deploy store --- app/w/components/control-bar/control-bar.tsx | 1 + stores/workflow/middleware.ts | 6 +---- stores/workflow/store.ts | 26 -------------------- stores/workflow/types.ts | 2 +- 4 files changed, 3 insertions(+), 32 deletions(-) diff --git a/app/w/components/control-bar/control-bar.tsx b/app/w/components/control-bar/control-bar.tsx index 6f87c1e2d1..13b706df8f 100644 --- a/app/w/components/control-bar/control-bar.tsx +++ b/app/w/components/control-bar/control-bar.tsx @@ -77,6 +77,7 @@ export function ControlBar() { return () => clearInterval(interval) }, []) + // TODO: Put this in sync-manager // Check deployment status on mount or when activeWorkflowId changes useEffect(() => { async function checkStatus() { diff --git a/stores/workflow/middleware.ts b/stores/workflow/middleware.ts index 4669f4f1c3..4db38e09b9 100644 --- a/stores/workflow/middleware.ts +++ b/stores/workflow/middleware.ts @@ -25,8 +25,6 @@ export const withHistory = ( blocks: initialState.blocks, edges: initialState.edges, loops: initialState.loops, - isDeployed: initialState.isDeployed || false, - deployedAt: initialState.deployedAt, }, timestamp: Date.now(), action: 'Initial state', @@ -138,7 +136,7 @@ export const withHistory = ( history: { past: [], present: { - state: { blocks: {}, edges: [], loops: {}, isDeployed: false }, + state: { blocks: {}, edges: [], loops: {} }, timestamp: Date.now(), action: 'Clear workflow', subblockValues: {}, @@ -206,8 +204,6 @@ export const createHistoryEntry = (state: WorkflowState, action: string): Histor blocks: { ...state.blocks }, edges: [...state.edges], loops: { ...state.loops }, - isDeployed: state.isDeployed !== undefined ? state.isDeployed : false, - deployedAt: state.deployedAt, } // Capture the current subblock values for this workflow diff --git a/stores/workflow/store.ts b/stores/workflow/store.ts index 75f6dbea15..0ac735f83c 100644 --- a/stores/workflow/store.ts +++ b/stores/workflow/store.ts @@ -73,8 +73,6 @@ export const useWorkflowStore = create()( }, edges: [...get().edges], loops: { ...get().loops }, - isDeployed: get().isDeployed, - deployedAt: get().deployedAt, } set(newState) @@ -105,8 +103,6 @@ export const useWorkflowStore = create()( blocks: { ...get().blocks }, edges: [...get().edges].filter((edge) => edge.source !== id && edge.target !== id), loops: { ...get().loops }, - isDeployed: get().isDeployed || false, - deployedAt: get().deployedAt, } // Clean up subblock values before removing the block @@ -199,8 +195,6 @@ export const useWorkflowStore = create()( blocks: { ...get().blocks }, edges: newEdges, loops: newLoops, - isDeployed: get().isDeployed || false, - deployedAt: get().deployedAt, } set(newState) @@ -238,8 +232,6 @@ export const useWorkflowStore = create()( blocks: { ...get().blocks }, edges: newEdges, loops: newLoops, - isDeployed: get().isDeployed || false, - deployedAt: get().deployedAt, } set(newState) @@ -252,8 +244,6 @@ export const useWorkflowStore = create()( blocks: {}, edges: [], loops: {}, - isDeployed: false, - deployedAt: undefined, history: { past: [], present: { @@ -261,8 +251,6 @@ export const useWorkflowStore = create()( blocks: {}, edges: [], loops: {}, - isDeployed: false, - deployedAt: undefined, }, timestamp: Date.now(), action: 'Initial state', @@ -290,8 +278,6 @@ export const useWorkflowStore = create()( }, }, edges: [...get().edges], - isDeployed: get().isDeployed || false, - deployedAt: get().deployedAt, } set(newState) @@ -341,8 +327,6 @@ export const useWorkflowStore = create()( }, edges: [...get().edges], loops: { ...get().loops }, - isDeployed: get().isDeployed || false, - deployedAt: get().deployedAt, } // Update the subblock store with the duplicated values @@ -376,8 +360,6 @@ export const useWorkflowStore = create()( }, }, edges: [...get().edges], - isDeployed: get().isDeployed || false, - deployedAt: get().deployedAt, } set(newState) @@ -395,8 +377,6 @@ export const useWorkflowStore = create()( }, edges: [...get().edges], loops: { ...get().loops }, - isDeployed: get().isDeployed || false, - deployedAt: get().deployedAt, } set(newState) @@ -415,8 +395,6 @@ export const useWorkflowStore = create()( }, edges: [...state.edges], loops: { ...get().loops }, - isDeployed: state.isDeployed || false, - deployedAt: state.deployedAt, })) get().updateLastSaved() }, @@ -431,8 +409,6 @@ export const useWorkflowStore = create()( }, }, edges: [...state.edges], - isDeployed: state.isDeployed || false, - deployedAt: state.deployedAt, })) get().updateLastSaved() }, @@ -448,8 +424,6 @@ export const useWorkflowStore = create()( maxIterations: Math.max(1, Math.min(50, maxIterations)), // Clamp between 1-50 }, }, - isDeployed: get().isDeployed || false, - deployedAt: get().deployedAt, } set(newState) diff --git a/stores/workflow/types.ts b/stores/workflow/types.ts index 2c27862733..a76207861e 100644 --- a/stores/workflow/types.ts +++ b/stores/workflow/types.ts @@ -37,7 +37,7 @@ export interface WorkflowState { lastSaved?: number loops: Record lastUpdate?: number - isDeployed: boolean + isDeployed?: boolean deployedAt?: Date }