foreman-tasks 0.17.6 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc +2 -22
- data/.rubocop.yml +12 -12
- data/.rubocop_todo.yml +34 -116
- data/.travis.yml +2 -2
- data/app/controllers/foreman_tasks/api/recurring_logics_controller.rb +20 -1
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +38 -11
- data/app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb +1 -1
- data/app/controllers/foreman_tasks/recurring_logics_controller.rb +19 -0
- data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +0 -2
- data/app/lib/actions/helpers/humanizer.rb +1 -3
- data/app/lib/actions/proxy_action.rb +33 -12
- data/app/lib/foreman_tasks/concerns/polling_action_extensions.rb +12 -0
- data/app/models/foreman_tasks/concerns/action_triggering.rb +1 -1
- data/app/models/foreman_tasks/recurring_logic.rb +1 -0
- data/app/models/foreman_tasks/remote_task.rb +1 -0
- data/app/models/foreman_tasks/task.rb +4 -0
- data/app/models/foreman_tasks/task/dynflow_task.rb +1 -1
- data/app/models/foreman_tasks/task/search.rb +11 -1
- data/app/models/setting/foreman_tasks.rb +6 -1
- data/app/services/ui_notifications/tasks/task_bulk_cancel.rb +36 -0
- data/app/services/ui_notifications/tasks/task_bulk_resume.rb +38 -0
- data/app/views/foreman_tasks/api/recurring_logics/base.json.rabl +2 -1
- data/app/views/foreman_tasks/api/tasks/details.json.rabl +1 -0
- data/app/views/foreman_tasks/api/tasks/show.json.rabl +1 -1
- data/app/views/foreman_tasks/recurring_logics/index.html.erb +30 -0
- data/app/views/foreman_tasks/tasks/show.html.erb +3 -0
- data/babel.config.js +3 -0
- data/config/routes.rb +7 -0
- data/db/migrate/20200611090846_add_task_lock_index_on_resource_type_and_task_id.rb +9 -0
- data/db/seeds.d/30-notification_blueprints.rb +14 -0
- data/foreman-tasks.gemspec +5 -6
- data/gemfile.d/foreman-tasks.rb +1 -0
- data/lib/foreman_tasks/dynflow/console_authorizer.rb +2 -2
- data/lib/foreman_tasks/engine.rb +17 -14
- data/lib/foreman_tasks/tasks/cleanup.rake +3 -3
- data/lib/foreman_tasks/tasks/dynflow.rake +6 -0
- data/lib/foreman_tasks/tasks/export_tasks.rake +3 -3
- data/lib/foreman_tasks/test_extensions.rb +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/locale/action_names.rb +1 -1
- data/package.json +19 -79
- data/script/rails +2 -2
- data/script/travis_run_js_tests.sh +2 -2
- data/test/controllers/api/tasks_controller_test.rb +9 -0
- data/test/factories/task_factory.rb +34 -2
- data/test/foreman_tasks_test_helper.rb +4 -0
- data/test/lib/concerns/polling_action_extensions_test.rb +34 -0
- data/test/unit/actions/action_with_sub_plans_test.rb +1 -1
- data/test/unit/task_test.rb +160 -74
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +4 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +1 -4
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Errors.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Locks.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Raw.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +2 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskInfo.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +3 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +9 -15
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.stories.js +6 -2
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +2 -2
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +3 -0
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/index.js +2 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.stories.js +44 -40
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.stories.js +45 -40
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.stories.js +27 -22
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.stories.js +61 -56
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.stories.js +40 -35
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.stories.js +21 -20
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.stories.js +40 -39
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.stories.js +16 -17
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js +1 -2
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.mdx +57 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.stories.js +36 -18
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +5 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardHelper.js +3 -2
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboard.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardReducer.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/Components/CancelConfirm.js +53 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmationModals.js +56 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ResumeConfirm.js +52 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/SelectAllAlert.js +43 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelConfirm.test.js +26 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ConfirmationModals.test.js +24 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ResumeConfirm.test.js +26 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/SelectAllAlert.test.js +29 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionCell.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionHeaderCell.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelConfirm.test.js.snap +65 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ConfirmationModals.test.js.snap +30 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ResumeConfirm.test.js.snap +63 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/SelectAllAlert.test.js.snap +75 -0
- data/webpack/ForemanTasks/Components/TasksTable/SubTasksPage.js +4 -1
- data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +164 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +46 -22
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActionHelpers.js +52 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +88 -87
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +20 -5
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +4 -3
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +128 -31
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +26 -9
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +24 -16
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/SubTasksPage.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +112 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksIndexPage.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +12 -5
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActionHelpers.test.js +46 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +28 -52
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js +17 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +10 -2
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js +28 -8
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +15 -5
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +229 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +14 -5
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +56 -85
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +160 -34
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableReducer.test.js.snap +43 -16
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionHeaderCellFormatter.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionHeaderCellFormatter.js +2 -2
- data/webpack/ForemanTasks/Components/TasksTable/index.js +11 -4
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +4 -4
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +1 -1
- data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.test.js +1 -2
- data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.test.js +2 -2
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +3 -3
- data/webpack/ForemanTasks/Components/common/ToastTypesConstants.js +11 -0
- data/webpack/ForemanTasks/ForemanTasks.test.js +1 -1
- data/webpack/ForemanTasks/Routes/ForemanTasksRouter.test.js +1 -1
- data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +2 -3
- data/webpack/ForemanTasks/Routes/ShowTask/__tests__/ShowTask.test.js +1 -1
- data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +10 -0
- data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +4 -0
- metadata +55 -24
- data/.babelrc +0 -35
- data/.storybook/addons.js +0 -2
- data/.storybook/config.js +0 -7
- data/.storybook/webpack.config.js +0 -63
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.js +0 -23
- data/webpack/ForemanTasks/Components/TasksTable/Components/ActionConfirmation.js +0 -49
- data/webpack/ForemanTasks/Components/TasksTable/Components/CancelResumeConfirm.js +0 -51
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionConfirmation.test.js +0 -18
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelResumeConfirm.test.js +0 -28
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionConfirmation.test.js.snap +0 -89
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelResumeConfirm.test.js.snap +0 -37
- data/webpack/stories/index.js +0 -10
- data/webpack/stories/index.scss +0 -7
- data/webpack/test_setup.js +0 -6
@@ -0,0 +1 @@
|
|
1
|
+
gem 'sqlite3'
|
@@ -34,7 +34,7 @@ module ForemanTasks
|
|
34
34
|
# console no matter what task it is...
|
35
35
|
edit_permission = Permission.where(:name => :edit_foreman_tasks, :resource_type => ForemanTasks::Task.name).first
|
36
36
|
if @user.filters.joins(:filterings).unlimited.where('filterings.permission_id' => edit_permission).first
|
37
|
-
|
37
|
+
true
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
@@ -43,7 +43,7 @@ module ForemanTasks
|
|
43
43
|
begin
|
44
44
|
original_user = User.current
|
45
45
|
User.current = @user
|
46
|
-
|
46
|
+
Authorizer.new(@user).can?(:edit_foreman_tasks, task)
|
47
47
|
ensure
|
48
48
|
User.current = original_user
|
49
49
|
end
|
data/lib/foreman_tasks/engine.rb
CHANGED
@@ -7,10 +7,10 @@ module ForemanTasks
|
|
7
7
|
engine_name 'foreman_tasks'
|
8
8
|
|
9
9
|
initializer 'foreman_tasks.load_default_settings', :before => :load_config_initializers do
|
10
|
-
require_dependency File.expand_path('
|
10
|
+
require_dependency File.expand_path('../../app/models/setting/foreman_tasks.rb', __dir__) if begin
|
11
11
|
Setting.table_exists?
|
12
|
-
|
13
|
-
|
12
|
+
rescue
|
13
|
+
false
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
@@ -26,7 +26,7 @@ module ForemanTasks
|
|
26
26
|
end
|
27
27
|
|
28
28
|
initializer 'foreman_tasks.register_gettext', :after => :load_config_initializers do
|
29
|
-
locale_dir = File.join(File.expand_path('
|
29
|
+
locale_dir = File.join(File.expand_path('../..', __dir__), 'locale')
|
30
30
|
locale_domain = 'foreman_tasks'
|
31
31
|
|
32
32
|
Foreman::Gettext::Support.add_text_domain locale_domain, locale_dir
|
@@ -34,7 +34,7 @@ module ForemanTasks
|
|
34
34
|
|
35
35
|
initializer 'foreman_tasks.register_plugin', :before => :finisher_hook do |_app|
|
36
36
|
Foreman::Plugin.register :"foreman-tasks" do
|
37
|
-
requires_foreman '>=
|
37
|
+
requires_foreman '>= 2.0.0'
|
38
38
|
divider :top_menu, :parent => :monitor_menu, :last => true, :caption => N_('Foreman Tasks')
|
39
39
|
menu :top_menu, :tasks,
|
40
40
|
:url_hash => { :controller => 'foreman_tasks/tasks', :action => :index },
|
@@ -53,15 +53,15 @@ module ForemanTasks
|
|
53
53
|
:'foreman_tasks/react' => [:index],
|
54
54
|
:'foreman_tasks/api/tasks' => [:bulk_search, :show, :index, :summary, :summary_sub_tasks, :details, :sub_tasks] }, :resource_type => ForemanTasks::Task.name
|
55
55
|
permission :edit_foreman_tasks, { :'foreman_tasks/tasks' => [:resume, :unlock, :force_unlock, :cancel_step, :cancel, :abort],
|
56
|
-
:'foreman_tasks/api/tasks' => [:bulk_resume] }, :resource_type => ForemanTasks::Task.name
|
56
|
+
:'foreman_tasks/api/tasks' => [:bulk_resume, :bulk_cancel] }, :resource_type => ForemanTasks::Task.name
|
57
57
|
|
58
58
|
permission :create_recurring_logics, {}, :resource_type => ForemanTasks::RecurringLogic.name
|
59
59
|
|
60
60
|
permission :view_recurring_logics, { :'foreman_tasks/recurring_logics' => [:index, :show],
|
61
61
|
:'foreman_tasks/api/recurring_logics' => [:index, :show] }, :resource_type => ForemanTasks::RecurringLogic.name
|
62
62
|
|
63
|
-
permission :edit_recurring_logics, { :'foreman_tasks/recurring_logics' => [:cancel, :enable, :disable],
|
64
|
-
:'foreman_tasks/api/recurring_logics' => [:cancel, :update] }, :resource_type => ForemanTasks::RecurringLogic.name
|
63
|
+
permission :edit_recurring_logics, { :'foreman_tasks/recurring_logics' => [:cancel, :enable, :disable, :clear_cancelled],
|
64
|
+
:'foreman_tasks/api/recurring_logics' => [:cancel, :update, :bulk_destroy] }, :resource_type => ForemanTasks::RecurringLogic.name
|
65
65
|
end
|
66
66
|
|
67
67
|
add_all_permissions_to_default_roles
|
@@ -69,8 +69,10 @@ module ForemanTasks
|
|
69
69
|
logger :dynflow, :enabled => true
|
70
70
|
logger :action, :enabled => true
|
71
71
|
|
72
|
-
role 'Tasks Manager', [:view_foreman_tasks, :edit_foreman_tasks]
|
73
|
-
|
72
|
+
role 'Tasks Manager', [:view_foreman_tasks, :edit_foreman_tasks],
|
73
|
+
'Role granting permissions to inspect, cancel, resume and unlock tasks'
|
74
|
+
role 'Tasks Reader', [:view_foreman_tasks],
|
75
|
+
'Role granting permissions to inspect tasks'
|
74
76
|
|
75
77
|
widget 'foreman_tasks/tasks/dashboard/tasks_status', :sizex => 6, :sizey => 1, :name => N_('Task Status')
|
76
78
|
widget 'foreman_tasks/tasks/dashboard/latest_tasks_in_error_warning', :sizex => 6, :sizey => 1, :name => N_('Latest Warning/Error Tasks')
|
@@ -133,16 +135,17 @@ module ForemanTasks
|
|
133
135
|
# to enable async Foreman operations using Dynflow
|
134
136
|
if ENV['FOREMAN_TASKS_MONKEYS'] == 'true'
|
135
137
|
config.to_prepare do
|
136
|
-
::Api::V2::HostsController.
|
137
|
-
::Host::Base.
|
138
|
+
::Api::V2::HostsController.prepend ForemanTasks::Concerns::HostsControllerExtension
|
139
|
+
::Host::Base.include ForemanTasks::Concerns::HostActionSubject
|
138
140
|
end
|
139
141
|
end
|
140
142
|
|
141
143
|
config.to_prepare do
|
142
144
|
ForemanTasks.dynflow.eager_load_actions! if ForemanTasks.dynflow.initialized?
|
143
145
|
|
144
|
-
Authorizer.
|
145
|
-
User.
|
146
|
+
Authorizer.prepend AuthorizerExt
|
147
|
+
User.include ForemanTasks::Concerns::UserExtensions
|
148
|
+
::Dynflow::Action::Polling.prepend ForemanTasks::Concerns::PollingActionExtensions
|
146
149
|
end
|
147
150
|
|
148
151
|
rake_tasks do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
namespace :foreman_tasks do
|
2
2
|
namespace :cleanup do
|
3
|
-
desc
|
3
|
+
desc <<~DESC
|
4
4
|
Clean tasks based on filter and age. ENV variables:
|
5
5
|
|
6
6
|
* TASK_SEARCH : scoped search filter (example: 'label = "Actions::Foreman::Host::ImportFacts"')
|
@@ -14,7 +14,7 @@ namespace :foreman_tasks do
|
|
14
14
|
If TASK_SEARCH is set then AFTER, STATES can be set and it's used for cleanup. If TASK_SEARCH is not set then
|
15
15
|
the cleanup respects the configuration file and setting AFTER or STATES will throw exception.
|
16
16
|
DESC
|
17
|
-
task :run => 'environment' do
|
17
|
+
task :run => ['environment', 'dynflow:client'] do
|
18
18
|
options = {}
|
19
19
|
|
20
20
|
options[:filter] = ENV['TASK_SEARCH'] if ENV['TASK_SEARCH']
|
@@ -38,7 +38,7 @@ namespace :foreman_tasks do
|
|
38
38
|
end
|
39
39
|
|
40
40
|
desc 'Show the current configuration for auto-cleanup'
|
41
|
-
task :config => 'environment' do
|
41
|
+
task :config => ['environment', 'dynflow:client'] do
|
42
42
|
if ForemanTasks::Cleaner.cleanup_settings[:after]
|
43
43
|
puts _('The tasks will be deleted after %{after}') % { :after => ForemanTasks::Cleaner.cleanup_settings[:after] }
|
44
44
|
else
|
@@ -7,7 +7,7 @@
|
|
7
7
|
require 'csv'
|
8
8
|
|
9
9
|
namespace :foreman_tasks do
|
10
|
-
desc
|
10
|
+
desc <<~DESC
|
11
11
|
Export dynflow tasks based on filter. ENV variables:
|
12
12
|
|
13
13
|
* TASK_SEARCH : scoped search filter (example: 'label = "Actions::Foreman::Host::ImportFacts"')
|
@@ -19,7 +19,7 @@ namespace :foreman_tasks do
|
|
19
19
|
all unsuccessful tasks in the past 60 days. The default TASK_FORMAT is html
|
20
20
|
which requires a tar.gz file extension.
|
21
21
|
DESC
|
22
|
-
task :export_tasks => :environment do
|
22
|
+
task :export_tasks => [:environment, 'dynflow:client'] do
|
23
23
|
deprecated_options = { :tasks => 'TASK_SEARCH',
|
24
24
|
:days => 'TASK_DAYS',
|
25
25
|
:export => 'TASK_FILE' }
|
@@ -259,7 +259,7 @@ namespace :foreman_tasks do
|
|
259
259
|
|
260
260
|
File.open(File.join(tmp_dir, 'index.html'), 'w') { |file| file.write(PageHelper.pagify(PageHelper.generate_index(tasks))) }
|
261
261
|
|
262
|
-
|
262
|
+
system("tar", "czf", export_filename, tmp_dir)
|
263
263
|
end
|
264
264
|
elsif format == 'csv'
|
265
265
|
CSV.open(export_filename, 'wb') do |csv|
|
data/locale/action_names.rb
CHANGED
data/package.json
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
"description": "Foreman Tasks =============",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
7
|
-
"lint": "
|
8
|
-
"test": "
|
9
|
-
"test:watch": "
|
10
|
-
"test:current": "
|
11
|
-
"
|
12
|
-
"
|
13
|
-
"
|
14
|
-
"
|
7
|
+
"lint": "tfm-lint --plugin -d /webpack",
|
8
|
+
"test": "tfm-test --plugin",
|
9
|
+
"test:watch": "tfm-test --plugin --watchAll",
|
10
|
+
"test:current": "tfm-test --plugin --watch",
|
11
|
+
"publish-coverage": "tfm-publish-coverage",
|
12
|
+
"stories": "tfm-stories --plugin",
|
13
|
+
"stories:build": "tfm-build-stories --plugin",
|
14
|
+
"stories:deploy": "surge --project .storybook-dist",
|
15
15
|
"create-react-component": "yo react-domain"
|
16
16
|
},
|
17
17
|
"repository": {
|
@@ -21,88 +21,28 @@
|
|
21
21
|
"bugs": {
|
22
22
|
"url": "http://projects.theforeman.org/projects/foreman-tasks/issues"
|
23
23
|
},
|
24
|
+
"peerDependencies": {
|
25
|
+
"@theforeman/vendor": ">= 4.0.2"
|
26
|
+
},
|
24
27
|
"dependencies": {
|
25
|
-
"@theforeman/vendor": "^1.4.0",
|
26
28
|
"c3": "^0.4.11",
|
27
29
|
"humanize-duration": "^3.20.1",
|
28
30
|
"react-html-parser": "^2.0.2",
|
29
31
|
"react-intl": "^2.8.0"
|
30
32
|
},
|
31
33
|
"devDependencies": {
|
32
|
-
"@
|
33
|
-
"@
|
34
|
-
"@
|
35
|
-
"@theforeman/
|
36
|
-
"
|
37
|
-
"
|
38
|
-
"babel-eslint": "^
|
39
|
-
"
|
40
|
-
"babel-loader": "^7.1.1",
|
41
|
-
"babel-plugin-dynamic-import-node": "^2.0.0",
|
42
|
-
"babel-plugin-module-resolver": "^3.2.0",
|
43
|
-
"babel-plugin-syntax-dynamic-import": "^6.18.0",
|
44
|
-
"babel-plugin-transform-class-properties": "^6.24.1",
|
45
|
-
"babel-plugin-transform-object-assign": "^6.8.0",
|
46
|
-
"babel-plugin-transform-object-rest-spread": "^6.8.0",
|
47
|
-
"babel-preset-env": "^1.7.0",
|
48
|
-
"babel-preset-react": "^6.5.0",
|
49
|
-
"coveralls": "^3.0.0",
|
50
|
-
"enzyme": "^3.4.0",
|
51
|
-
"enzyme-adapter-react-16": "^1.4.0",
|
52
|
-
"enzyme-to-json": "^3.2.1",
|
53
|
-
"eslint": "^4.10.0",
|
54
|
-
"eslint-import-resolver-babel-module": "^4.0.0",
|
55
|
-
"eslint-plugin-patternfly-react": "0.2.0",
|
56
|
-
"identity-obj-proxy": "^3.0.0",
|
34
|
+
"@babel/core": "^7.7.0",
|
35
|
+
"@theforeman/builder": "^4.0.2",
|
36
|
+
"@theforeman/eslint-plugin-foreman": "4.0.5",
|
37
|
+
"@theforeman/stories": "^4.0.2",
|
38
|
+
"@theforeman/test": "^4.0.2",
|
39
|
+
"@theforeman/vendor-dev": "^4.0.2",
|
40
|
+
"babel-eslint": "^10.0.3",
|
41
|
+
"eslint": "^6.7.2",
|
57
42
|
"jed": "^1.1.1",
|
58
|
-
"jest-cli": "^23.6.0",
|
59
|
-
"jest-prop-type-error": "^1.1.0",
|
60
|
-
"node-sass": "^4.5.0",
|
61
|
-
"patternfly": "^3.58.0",
|
62
43
|
"prettier": "^1.13.5",
|
63
|
-
"raf": "^3.4.0",
|
64
|
-
"react-redux-test-utils": "^0.1.1",
|
65
|
-
"react-remarkable": "^1.1.3",
|
66
|
-
"sass-loader": "^6.0.7",
|
67
44
|
"stylelint": "^9.3.0",
|
68
45
|
"stylelint-config-standard": "^18.0.0",
|
69
46
|
"surge": "^0.20.3"
|
70
|
-
},
|
71
|
-
"jest": {
|
72
|
-
"verbose": true,
|
73
|
-
"testMatch": [
|
74
|
-
"**/*.test.js"
|
75
|
-
],
|
76
|
-
"testURL": "http://localhost/",
|
77
|
-
"collectCoverage": true,
|
78
|
-
"collectCoverageFrom": [
|
79
|
-
"webpack/**/*.js",
|
80
|
-
"!webpack/index.js",
|
81
|
-
"!webpack/test_setup.js",
|
82
|
-
"!webpack/**/bundle*",
|
83
|
-
"!webpack/stories/**",
|
84
|
-
"!webpack/**/*stories.js"
|
85
|
-
],
|
86
|
-
"coverageReporters": [
|
87
|
-
"lcov"
|
88
|
-
],
|
89
|
-
"moduleNameMapper": {
|
90
|
-
"^.+\\.(png|gif|css|scss)$": "identity-obj-proxy"
|
91
|
-
},
|
92
|
-
"globals": {
|
93
|
-
"__testing__": true
|
94
|
-
},
|
95
|
-
"transform": {
|
96
|
-
"^.+\\.js$": "babel-jest"
|
97
|
-
},
|
98
|
-
"moduleDirectories": [
|
99
|
-
"node_modules",
|
100
|
-
"webpack"
|
101
|
-
],
|
102
|
-
"setupFiles": [
|
103
|
-
"raf/polyfill",
|
104
|
-
"jest-prop-type-error",
|
105
|
-
"./webpack/test_setup.js"
|
106
|
-
]
|
107
47
|
}
|
108
48
|
}
|
data/script/rails
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
3
|
|
4
|
-
ENGINE_ROOT = File.expand_path('
|
5
|
-
ENGINE_PATH = File.expand_path('
|
4
|
+
ENGINE_ROOT = File.expand_path('..', __dir__)
|
5
|
+
ENGINE_PATH = File.expand_path('../lib/foreman_tasks/engine', __dir__)
|
6
6
|
|
7
7
|
require 'rails/all'
|
8
8
|
require 'rails/engine/commands'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/bin/bash
|
2
2
|
set -ev
|
3
|
-
if [[ $( git diff --name-only HEAD~1..HEAD webpack/ .travis.yml .
|
3
|
+
if [[ $( git diff --name-only HEAD~1..HEAD webpack/ .travis.yml babel.config.js .eslintrc package.json | wc -l ) -ne 0 ]]; then
|
4
4
|
npm run test;
|
5
|
-
npm run
|
5
|
+
npm run publish-coverage;
|
6
6
|
npm run lint;
|
7
7
|
fi
|
@@ -27,6 +27,15 @@ module ForemanTasks
|
|
27
27
|
_(data['results'].count).must_equal 5
|
28
28
|
end
|
29
29
|
|
30
|
+
it 'renders task ids when searching by resource id' do
|
31
|
+
task = FactoryBot.create(:dynflow_task, :product_create_task)
|
32
|
+
ForemanTasks::Lock.create!(name: "create", resource_type: "Katello::Product", resource_id: 1, task_id: task.id)
|
33
|
+
get :index, params: { :search => "label = Actions::Katello::Product::Create and resource_id = 1" }
|
34
|
+
assert_response :success
|
35
|
+
data = JSON.parse(response.body)
|
36
|
+
_(data['results'].first["id"]).must_equal task.id
|
37
|
+
end
|
38
|
+
|
30
39
|
it 'supports ordering by duration' do
|
31
40
|
get :index, params: { :sort_by => 'duration' }
|
32
41
|
assert_response :success
|
@@ -22,7 +22,7 @@ FactoryBot.define do
|
|
22
22
|
execution_plan = ForemanTasks.dynflow.world.plan(Support::DummyDynflowAction)
|
23
23
|
# remove the task created automatically by the persistence
|
24
24
|
ForemanTasks::Task.where(:external_id => execution_plan.id).delete_all
|
25
|
-
task.
|
25
|
+
task.update!(:external_id => execution_plan.id)
|
26
26
|
if evaluator.sync_with_dynflow
|
27
27
|
task.update_from_dynflow(execution_plan.to_hash)
|
28
28
|
end
|
@@ -38,9 +38,41 @@ FactoryBot.define do
|
|
38
38
|
|
39
39
|
trait :inconsistent_dynflow_task do
|
40
40
|
after(:build) do |task|
|
41
|
-
task.
|
41
|
+
task.update!(:state => 'running')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
factory :task_with_locks do
|
46
|
+
# posts_count is declared as a transient attribute and available in
|
47
|
+
# attributes on the factory, as well as the callback via the evaluator
|
48
|
+
transient do
|
49
|
+
locks_count { 3 }
|
50
|
+
resource_id { 1 }
|
51
|
+
resource_type { 'type1' }
|
52
|
+
end
|
53
|
+
|
54
|
+
# the after(:create) yields two values; the user instance itself and the
|
55
|
+
# evaluator, which stores all values from the factory, including transient
|
56
|
+
# attributes; `create_list`'s second argument is the number of records
|
57
|
+
# to create and we make sure the user is associated properly to the post
|
58
|
+
after(:create) do |task, evaluator|
|
59
|
+
create_list(
|
60
|
+
:lock,
|
61
|
+
evaluator.locks_count,
|
62
|
+
task: task,
|
63
|
+
resource_type: evaluator.resource_type,
|
64
|
+
resource_id: evaluator.resource_id
|
65
|
+
)
|
42
66
|
end
|
43
67
|
end
|
44
68
|
end
|
45
69
|
end
|
70
|
+
|
71
|
+
factory :lock, :class => ForemanTasks::Lock do
|
72
|
+
name { 'read' }
|
73
|
+
resource_type { 'Katello::Repository' }
|
74
|
+
resource_id { 1 }
|
75
|
+
exclusive { true }
|
76
|
+
association :task, factory: :task_with_locks
|
77
|
+
end
|
46
78
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'foreman_tasks_test_helper'
|
2
|
+
|
3
|
+
module ForemanTasks
|
4
|
+
module Concerns
|
5
|
+
class PollingActionExtensionsTest < ::ActiveSupport::TestCase
|
6
|
+
class Action < ::Dynflow::Action
|
7
|
+
include ::Dynflow::Action::Polling
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'polling interval tuning' do
|
11
|
+
let(:default_intervals) { [0.5, 1, 2, 4, 8, 16] }
|
12
|
+
|
13
|
+
it 'is extends the polling action module' do
|
14
|
+
_(::Dynflow::Action::Polling.ancestors.first).must_equal ForemanTasks::Concerns::PollingActionExtensions
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'does not modify polling intervals by default' do
|
18
|
+
_(Action.allocate.poll_intervals).must_equal default_intervals
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'cannot make intervals shorter than 0.5 seconds' do
|
22
|
+
Setting.expects(:[]).with(:foreman_tasks_polling_multiplier).returns 0
|
23
|
+
_(Action.allocate.poll_intervals).must_equal(default_intervals.map { 0.5 })
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'can be used to make the intervals longer' do
|
27
|
+
value = 5
|
28
|
+
Setting.expects(:[]).with(:foreman_tasks_polling_multiplier).returns value
|
29
|
+
_(Action.allocate.poll_intervals).must_equal(default_intervals.map { |i| i * value })
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|