@@ -6,9 +6,10 @@ const GET_NODES = 'automation/get-nodes'
66const EDIT_NODE = 'automation/open-node-edit'
77const SEARCH = 'automation/search'
88const ADD_FLOW_TAB = 'automation/add-flow-tab'
9+ const ADD_TAB = 'automation/add-tab'
910
1011/**
11- * @typedef {SELECT_NODES|GET_NODES|EDIT_NODE|SEARCH|ADD_FLOW_TAB } ExpertAutomationsActionsEnum
12+ * @typedef {SELECT_NODES|GET_NODES|EDIT_NODE|SEARCH|ADD_FLOW_TAB|ADD_TAB } ExpertAutomationsActionsEnum
1213 */
1314
1415export class ExpertAutomations extends ExpertActionsInterface {
@@ -98,6 +99,20 @@ export class ExpertAutomations extends ExpertActionsInterface {
9899 }
99100 }
100101 }
102+ ,
103+ [ ADD_TAB ] : {
104+ params : {
105+ type : 'object' ,
106+ properties : {
107+ id : { type : 'string' , description : 'Tab ID — auto-generated if omitted' } ,
108+ label : { type : 'string' , description : 'Tab label' } ,
109+ disabled : { type : 'boolean' , description : 'Create as disabled' } ,
110+ info : { type : 'string' , description : 'Tab notes' } ,
111+ env : { type : 'array' , description : 'Environment variables' }
112+ } ,
113+ required : [ 'label' ]
114+ }
115+ }
101116 } )
102117
103118 /**
@@ -229,6 +244,24 @@ export class ExpertAutomations extends ExpertActionsInterface {
229244 return newTab
230245 }
231246
247+ /**
248+ * Add a new flow tab with an explicit ID and configuration.
249+ * @param {Object } tab - tab definition with id, label, disabled, info, env
250+ */
251+ addTab ( tab ) {
252+ const ws = {
253+ type : 'tab' ,
254+ id : tab . id || this . RED . nodes . id ( ) ,
255+ label : tab . label ,
256+ disabled : tab . disabled || false ,
257+ info : tab . info || '' ,
258+ env : tab . env || [ ]
259+ }
260+ this . RED . nodes . addWorkspace ( ws )
261+ this . RED . workspaces . add ( ws )
262+ this . RED . workspaces . show ( ws . id )
263+ }
264+
232265 get supportedActions ( ) {
233266 return this . actions
234267 }
@@ -300,6 +333,10 @@ export class ExpertAutomations extends ExpertActionsInterface {
300333 }
301334 break
302335
336+ case ADD_TAB :
337+ this . addTab ( params )
338+ result . success = true
339+ break
303340 default :
304341 result . handled = false
305342 result . success = false
0 commit comments