Skip to content

Commit 71ffe2c

Browse files
committed
Workflow UI: When adding a new job node, honor the new_event_template config settings (category, plugin, targets)
1 parent 99f19a6 commit 71ffe2c

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

htdocs/js/pages/Workflows.class.js

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,13 +1639,26 @@ Page.Workflows = class Workflows extends Page.Events {
16391639
data: { params: {}, targets: [], algo: 'random', label: '' }
16401640
};
16411641

1642-
if (find_object(app.categories, { id: 'general' })) node.data.category = 'general';
1643-
else if (!app.categories.length) return app.doError('wfdj_no_cats');
1644-
else node.data.category = app.categories[0].id;
1642+
var cat_id = '';
1643+
if (app.config.new_event_template.category) cat_id = app.config.new_event_template.category;
1644+
else if (find_object(app.categories, { id: 'general' })) cat_id = 'general';
1645+
else if (!app.categories.length) return this.doFullPageError(config.ui.errors.new_wf_no_cats);
1646+
else cat_id = app.categories[0].id;
1647+
node.data.category = cat_id;
1648+
1649+
var plug_id = '';
1650+
if (app.config.new_event_template.plugin) plug_id = app.config.new_event_template.plugin;
1651+
else if (find_object(app.plugins, { id: 'shellplug' })) plug_id = 'shellplug';
1652+
else if (!app.plugins.length) return this.doFullPageError(config.ui.errors.new_wf_no_plugins);
1653+
else plug_id = app.plugins[0].id;
1654+
node.data.plugin = plug_id;
16451655

1646-
if (find_object(app.plugins, { id: 'shellplug' })) node.data.plugin = 'shellplug';
1647-
else if (!app.plugins.length) return app.doError('wfdj_no_plugins');
1648-
else node.data.plugin = app.plugins[0].id;
1656+
var target_ids = [];
1657+
if (app.config.new_event_template.targets && app.config.new_event_template.targets.length) target_ids = [ ...app.config.new_event_template.targets ];
1658+
else if (find_object(app.groups, { id: 'main' })) target_ids = ['main'];
1659+
else if (!app.groups.length) return this.doFullPageError(config.ui.errors.new_wf_no_groups);
1660+
else target_ids = [ app.groups[0].id ];
1661+
node.data.targets = target_ids;
16491662
} // do_create
16501663

16511664
var plugin = find_object( app.plugins, { id: node.data.plugin } );

0 commit comments

Comments
 (0)