Skip to content

Commit 2ebcda9

Browse files
waleedlatif1claude
andcommitted
refactor(stores): consolidate variables stores into stores/variables/
Move variable data store from stores/panel/variables/ to stores/variables/ since the panel variables tab no longer exists. Rename the modal UI store to useVariablesModalStore to eliminate naming collision with the data store. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 34d210c commit 2ebcda9

File tree

22 files changed

+471
-475
lines changed

22 files changed

+471
-475
lines changed

apps/sim/app/api/workflows/[id]/variables/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { AuditAction, AuditResourceType, recordAudit } from '@/lib/audit/log'
88
import { checkSessionOrInternalAuth } from '@/lib/auth/hybrid'
99
import { generateRequestId } from '@/lib/core/utils/request'
1010
import { authorizeWorkflowByWorkspacePermission } from '@/lib/workflows/utils'
11-
import type { Variable } from '@/stores/panel/variables/types'
11+
import type { Variable } from '@/stores/variables/types'
1212

1313
const logger = createLogger('WorkflowVariablesAPI')
1414

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/deploy/hooks/use-change-detection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useMemo } from 'react'
22
import { hasWorkflowChanged } from '@/lib/workflows/comparison'
33
import { mergeSubblockStateWithValues } from '@/lib/workflows/subblocks'
4-
import { useVariablesStore } from '@/stores/panel/variables/store'
4+
import { useVariablesStore } from '@/stores/variables/store'
55
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
66
import { useWorkflowStore } from '@/stores/workflows/workflow/store'
77
import type { WorkflowState } from '@/stores/workflows/workflow/types'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ import { useAccessibleReferencePrefixes } from '@/app/workspace/[workspaceId]/w/
3131
import { getBlock } from '@/blocks'
3232
import type { BlockConfig } from '@/blocks/types'
3333
import { normalizeName } from '@/executor/constants'
34-
import type { Variable } from '@/stores/panel'
35-
import { useVariablesStore } from '@/stores/panel'
34+
import { useVariablesStore } from '@/stores/variables/store'
35+
import type { Variable } from '@/stores/variables/types'
3636
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
3737
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
3838
import { useWorkflowStore } from '@/stores/workflows/workflow/store'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/variables-input/variables-input.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import {
1919
} from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tag-dropdown/tag-dropdown'
2020
import { useSubBlockValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/hooks/use-sub-block-value'
2121
import { useAccessibleReferencePrefixes } from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-accessible-reference-prefixes'
22-
import type { Variable } from '@/stores/panel'
23-
import { useVariablesStore } from '@/stores/panel'
22+
import { useVariablesStore } from '@/stores/variables/store'
23+
import type { Variable } from '@/stores/variables/types'
2424

2525
interface VariableAssignment {
2626
id: string

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/panel.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ import { useSettingsNavigation } from '@/hooks/use-settings-navigation'
6363
import { useChatStore } from '@/stores/chat/store'
6464
import { useNotificationStore } from '@/stores/notifications/store'
6565
import type { ChatContext, PanelTab } from '@/stores/panel'
66-
import { usePanelStore, useVariablesStore as usePanelVariablesStore } from '@/stores/panel'
66+
import { usePanelStore } from '@/stores/panel'
67+
import { useVariablesModalStore } from '@/stores/variables/modal'
6768
import { useVariablesStore } from '@/stores/variables/store'
6869
import { useWorkflowDiffStore } from '@/stores/workflow-diff/store'
6970
import { captureBaselineSnapshot } from '@/stores/workflow-diff/utils'
@@ -205,7 +206,7 @@ export const Panel = memo(function Panel({ workspaceId: propWorkspaceId }: Panel
205206
setIsChatOpen: state.setIsChatOpen,
206207
}))
207208
)
208-
const { isOpen: isVariablesOpen, setIsOpen: setVariablesOpen } = useVariablesStore(
209+
const { isOpen: isVariablesOpen, setIsOpen: setVariablesOpen } = useVariablesModalStore(
209210
useShallow((state) => ({
210211
isOpen: state.isOpen,
211212
setIsOpen: state.setIsOpen,
@@ -482,7 +483,7 @@ export const Panel = memo(function Panel({ workspaceId: propWorkspaceId }: Panel
482483
throw new Error('No workflow state found')
483484
}
484485

485-
const workflowVariables = usePanelVariablesStore
486+
const workflowVariables = useVariablesStore
486487
.getState()
487488
.getVariablesByWorkflowId(activeWorkflowId)
488489

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/variables/variables.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ import {
2727
usePreventZoom,
2828
} from '@/app/workspace/[workspaceId]/w/[workflowId]/hooks'
2929
import { useCollaborativeWorkflow } from '@/hooks/use-collaborative-workflow'
30-
import { useVariablesStore as usePanelVariablesStore } from '@/stores/panel'
31-
import type { Variable } from '@/stores/panel/variables/types'
3230
import {
3331
getVariablesPosition,
3432
MAX_VARIABLES_HEIGHT,
3533
MAX_VARIABLES_WIDTH,
3634
MIN_VARIABLES_HEIGHT,
3735
MIN_VARIABLES_WIDTH,
38-
useVariablesStore,
39-
} from '@/stores/variables/store'
36+
useVariablesModalStore,
37+
} from '@/stores/variables/modal'
38+
import { useVariablesStore } from '@/stores/variables/store'
39+
import type { Variable } from '@/stores/variables/types'
4040
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
4141

4242
/**
@@ -96,7 +96,7 @@ export function Variables() {
9696
const activeWorkflowId = useWorkflowRegistry((s) => s.activeWorkflowId)
9797

9898
const { isOpen, position, width, height, setIsOpen, setPosition, setDimensions } =
99-
useVariablesStore(
99+
useVariablesModalStore(
100100
useShallow((s) => ({
101101
isOpen: s.isOpen,
102102
position: s.position,
@@ -108,7 +108,7 @@ export function Variables() {
108108
}))
109109
)
110110

111-
const variables = usePanelVariablesStore((s) => s.variables)
111+
const variables = useVariablesStore((s) => s.variables)
112112

113113
const { collaborativeUpdateVariable, collaborativeAddVariable, collaborativeDeleteVariable } =
114114
useCollaborativeWorkflow()

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ import { useSkills } from '@/hooks/queries/skills'
4848
import { useTablesList } from '@/hooks/queries/tables'
4949
import { useWorkflowMap } from '@/hooks/queries/workflows'
5050
import { useSelectorDisplayName } from '@/hooks/use-selector-display-name'
51-
import { useVariablesStore } from '@/stores/panel'
51+
import { useVariablesStore } from '@/stores/variables/store'
5252
import { useSubBlockStore } from '@/stores/workflows/subblock/store'
5353
import { useWorkflowStore } from '@/stores/workflows/workflow/store'
5454
import { wouldCreateCycle } from '@/stores/workflows/workflow/utils'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ import { useExecutionStream } from '@/hooks/use-execution-stream'
3636
import { WorkflowValidationError } from '@/serializer'
3737
import { useCurrentWorkflowExecution, useExecutionStore } from '@/stores/execution'
3838
import { useNotificationStore } from '@/stores/notifications'
39-
import { useVariablesStore } from '@/stores/panel'
4039
import {
4140
clearExecutionPointer,
4241
consolePersistence,
4342
loadExecutionPointer,
4443
saveExecutionPointer,
4544
useTerminalConsoleStore,
4645
} from '@/stores/terminal'
46+
import { useVariablesStore } from '@/stores/variables/store'
4747
import { useWorkflowDiffStore } from '@/stores/workflow-diff'
4848
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
4949
import { mergeSubblockState } from '@/stores/workflows/utils'

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/workflow.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ import { useSearchModalStore } from '@/stores/modals/search/store'
8585
import { useNotificationStore } from '@/stores/notifications'
8686
import { usePanelEditorStore } from '@/stores/panel'
8787
import { useUndoRedoStore } from '@/stores/undo-redo'
88-
import { useVariablesStore } from '@/stores/variables/store'
88+
import { useVariablesModalStore } from '@/stores/variables/modal'
8989
import { useWorkflowDiffStore } from '@/stores/workflow-diff/store'
9090
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
9191
import { getUniqueBlockName, prepareBlockState } from '@/stores/workflows/utils'
@@ -337,7 +337,7 @@ const WorkflowContent = React.memo(
337337
autoConnectRef.current = isAutoConnectEnabled
338338

339339
// Panel open states for context menu
340-
const isVariablesOpen = useVariablesStore((state) => state.isOpen)
340+
const isVariablesOpen = useVariablesModalStore((state) => state.isOpen)
341341
const isChatOpen = useChatStore((state) => state.isChatOpen)
342342

343343
const snapGrid: [number, number] = useMemo(
@@ -1374,7 +1374,7 @@ const WorkflowContent = React.memo(
13741374
}, [router, workspaceId, workflowIdParam])
13751375

13761376
const handleContextToggleVariables = useCallback(() => {
1377-
const { isOpen, setIsOpen } = useVariablesStore.getState()
1377+
const { isOpen, setIsOpen } = useVariablesModalStore.getState()
13781378
setIsOpen(!isOpen)
13791379
}, [])
13801380

apps/sim/app/workspace/[workspaceId]/w/components/preview/components/preview-workflow/components/block/block.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { DELETED_WORKFLOW_LABEL } from '@/app/workspace/[workspaceId]/logs/utils
1313
import { getDisplayValue } from '@/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block'
1414
import { getBlock } from '@/blocks'
1515
import { SELECTOR_TYPES_HYDRATION_REQUIRED, type SubBlockConfig } from '@/blocks/types'
16-
import { useVariablesStore } from '@/stores/panel/variables/store'
16+
import { useVariablesStore } from '@/stores/variables/store'
1717
import type { WorkflowMetadata } from '@/stores/workflows/registry/types'
1818

1919
/** Execution status for blocks in preview mode */

0 commit comments

Comments
 (0)