fix(ui): fix circular dependency

This commit is contained in:
psychedelicious 2023-12-03 20:27:40 +11:00
parent 37c87affd0
commit 7d4a78e470
6 changed files with 15 additions and 10 deletions

View File

@ -1,7 +1,7 @@
import { logger } from 'app/logging/logger';
import { parseify } from 'common/util/serialize';
import { workflowLoadRequested } from 'features/nodes/store/actions';
import { workflowLoaded } from 'features/nodes/store/workflowSlice';
import { workflowLoaded } from 'features/nodes/store/actions';
import { $flow } from 'features/nodes/store/reactFlowInstance';
import {
WorkflowMigrationError,

View File

@ -1,4 +1,5 @@
import { createAction, isAnyOf } from '@reduxjs/toolkit';
import { WorkflowV2 } from 'features/nodes/types/workflow';
import { Graph } from 'services/api/types';
export const textToImageGraphBuilt = createAction<Graph>(
@ -25,3 +26,7 @@ export const workflowLoadRequested = createAction<{
export const updateAllNodesRequested = createAction(
'nodes/updateAllNodesRequested'
);
export const workflowLoaded = createAction<WorkflowV2>(
'workflow/workflowLoaded'
);

View File

@ -1,5 +1,5 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { workflowLoaded } from 'features/nodes/store/workflowSlice';
import { workflowLoaded } from 'features/nodes/store/actions';
import { SHARED_NODE_PROPERTIES } from 'features/nodes/types/constants';
import {
BoardFieldValue,

View File

@ -1,8 +1,8 @@
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
import { workflowLoaded } from 'features/nodes/store/actions';
import { nodeEditorReset, nodesDeleted } from 'features/nodes/store/nodesSlice';
import { WorkflowsState as WorkflowState } from 'features/nodes/store/types';
import { FieldIdentifier } from 'features/nodes/types/field';
import { WorkflowV2 } from 'features/nodes/types/workflow';
import { cloneDeep, isEqual, uniqBy } from 'lodash-es';
export const initialWorkflowState: WorkflowState = {
@ -62,13 +62,14 @@ const workflowSlice = createSlice({
workflowIDChanged: (state, action: PayloadAction<string>) => {
state.id = action.payload;
},
workflowLoaded: (state, action: PayloadAction<WorkflowV2>) => {
const { nodes: _nodes, edges: _edges, ...workflow } = action.payload;
return cloneDeep(workflow);
},
workflowReset: () => cloneDeep(initialWorkflowState),
},
extraReducers: (builder) => {
builder.addCase(workflowLoaded, (state, action) => {
const { nodes: _nodes, edges: _edges, ...workflow } = action.payload;
return cloneDeep(workflow);
});
builder.addCase(nodesDeleted, (state, action) => {
action.payload.forEach((node) => {
state.exposedFields = state.exposedFields.filter(
@ -92,7 +93,6 @@ export const {
workflowVersionChanged,
workflowContactChanged,
workflowIDChanged,
workflowLoaded,
workflowReset,
} = workflowSlice.actions;

View File

@ -1,7 +1,7 @@
import { useAppToaster } from 'app/components/Toaster';
import { useAppDispatch } from 'app/store/storeHooks';
import { useWorkflow } from 'features/nodes/hooks/useWorkflow';
import { workflowLoaded } from 'features/nodes/store/workflowSlice';
import { workflowLoaded } from 'features/nodes/store/actions';
import { zWorkflowV2 } from 'features/nodes/types/workflow';
import { getWorkflowCopyName } from 'features/workflowLibrary/util/getWorkflowCopyName';
import { useCallback } from 'react';

View File

@ -1,7 +1,7 @@
import { useAppToaster } from 'app/components/Toaster';
import { useAppDispatch } from 'app/store/storeHooks';
import { useWorkflow } from 'features/nodes/hooks/useWorkflow';
import { workflowLoaded } from 'features/nodes/store/workflowSlice';
import { workflowLoaded } from 'features/nodes/store/actions';
import { zWorkflowV2 } from 'features/nodes/types/workflow';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';