foreman-tasks 2.0.3 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/js_tests.yml +31 -0
  3. data/.github/workflows/ruby_tests.yml +74 -0
  4. data/.rubocop.yml +12 -4
  5. data/.rubocop_todo.yml +32 -25
  6. data/Gemfile +5 -0
  7. data/app/controllers/foreman_tasks/api/tasks_controller.rb +50 -63
  8. data/app/controllers/foreman_tasks/concerns/parameters/triggering.rb +1 -1
  9. data/app/controllers/foreman_tasks/recurring_logics_controller.rb +7 -0
  10. data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +3 -3
  11. data/app/models/foreman_tasks/recurring_logic.rb +1 -1
  12. data/app/models/foreman_tasks/task.rb +11 -0
  13. data/app/models/foreman_tasks/task/dynflow_task.rb +27 -33
  14. data/app/models/foreman_tasks/task/search.rb +1 -1
  15. data/app/models/foreman_tasks/task/status_explicator.rb +1 -1
  16. data/app/models/foreman_tasks/triggering.rb +1 -1
  17. data/app/models/setting/foreman_tasks.rb +9 -9
  18. data/app/services/foreman_tasks/dashboard_table_filter.rb +5 -1
  19. data/app/views/foreman_tasks/api/tasks/index.json.rabl +2 -0
  20. data/app/views/foreman_tasks/layouts/react.html.erb +1 -2
  21. data/app/views/foreman_tasks/recurring_logics/index.html.erb +3 -1
  22. data/app/views/foreman_tasks/tasks/dashboard/_latest_tasks_in_error_warning.html.erb +1 -1
  23. data/app/views/foreman_tasks/tasks/dashboard/_tasks_status.html.erb +1 -1
  24. data/app/views/foreman_tasks/tasks/show.html.erb +1 -6
  25. data/config/routes.rb +2 -1
  26. data/db/migrate/20200517215015_rename_bookmarks_controller.rb +2 -2
  27. data/db/seeds.d/30-notification_blueprints.rb +7 -7
  28. data/db/seeds.d/61-foreman_tasks_bookmarks.rb +1 -1
  29. data/foreman-tasks.gemspec +1 -0
  30. data/lib/foreman_tasks/cleaner.rb +4 -6
  31. data/lib/foreman_tasks/dynflow/configuration.rb +1 -1
  32. data/lib/foreman_tasks/dynflow/persistence.rb +4 -6
  33. data/lib/foreman_tasks/engine.rb +2 -2
  34. data/lib/foreman_tasks/version.rb +1 -1
  35. data/package.json +0 -1
  36. data/test/controllers/api/recurring_logics_controller_test.rb +1 -1
  37. data/test/controllers/api/tasks_controller_test.rb +17 -7
  38. data/test/controllers/tasks_controller_test.rb +6 -6
  39. data/test/core/unit/runner_test.rb +20 -20
  40. data/test/core/unit/task_launcher_test.rb +8 -8
  41. data/test/helpers/foreman_tasks/foreman_tasks_helper_test.rb +7 -7
  42. data/test/helpers/foreman_tasks/tasks_helper_test.rb +3 -3
  43. data/test/lib/actions/middleware/keep_current_request_id_test.rb +3 -3
  44. data/test/support/history_tasks_builder.rb +1 -1
  45. data/test/tasks/generate_task_actions_test.rb +1 -1
  46. data/test/unit/actions/action_with_sub_plans_test.rb +2 -2
  47. data/test/unit/actions/bulk_action_test.rb +6 -6
  48. data/test/unit/actions/proxy_action_test.rb +20 -20
  49. data/test/unit/actions/recurring_action_test.rb +30 -32
  50. data/test/unit/cleaner_test.rb +24 -24
  51. data/test/unit/dashboard_table_filter_test.rb +5 -5
  52. data/test/unit/otp_manager_test.rb +2 -2
  53. data/test/unit/proxy_selector_test.rb +9 -9
  54. data/test/unit/recurring_logic_test.rb +32 -32
  55. data/test/unit/remote_task_test.rb +2 -2
  56. data/test/unit/task_groups_test.rb +4 -4
  57. data/test/unit/task_test.rb +26 -18
  58. data/test/unit/triggering_test.rb +8 -8
  59. data/test/unit/troubleshooting_help_generator_test.rb +6 -6
  60. data/test/unit/ui_notifications_test.rb +11 -11
  61. data/webpack/ForemanTasks/Components/TaskDetails/Components/RunningSteps.js +3 -3
  62. data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +8 -157
  63. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskButtons.js +168 -0
  64. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +6 -7
  65. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskSkeleton.js +48 -0
  66. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +1 -1
  67. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +12 -70
  68. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskButtons.test.js +95 -0
  69. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +78 -225
  70. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskButtons.test.js.snap +212 -0
  71. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +8 -4
  72. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.js +87 -70
  73. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.scss +10 -0
  74. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +48 -125
  75. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +3 -16
  76. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +55 -29
  77. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.fixtures.js +2 -2
  78. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +6 -0
  79. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +2 -18
  80. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +77 -27
  81. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap +14 -101
  82. data/webpack/ForemanTasks/Components/TaskDetails/index.js +6 -3
  83. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.scss +4 -0
  84. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.js +53 -0
  85. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.test.js +14 -0
  86. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.js +27 -19
  87. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.scss +14 -0
  88. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +1 -34
  89. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/{StoppedTasksCardHelper.js → StoppedTasksCardTable.js} +28 -1
  90. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardTable.test.js +54 -0
  91. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/OtherInfo.test.js.snap +48 -0
  92. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCard.test.js.snap +60 -1367
  93. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCardTable.test.js.snap +960 -0
  94. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/__snapshots__/TasksCardsGrid.test.js.snap +14 -11
  95. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +2 -0
  96. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js +17 -11
  97. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test.js +26 -14
  98. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboard.test.js.snap +14 -11
  99. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardSelectors.test.js.snap +38 -22
  100. data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +0 -8
  101. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +13 -4
  102. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.scss +0 -10
  103. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +0 -2
  104. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionNameCellFormatter.test.js.snap +3 -1
  105. data/webpack/ForemanTasks/Components/TasksTable/formatters/actionNameCellFormatter.js +6 -1
  106. data/webpack/ForemanTasks/Components/common/urlHelpers.js +7 -0
  107. data/webpack/ForemanTasks/ForemanTasksReducers.js +0 -2
  108. data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
  109. data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +10 -0
  110. data/webpack/__mocks__/foremanReact/redux/API/index.js +10 -0
  111. data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +5 -0
  112. metadata +21 -13
  113. data/.travis.yml +0 -7
  114. data/app/assets/stylesheets/foreman_tasks/tasks.scss +0 -9
  115. data/script/travis_run_js_tests.sh +0 -7
  116. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -38
  117. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +0 -33
  118. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsReducer.test.js.snap +0 -26
  119. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/integration.test.js.snap +0 -122
  120. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +0 -72
  121. data/webpack/__mocks__/foremanReact/redux/API.js +0 -7
