@@ -57,10 +57,6 @@ export const getActionsByContext = (
5757 return availableActions . filter ( ( action ) => action . supportedContexts . includes ( context ) ) ;
5858} ;
5959
60- /**
61- * Remap configs when items are reordered (drag-drop)
62- * Moves config from old index to new index position
63- */
6460export const remapConfigsOnReorder = (
6561 configs : Record < string , unknown > ,
6662 prefix : 'filter' | 'action' ,
@@ -111,30 +107,19 @@ export const remapConfigsOnRemove = (
111107 return newConfigs ;
112108} ;
113109
114- /**
115- * Initialize filter configurations from existing workflow
116- * Uses index-based keys to support multiple filters of the same type
117- */
118- export const initializeFilterConfigs = ( workflow : WorkflowResponseDto ) : Record < string , unknown > => {
110+ export const initializeConfigs = (
111+ type : 'action' | 'filter' ,
112+ workflow : WorkflowResponseDto ,
113+ ) : Record < string , unknown > => {
119114 const configs : Record < string , unknown > = { } ;
120115
121- if ( workflow . filters ) {
116+ if ( workflow . filters && type == 'filter' ) {
122117 for ( const [ index , workflowFilter ] of workflow . filters . entries ( ) ) {
123118 configs [ `filter_${ index } ` ] = workflowFilter . filterConfig ?? { } ;
124119 }
125120 }
126121
127- return configs ;
128- } ;
129-
130- /**
131- * Initialize action configurations from existing workflow
132- * Uses index-based keys to support multiple actions of the same type
133- */
134- export const initializeActionConfigs = ( workflow : WorkflowResponseDto ) : Record < string , unknown > => {
135- const configs : Record < string , unknown > = { } ;
136-
137- if ( workflow . actions ) {
122+ if ( workflow . actions && type == 'action' ) {
138123 for ( const [ index , workflowAction ] of workflow . actions . entries ( ) ) {
139124 configs [ `action_${ index } ` ] = workflowAction . actionConfig ?? { } ;
140125 }
@@ -175,9 +160,6 @@ export const buildWorkflowPayload = (
175160 } ;
176161} ;
177162
178- /**
179- * Parse JSON workflow and update state
180- */
181163export const parseWorkflowJson = (
182164 jsonString : string ,
183165 availableTriggers : PluginTriggerResponseDto [ ] ,
@@ -200,10 +182,8 @@ export const parseWorkflowJson = (
200182 try {
201183 const parsed = JSON . parse ( jsonString ) ;
202184
203- // Find trigger
204185 const trigger = availableTriggers . find ( ( t ) => t . type === parsed . triggerType ) ;
205186
206- // Parse filters (using index-based keys to support multiple of same type)
207187 const filters : PluginFilterResponseDto [ ] = [ ] ;
208188 const filterConfigs : Record < string , unknown > = { } ;
209189 if ( Array . isArray ( parsed . filters ) ) {
@@ -217,7 +197,6 @@ export const parseWorkflowJson = (
217197 }
218198 }
219199
220- // Parse actions (using index-based keys to support multiple of same type)
221200 const actions : PluginActionResponseDto [ ] = [ ] ;
222201 const actionConfigs : Record < string , unknown > = { } ;
223202 if ( Array . isArray ( parsed . actions ) ) {
@@ -252,9 +231,6 @@ export const parseWorkflowJson = (
252231 }
253232} ;
254233
255- /**
256- * Check if workflow has changes compared to previous version
257- */
258234export const hasWorkflowChanged = (
259235 previousWorkflow : WorkflowResponseDto ,
260236 enabled : boolean ,
@@ -266,36 +242,30 @@ export const hasWorkflowChanged = (
266242 filterConfigs : Record < string , unknown > ,
267243 actionConfigs : Record < string , unknown > ,
268244) : boolean => {
269- // Check enabled state
270245 if ( enabled !== previousWorkflow . enabled ) {
271246 return true ;
272247 }
273248
274- // Check name or description
275249 if ( name !== ( previousWorkflow . name ?? '' ) || description !== ( previousWorkflow . description ?? '' ) ) {
276250 return true ;
277251 }
278252
279- // Check trigger
280253 if ( triggerType !== previousWorkflow . triggerType ) {
281254 return true ;
282255 }
283256
284- // Check filters order/items
285257 const previousFilterIds = previousWorkflow . filters ?. map ( ( f ) => f . pluginFilterId ) ?? [ ] ;
286258 const currentFilterIds = orderedFilters . map ( ( f ) => f . id ) ;
287259 if ( JSON . stringify ( previousFilterIds ) !== JSON . stringify ( currentFilterIds ) ) {
288260 return true ;
289261 }
290262
291- // Check actions order/items
292263 const previousActionIds = previousWorkflow . actions ?. map ( ( a ) => a . pluginActionId ) ?? [ ] ;
293264 const currentActionIds = orderedActions . map ( ( a ) => a . id ) ;
294265 if ( JSON . stringify ( previousActionIds ) !== JSON . stringify ( currentActionIds ) ) {
295266 return true ;
296267 }
297268
298- // Check filter configs (using index-based keys)
299269 const previousFilterConfigs : Record < string , unknown > = { } ;
300270 for ( const [ index , wf ] of ( previousWorkflow . filters ?? [ ] ) . entries ( ) ) {
301271 previousFilterConfigs [ `filter_${ index } ` ] = wf . filterConfig ?? { } ;
@@ -304,7 +274,6 @@ export const hasWorkflowChanged = (
304274 return true ;
305275 }
306276
307- // Check action configs (using index-based keys)
308277 const previousActionConfigs : Record < string , unknown > = { } ;
309278 for ( const [ index , wa ] of ( previousWorkflow . actions ?? [ ] ) . entries ( ) ) {
310279 previousActionConfigs [ `action_${ index } ` ] = wa . actionConfig ?? { } ;
@@ -316,9 +285,6 @@ export const hasWorkflowChanged = (
316285 return false ;
317286} ;
318287
319- /**
320- * Update a workflow via API
321- */
322288export const handleUpdateWorkflow = async (
323289 workflowId : string ,
324290 name : string ,
0 commit comments