@@ -15,7 +15,7 @@ module ForemanTasks
15
15
  *::ForemanTasks::Triggering::PARAMS,
16
16
  :days_of_week => {},
17
17
  :time => {},
18
- :end_time => {}
18
+ :end_time => {},
19
19
  ],
20
20
  :nested => true
21
21
  )
@@ -1,5 +1,7 @@
1
1
  module ForemanTasks
2
2
  class RecurringLogicsController < ::ApplicationController
3
+ include Foreman::Controller::AutoCompleteSearch
4
+
3
5
  before_action :find_recurring_logic, :only => [:show, :cancel, :enable, :disable]
4
6
 
5
7
  def index
@@ -41,6 +43,11 @@ module ForemanTasks
41
43
  def change_enabled(value)
42
44
  begin
43
45
  @recurring_logic.update!(:enabled => value)
46
+ flash[:success] = if value
47
+ _('The recurring logic was enabled.')
48
+ else
49
+ _('The recurring logic was disabled.')
50
+ end
44
51
  rescue RecurringLogicCancelledException => e
45
52
  @errors = e.message
46
53
  end
@@ -82,7 +82,7 @@ module ForemanTasks
82
82
  ' &mdash; ',
83
83
  content_tag(:span, nil, :class => 'time', :style => 'white-space: nowrap;') do
84
84
  fields.time_select(attr, datetime_options.merge(:ignore_date => true), html_options)
85
- end
85
+ end,
86
86
  ].join
87
87
  end
88
88
  end
@@ -139,7 +139,7 @@ module ForemanTasks
139
139
  cronline_fieldset(f, triggering),
140
140
  monthly_fieldset(f, triggering),
141
141
  weekly_fieldset(f, triggering),
142
- time_picker_fieldset(f, triggering)
142
+ time_picker_fieldset(f, triggering),
143
143
  ]
144
144
 
145
145
  content_tag(:fieldset, nil, :id => 'trigger_mode_recurring', :class => "trigger_mode_form #{'hidden' unless triggering.recurring?}") do
@@ -158,7 +158,7 @@ module ForemanTasks
158
158
  # TRANSLATORS: this translation is referring to an option which is a time interval
159
159
  _('is month (range: 1-12)'),
160
160
  # TRANSLATORS: this translation is referring to an option which is a time interval
161
- _('is day of week (range: 0-6)')
161
+ _('is day of week (range: 0-6)'),
162
162
  ].map { |opt| content_tag(:li, opt) }.join
163
163
 
164
164
  help = _("Cron line format 'a b c d e', where: %s") % "<br><ol type=\"a\">#{options}</ol>".html_safe
@@ -95,7 +95,7 @@ module ForemanTasks
95
95
  :start_at => next_occurrence_time(time),
96
96
  :start_before => options['start_before'],
97
97
  :recurring_logic_id => id,
98
- :frozen => disabled?
98
+ :frozen => disabled?,
99
99
  }
100
100
  end
101
101
 
@@ -70,6 +70,17 @@ module ForemanTasks
70
70
  end)
71
71
  scope :for_action_types, (->(action_types) { where('foreman_tasks_tasks.label IN (?)', Array(action_types)) })
72
72
 
73
+ apipie :class, "A class representing #{model_name.human} object" do
74
+ name 'Task'
75
+ refs 'Task'
76
+ sections only: %w[all additional]
77
+ property :main_action, object_of: 'Dynflow::Action', desc: 'Returns the main action of the task, e.g. Actions::RemoteExecution::RunHostJob'
78
+ property :label, String, desc: 'Returns the label of the task'
79
+ property :state, String, desc: 'Returns state of the task execution, e.g. "stopped"'
80
+ property :result, String, desc: 'Returns result of the task execution, e.g. "success"'
81
+ property :started_at, ActiveSupport::TimeWithZone, desc: 'Returns date with time the task started at'
82
+ property :ended_at, ActiveSupport::TimeWithZone, desc: 'Returns date with time the task ended at'
83
+ end
73
84
  class Jail < Safemode::Jail
74
85
  allow :started_at, :ended_at, :result, :state, :label, :main_action
75
86
  end
@@ -102,32 +102,28 @@ module ForemanTasks
102
102
 
103
103
  def input_output_failed_steps
104
104
  failed_steps.map do |f|
105
- begin
106
- f_action = f.action(execution_plan)
107
- {
108
- error: ({ exception_class: f.error.exception_class, message: f.error.message, backtrace: f.error.backtrace } if f.error),
109
- action_class: f.action_class.name,
110
- state: f.state,
111
- input: f_action.input.pretty_inspect,
112
- output: f_action.output.pretty_inspect
113
- }
114
- end
105
+ f_action = f.action(execution_plan)
106
+ {
107
+ error: ({ exception_class: f.error.exception_class, message: f.error.message, backtrace: f.error.backtrace } if f.error),
108
+ action_class: f.action_class.name,
109
+ state: f.state,
110
+ input: f_action.input.pretty_inspect,
111
+ output: f_action.output.pretty_inspect,
112
+ }
115
113
  end
116
114
  end
117
115
 
118
116
  def input_output_running_steps
119
117
  running_steps.map do |f|
120
- begin
121
- f_action = f.action(execution_plan)
122
- {
123
- id: f_action.id,
124
- action_class: f.action_class.name,
125
- state: f.state,
126
- input: f_action.input.pretty_inspect,
127
- output: f_action.output.pretty_inspect,
128
- cancellable: cancellable_action?(f_action)
129
- }
130
- end
118
+ f_action = f.action(execution_plan)
119
+ {
120
+ id: f_action.id,
121
+ action_class: f.action_class.name,
122
+ state: f.state,
123
+ input: f_action.input.pretty_inspect,
124
+ output: f_action.output.pretty_inspect,
125
+ cancellable: cancellable_action?(f_action),
126
+ }
131
127
  end
132
128
  end
133
129
 
@@ -220,19 +216,17 @@ module ForemanTasks
220
216
  fixed_count = 0
221
217
  logger = Foreman::Logging.logger('foreman-tasks')
222
218
  running.each do |task|
223
- begin
224
- changes = task.update_from_dynflow(task.execution_plan.to_hash)
225
- unless changes.empty?
226
- fixed_count += 1
227
- logger.warn('Task %s updated at consistency check: %s' % [task.id, changes.inspect])
228
- end
229
- rescue => e
230
- # if we fail updating the data from dynflow, it usually means there is something
231
- # odd with the data consistency and at this point it is not possible to resume, switching
232
- # the task to stopped/error
233
- task.update(:state => 'stopped', :result => 'error')
234
- Foreman::Logging.exception("Failed at consistency check for task #{task.id}", e, :logger => 'foreman-tasks')
219
+ changes = task.update_from_dynflow(task.execution_plan.to_hash)
220
+ unless changes.empty?
221
+ fixed_count += 1
222
+ logger.warn('Task %s updated at consistency check: %s' % [task.id, changes.inspect])
235
223
  end
224
+ rescue => e
225
+ # if we fail updating the data from dynflow, it usually means there is something
226
+ # odd with the data consistency and at this point it is not possible to resume, switching
227
+ # the task to stopped/error
228
+ task.update(:state => 'stopped', :result => 'error')
229
+ Foreman::Logging.exception("Failed at consistency check for task #{task.id}", e, :logger => 'foreman-tasks')
236
230
  end
237
231
  fixed_count
238
232
  end
@@ -20,7 +20,7 @@ module ForemanTasks
20
20
  foreman_tasks_locks_taxonomy#{uniq_suffix}.resource_type = '#{resource_type}')
21
21
  SQL
22
22
  # Select only those tasks which either have the correct taxonomy or are not related to any
23
- sql = "foreman_tasks_locks_taxonomy#{uniq_suffix}.resource_id #{operator} ? OR foreman_tasks_locks_taxonomy#{uniq_suffix}.resource_id IS NULL"
23
+ sql = "foreman_tasks_locks_taxonomy#{uniq_suffix}.resource_id #{operator} (?) OR foreman_tasks_locks_taxonomy#{uniq_suffix}.resource_id IS NULL"
24
24
  { :conditions => sanitize_sql_for_conditions([sql, value]), :joins => joins }
25
25
  end
26
26
 
@@ -4,7 +4,7 @@ module ForemanTasks
4
4
  ERRONEOUS_STATUSES = [
5
5
  { :state => 'paused', :result => ANY },
6
6
  { :state => ANY, :result => 'error' },
7
- { :state => ANY, :result => 'warning' }
7
+ { :state => ANY, :result => 'warning' },
8
8
  ].freeze
9
9
  def is_erroneous(task)
10
10
  remainder = ERRONEOUS_STATUSES.select do |status|
@@ -75,7 +75,7 @@ module ForemanTasks
75
75
  def delay_options
76
76
  {
77
77
  :start_at => start_at.utc,
78
- :start_before => start_before.try(:utc)
78
+ :start_before => start_before.try(:utc),
79
79
  }
80
80
  end
81
81
 
@@ -1,23 +1,23 @@
1
1
  class Setting::ForemanTasks < Setting
2
2
  def self.default_settings
3
3
  [
4
- set('foreman_tasks_sync_task_timeout', N_('Number of seconds to wait for synchronous task to finish.'), 120),
5
- set('dynflow_enable_console', N_('Enable the dynflow console (/foreman_tasks/dynflow) for debugging'), true),
6
- set('dynflow_console_require_auth', N_('Require user to be authenticated as user with admin rights when accessing dynflow console'), true),
7
- set('foreman_tasks_proxy_action_retry_count', N_('Number of attempts to start a task on the smart proxy before failing'), 4),
8
- set('foreman_tasks_proxy_action_retry_interval', N_('Time in seconds between retries'), 15),
9
- set('foreman_tasks_proxy_batch_trigger', N_('Allow triggering tasks on the smart proxy in batches'), true),
10
- set('foreman_tasks_proxy_batch_size', N_('Number of tasks which should be sent to the smart proxy in one request, if foreman_tasks_proxy_batch_trigger is enabled'), 100),
4
+ set('foreman_tasks_sync_task_timeout', N_('Number of seconds to wait for synchronous task to finish.'), 120, N_('Sync task timeout')),
5
+ set('dynflow_enable_console', N_('Enable the dynflow console (/foreman_tasks/dynflow) for debugging'), true, N_('Enable dynflow console')),
6
+ set('dynflow_console_require_auth', N_('Require user to be authenticated as user with admin rights when accessing dynflow console'), true, N_('Require auth for dynflow console')),
7
+ set('foreman_tasks_proxy_action_retry_count', N_('Number of attempts to start a task on the smart proxy before failing'), 4, N_('Proxy action retry count')),
8
+ set('foreman_tasks_proxy_action_retry_interval', N_('Time in seconds between retries'), 15, N_('Proxy action retry interval')),
9
+ set('foreman_tasks_proxy_batch_trigger', N_('Allow triggering tasks on the smart proxy in batches'), true, N_('Allow proxy batch tasks')),
10
+ set('foreman_tasks_proxy_batch_size', N_('Number of tasks which should be sent to the smart proxy in one request, if foreman_tasks_proxy_batch_trigger is enabled'), 100, N_('Proxy tasks batch size')),
11
11
  set('foreman_tasks_troubleshooting_url',
12
12
  N_('Url pointing to the task troubleshooting documentation. '\
13
13
  'It should contain %{label} placeholder, that will be replaced with normalized task label '\
14
14
  '(restricted to only alphanumeric characters)). %{version} placeholder is also available.'),
15
- nil),
15
+ nil, N_('Tasks troubleshooting URL')),
16
16
  set('foreman_tasks_polling_multiplier',
17
17
  N_('Polling multiplier which is used to multiply the default polling intervals. '\
18
18
  'This can be used to prevent polling too frequently for long running tasks.'),
19
19
  1,
20
- N_("Polling intervals multiplier"))
20
+ N_("Polling intervals multiplier")),
21
21
  ]
22
22
  end
23
23
 
@@ -24,7 +24,11 @@ module ForemanTasks
24
24
  private
25
25
 
26
26
  def scope_by(field)
27
- @new_scope = @new_scope.where(field => @params[field]) if @params[field].present?
27
+ if (field == :result) && (@params[field] == 'other')
28
+ @new_scope = @new_scope.where(:result => ['cancelled', 'pending'])
29
+ elsif @params[field].present?
30
+ @new_scope = @new_scope.where(field => @params[field])
31
+ end
28
32
  end
29
33
 
30
34
  def scope_by_time
@@ -0,0 +1,2 @@
1
+ collection @tasks
2
+ extends "foreman_tasks/api/tasks/show"
@@ -9,7 +9,6 @@
9
9
  <%= notifications %>
10
10
  <div id="organization-id" data-id="<%= Organization.current.id if Organization.current %>" ></div>
11
11
  <div id="user-id" data-id="<%= User.current.id if User.current %>" ></div>
12
- <div id="foremanTasksReactRoot"></div>
12
+ <%= react_component('ForemanTasks') %>
13
13
  <% end %>
14
14
  <%= render file: "layouts/base" %>
15
- <%= mount_react_component('ForemanTasks', '#foremanTasksReactRoot') %>
@@ -37,6 +37,7 @@
37
37
 
38
38
  <table class="<%= table_css_classes('table-condensed table-fixed') %>">
39
39
  <thead>
40
+ <th class="col-md-1"><%= N_("ID") %></th>
40
41
  <th><%= N_("Cron line") %></th>
41
42
  <th><%= N_("Task count") %></th>
42
43
  <th><%= N_("Action") %></th>
@@ -50,7 +51,8 @@
50
51
  </thead>
51
52
  <% @recurring_logics.each do |recurring_logic| %>
52
53
  <tr>
53
- <td><%= link_to(recurring_logic.cron_line, foreman_tasks_recurring_logic_path(recurring_logic)) %></td>
54
+ <td><%= link_to(recurring_logic.id, foreman_tasks_recurring_logic_path(recurring_logic)) %></td>
55
+ <td><%= recurring_logic.cron_line %></td>
54
56
  <td><%= link_to(recurring_logic.tasks.count, foreman_tasks_tasks_url(:search => "task_group.id = #{recurring_logic.task_group.id}")) %></td>
55
57
  <td><%= format_task_input(recurring_logic.tasks.first) %></td>
56
58
  <td><%= recurring_logic.tasks.order(:started_at).where('started_at IS NOT NULL').last.try(:started_at) || "-" %></td>
@@ -11,7 +11,7 @@
11
11
  <td class="ellipsis"><%= link_to task.humanized[:action], defined?(main_app) ? main_app.foreman_tasks_task_path(task.id) : foreman_tasks_task_path(task.id) %></td>
12
12
  <td><%= task.state %></td>
13
13
  <td><%= task.result %></td>
14
- <td><%= task.started_at ? (_(date_time_relative(task.started_at))) : _('N/A') %></td>
14
+ <td><%= task.started_at ? date_time_relative(task.started_at) : _('N/A') %></td>
15
15
  </tr>
16
16
  <% end %>
17
17
  </table>
@@ -11,7 +11,7 @@
11
11
  <td><%= result.state %></td>
12
12
  <td><%= result.result %></td>
13
13
  <td><%= link_to result.count, main_app.foreman_tasks_tasks_path(:search => "state=#{result.state}&result=#{result.result}") %></td>
14
- <td><%= result.started_at ? (_(date_time_relative(result.started_at))) : _('N/A') %></td>
14
+ <td><%= result.started_at ? date_time_relative(result.started_at) : _('N/A') %></td>
15
15
  </tr>
16
16
  <% end %>
17
17
  </table>
@@ -15,9 +15,4 @@
15
15
  switcher_item_url: foreman_tasks_task_path(:id => ':id')
16
16
  ) %>
17
17
 
18
-
19
- <div class="task-details" id="foremanTaskDetails">
20
- </div>
21
-
22
-
23
- <%= mount_react_component('TaskDetails', '#foremanTaskDetails') %>
18
+ <%= react_component('TaskDetails') %>
data/config/routes.rb CHANGED
@@ -7,6 +7,7 @@ Foreman::Application.routes.draw do
7
7
  put :disable
8
8
  end
9
9
  collection do
10
+ get 'auto_complete_search'
10
11
  post :clear_cancelled
11
12
  end
12
13
  end
@@ -50,7 +51,6 @@ Foreman::Application.routes.draw do
50
51
  resources :tasks, :only => [:show, :index] do
51
52
  member do
52
53
  get :details
53
- get :sub_tasks
54
54
  end
55
55
  collection do
56
56
  post :bulk_search
@@ -58,6 +58,7 @@ Foreman::Application.routes.draw do
58
58
  post :bulk_cancel
59
59
  post :bulk_stop
60
60
  get :summary
61
+ get '/:parent_task_id/sub_tasks', action: 'index'
61
62
  get '/summary/:id/sub_tasks/', action: 'summary_sub_tasks'
62
63
  post :callback
63
64
  end
@@ -3,7 +3,7 @@ class RenameBookmarksController < ActiveRecord::Migration[5.2]
3
3
  original_controller = 'foreman_tasks_tasks'
4
4
  original_bookmarks = Bookmark.where(controller: original_controller)
5
5
  original_bookmarks_names = Hash[original_bookmarks.pluck(:name, :id)]
6
-
6
+
7
7
  new_controller = 'foreman_tasks/tasks'
8
8
  new_bookmarks = Bookmark.where(controller: new_controller)
9
9
  new_bookmarks.find_each do |new_bookmark|
@@ -18,7 +18,7 @@ class RenameBookmarksController < ActiveRecord::Migration[5.2]
18
18
  original_bookmark.public == new_bookmark.public
19
19
 
20
20
  if is_duplicated
21
- original_bookmark.destroy
21
+ original_bookmark.destroy
22
22
  else
23
23
  modified_name = "#{name}_#{generate_token}"
24
24
  original_bookmark.update(name: modified_name)
@@ -9,9 +9,9 @@ blueprints = [
9
9
  links:
10
10
  [
11
11
  href: "/foreman_tasks/tasks?search=#{CGI.escape('state=paused')}",
12
- title: N_('List of tasks')
13
- ]
14
- }
12
+ title: N_('List of tasks'),
13
+ ],
14
+ },
15
15
  },
16
16
 
17
17
  {
@@ -24,9 +24,9 @@ blueprints = [
24
24
  links:
25
25
  [
26
26
  path_method: :foreman_tasks_task_path,
27
- title: N_('Task Details')
28
- ]
29
- }
27
+ title: N_('Task Details'),
28
+ ],
29
+ },
30
30
  },
31
31
 
32
32
  {
@@ -48,7 +48,7 @@ blueprints = [
48
48
  name: 'tasks_bulk_stop',
49
49
  level: 'info',
50
50
  message: "DYNAMIC",
51
- }
51
+ },
52
52
  ]
53
53
 
54
54
  blueprints.each { |blueprint| UINotifications::Seed.new(blueprint).configure }
@@ -1,7 +1,7 @@
1
1
  Bookmark.without_auditing do
2
2
  [
3
3
  { :name => 'running', :query => 'state = running' },
4
- { :name => 'failed', :query => 'state = paused or result = error or result = warning' }
4
+ { :name => 'failed', :query => 'state = paused or result = error or result = warning' },
5
5
 
6
6
  ].each do |item|
7
7
  next if Bookmark.where(:name => item[:name]).first
@@ -7,6 +7,7 @@ require "foreman_tasks/version"
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "foreman-tasks"
9
9
  s.version = ForemanTasks::VERSION
10
+ s.license = 'GPL-3.0'
10
11
  s.authors = ["Ivan Nečas"]
11
12
  s.email = ["inecas@redhat.com"]
12
13
  s.homepage = "https://github.com/theforeman/foreman-tasks"
@@ -30,12 +30,10 @@ module ForemanTasks
30
30
  actions_with_periods = {}
31
31
  if cleanup_settings[:actions]
32
32
  cleanup_settings[:actions].each do |action|
33
- begin
34
- action_class = action[:name].constantize
35
- actions_with_periods[action_class] = action[:after]
36
- rescue => e
37
- Foreman::Logging.exception("Error handling #{action} cleanup settings", e)
38
- end
33
+ action_class = action[:name].constantize
34
+ actions_with_periods[action_class] = action[:after]
35
+ rescue => e
36
+ Foreman::Logging.exception("Error handling #{action} cleanup settings", e)
39
37
  end
40
38
  end
41
39
  (ForemanTasks.dynflow.world.action_classes - actions_with_periods.keys).each do |action_class|
@@ -15,7 +15,7 @@ module ForemanTasks
15
15
  return @backup_settings if @backup_settings
16
16
  backup_options = {
17
17
  :backup_deleted_plans => true,
18
- :backup_dir => default_backup_dir
18
+ :backup_dir => default_backup_dir,
19
19
  }
20
20
  settings = SETTINGS[:'foreman-tasks'] && SETTINGS[:'foreman-tasks'][:backup]
21
21
  backup_options.merge!(settings) if settings
@@ -8,12 +8,10 @@ module ForemanTasks
8
8
  # clear connection only if not running in some active record transaction already
9
9
  clear_connections = ActiveRecord::Base.connection.open_transactions.zero?
10
10
  super.tap do
11
- begin
12
- on_execution_plan_save(execution_plan_id, value)
13
- rescue => e
14
- Foreman::Logging.exception('Error on on_execution_plan_save event', e,
15
- :logger => 'dynflow')
16
- end
11
+ on_execution_plan_save(execution_plan_id, value)
12
+ rescue => e
13
+ Foreman::Logging.exception('Error on on_execution_plan_save event', e,
14
+ :logger => 'dynflow')
17
15
  end
18
16
  ensure
19
17
  ::ActiveRecord::Base.clear_active_connections! if clear_connections