foreman-tasks 0.17.6 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/.eslintrc +2 -22
  3. data/.rubocop.yml +12 -12
  4. data/.rubocop_todo.yml +34 -116
  5. data/.travis.yml +2 -2
  6. data/app/controllers/foreman_tasks/api/recurring_logics_controller.rb +20 -1
  7. data/app/controllers/foreman_tasks/api/tasks_controller.rb +66 -11
  8. data/app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb +1 -1
  9. data/app/controllers/foreman_tasks/recurring_logics_controller.rb +19 -0
  10. data/app/controllers/foreman_tasks/tasks_controller.rb +3 -11
  11. data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +0 -2
  12. data/app/lib/actions/helpers/humanizer.rb +1 -3
  13. data/app/lib/actions/proxy_action.rb +33 -12
  14. data/app/lib/foreman_tasks/concerns/polling_action_extensions.rb +12 -0
  15. data/app/models/foreman_tasks/concerns/action_triggering.rb +1 -1
  16. data/app/models/foreman_tasks/recurring_logic.rb +1 -0
  17. data/app/models/foreman_tasks/remote_task.rb +1 -0
  18. data/app/models/foreman_tasks/task.rb +8 -0
  19. data/app/models/foreman_tasks/task/dynflow_task.rb +1 -1
  20. data/app/models/foreman_tasks/task/search.rb +11 -1
  21. data/app/models/setting/foreman_tasks.rb +7 -2
  22. data/app/services/ui_notifications/tasks/task_bulk_cancel.rb +36 -0
  23. data/app/services/ui_notifications/tasks/task_bulk_resume.rb +38 -0
  24. data/app/services/ui_notifications/tasks/task_bulk_stop.rb +36 -0
  25. data/app/views/foreman_tasks/api/recurring_logics/base.json.rabl +2 -1
  26. data/app/views/foreman_tasks/api/tasks/details.json.rabl +1 -1
  27. data/app/views/foreman_tasks/api/tasks/show.json.rabl +1 -1
  28. data/app/views/foreman_tasks/recurring_logics/index.html.erb +30 -0
  29. data/app/views/foreman_tasks/tasks/show.html.erb +3 -0
  30. data/babel.config.js +3 -0
  31. data/config/routes.rb +8 -0
  32. data/db/migrate/20200517215015_rename_bookmarks_controller.rb +35 -0
  33. data/db/migrate/20200519093217_drop_dynflow_allow_dangerous_actions_setting.foreman_tasks.rb +5 -0
  34. data/db/seeds.d/30-notification_blueprints.rb +21 -0
  35. data/foreman-tasks.gemspec +5 -6
  36. data/gemfile.d/foreman-tasks.rb +1 -0
  37. data/lib/foreman_tasks/dynflow/console_authorizer.rb +2 -2
  38. data/lib/foreman_tasks/engine.rb +17 -14
  39. data/lib/foreman_tasks/tasks/cleanup.rake +1 -1
  40. data/lib/foreman_tasks/tasks/export_tasks.rake +2 -2
  41. data/lib/foreman_tasks/test_extensions.rb +1 -1
  42. data/lib/foreman_tasks/version.rb +1 -1
  43. data/locale/action_names.rb +2 -2
  44. data/locale/en/foreman_tasks.po +227 -41
  45. data/locale/foreman_tasks.pot +579 -288
  46. data/package.json +19 -79
  47. data/script/rails +2 -2
  48. data/script/travis_run_js_tests.sh +2 -2
  49. data/test/controllers/api/tasks_controller_test.rb +9 -0
  50. data/test/factories/task_factory.rb +34 -2
  51. data/test/foreman_tasks_test_helper.rb +4 -0
  52. data/test/lib/concerns/polling_action_extensions_test.rb +34 -0
  53. data/test/unit/actions/action_with_sub_plans_test.rb +1 -1
  54. data/test/unit/task_test.rb +160 -74
  55. data/webpack/ForemanTasks/Components/TaskActions/TaskAction.test.js +60 -0
  56. data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.js +67 -0
  57. data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.test.js +46 -0
  58. data/webpack/ForemanTasks/Components/TaskActions/TaskActionsConstants.js +16 -0
  59. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.js +60 -0
  60. data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.test.js +14 -0
  61. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/TaskAction.test.js.snap +233 -0
  62. data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/UnlockModals.test.js.snap +25 -0
  63. data/webpack/ForemanTasks/Components/TaskActions/index.js +115 -0
  64. data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +132 -150
  65. data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +1 -4
  66. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Errors.test.js +1 -1
  67. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Locks.test.js +1 -1
  68. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Raw.test.js +1 -1
  69. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +1 -1
  70. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +68 -3
  71. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskInfo.test.js +1 -2
  72. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +104 -71
  73. data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +9 -15
  74. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.stories.js +6 -2
  75. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +2 -17
  76. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +0 -5
  77. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -6
  78. data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +3 -9
  79. data/webpack/ForemanTasks/Components/TaskDetails/TasksDetailsHelper.js +6 -1
  80. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +6 -1
  81. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +1 -1
  82. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +1 -1
  83. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +3 -7
  84. data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +5 -1
  85. data/webpack/ForemanTasks/Components/TaskDetails/index.js +6 -8
  86. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.stories.js +44 -40
  87. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/PausedTasksCard/PausedTasksCard.test.js +1 -1
  88. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.stories.js +45 -40
  89. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/RunningTasksCard/RunningTasksCard.test.js +1 -1
  90. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.stories.js +27 -22
  91. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.test.js +1 -1
  92. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.stories.js +61 -56
  93. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +1 -1
  94. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.stories.js +40 -35
  95. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutCard/TasksDonutCard.test.js +1 -1
  96. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.stories.js +21 -20
  97. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/TasksDonutChart/TasksDonutChart.test.js +1 -1
  98. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.stories.js +40 -39
  99. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/TasksCardsGrid.test.js +1 -1
  100. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.stories.js +16 -17
  101. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js +1 -2
  102. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.mdx +57 -0
  103. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.test.js +1 -1
  104. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.stories.js +36 -18
  105. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.test.js +1 -1
  106. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +5 -0
  107. data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardHelper.js +3 -2
  108. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboard.test.js +1 -1
  109. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +1 -1
  110. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardReducer.test.js +1 -1
  111. data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test.js +1 -1
  112. data/webpack/ForemanTasks/Components/TasksTable/Components/ActionSelectButton.js +14 -1
  113. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModal.js +83 -0
  114. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js +106 -0
  115. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js +38 -0
  116. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +45 -0
  117. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModal.test.js +36 -0
  118. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalActions.test.js +205 -0
  119. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalReducer.test.js +27 -0
  120. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +54 -0
  121. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModal.test.js.snap +41 -0
  122. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalReducer.test.js.snap +19 -0
  123. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +30 -0
  124. data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js +29 -0
  125. data/webpack/ForemanTasks/Components/TasksTable/Components/SelectAllAlert.js +43 -0
  126. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +2 -1
  127. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/SelectAllAlert.test.js +29 -0
  128. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionCell.test.js +1 -1
  129. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/TableSelectionHeaderCell.test.js +1 -1
  130. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionSelectButton.test.js.snap +11 -0
  131. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/SelectAllAlert.test.js.snap +75 -0
  132. data/webpack/ForemanTasks/Components/TasksTable/SubTasksPage.js +4 -1
  133. data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +247 -0
  134. data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +50 -22
  135. data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +62 -101
  136. data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +18 -5
  137. data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +4 -3
  138. data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +65 -38
  139. data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +26 -9
  140. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSchema.js +2 -2
  141. data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +27 -16
  142. data/webpack/ForemanTasks/Components/TasksTable/__tests__/SubTasksPage.test.js +1 -1
  143. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +147 -0
  144. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksIndexPage.test.js +1 -1
  145. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +4 -7
  146. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.test.js +1 -1
  147. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +46 -74
  148. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js +17 -1
  149. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +10 -2
  150. data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableReducer.test.js +28 -8
  151. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +5 -7
  152. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +336 -0
  153. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +4 -7
  154. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +22 -158
  155. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +66 -44
  156. data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableReducer.test.js.snap +43 -16
  157. data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionHeaderCellFormatter.test.js +1 -1
  158. data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionHeaderCellFormatter.js +2 -2
  159. data/webpack/ForemanTasks/Components/TasksTable/index.js +11 -4
  160. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +49 -21
  161. data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +61 -14
  162. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +80 -21
  163. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.scss +9 -0
  164. data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.test.js +44 -0
  165. data/webpack/ForemanTasks/Components/common/ClickConfirmation/__snapshots__/ClickConfirmation.test.js.snap +52 -0
  166. data/webpack/ForemanTasks/Components/common/ClickConfirmation/index.js +59 -66
  167. data/webpack/ForemanTasks/Components/common/ToastsHelpers/ToastTypesConstants.js +11 -0
  168. data/webpack/ForemanTasks/Components/common/ToastsHelpers/index.js +15 -0
  169. data/webpack/ForemanTasks/ForemanTasks.test.js +1 -1
  170. data/webpack/ForemanTasks/ForemanTasksReducers.js +2 -0
  171. data/webpack/ForemanTasks/Routes/ForemanTasksRouter.test.js +1 -1
  172. data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +4 -4
  173. data/webpack/ForemanTasks/Routes/ShowTask/__tests__/ShowTask.test.js +1 -1
  174. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalActions.js +2 -0
  175. data/webpack/__mocks__/foremanReact/components/ForemanModal/ForemanModalHooks.js +10 -0
  176. data/webpack/__mocks__/foremanReact/components/ForemanModal/index.js +18 -0
  177. data/webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js +3 -0
  178. metadata +71 -30
  179. data/.babelrc +0 -35
  180. data/.storybook/addons.js +0 -2
  181. data/.storybook/config.js +0 -7
  182. data/.storybook/webpack.config.js +0 -63
  183. data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.js +0 -23
  184. data/webpack/ForemanTasks/Components/TasksTable/Components/ActionConfirmation.js +0 -49
  185. data/webpack/ForemanTasks/Components/TasksTable/Components/CancelResumeConfirm.js +0 -51
  186. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionConfirmation.test.js +0 -18
  187. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelResumeConfirm.test.js +0 -28
  188. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionConfirmation.test.js.snap +0 -89
  189. data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelResumeConfirm.test.js.snap +0 -37
  190. data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.js +0 -23
  191. data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.test.js +0 -27
  192. data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.js +0 -23
  193. data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.test.js +0 -27
  194. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/CancelButton.test.js.snap +0 -15
  195. data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ResumeButton.test.js.snap +0 -15
  196. data/webpack/stories/index.js +0 -10
  197. data/webpack/stories/index.scss +0 -7
  198. data/webpack/test_setup.js +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b4e3250fe2916ec688e6f9c00499f89b5bebe513ddbd783850a3fe7e9c990f7
4
- data.tar.gz: bcbd6c4b489aab5f9a166b5ba48cac75849746d13f5f9f40d425dae792db3629
3
+ metadata.gz: b64fbe722db23184eb2bc9db457a71ed09402fc404bed3aa0448c0f30deff8f7
4
+ data.tar.gz: 39afeebd07ee4012eb1bd9435d5d72400ef56582bb29a6f097c7f1b440cbaedc
5
5
  SHA512:
6
- metadata.gz: a7c6f1a0aefbc547a84c10ff6e64c96631de2a9056638084184c423274dfeaed77924f58b827c4fea8b1a53b19d12e049ce85d8d79489700b2aaa3c339942e42
7
- data.tar.gz: 3741f57f5fc0b34109f254afda46ccadcb80e46ab4e828ce185ecfd4c1f6952d2fae114314e5a1a3207759f0cbac03797cc59ef093a054249120b8ba5bc23563
6
+ metadata.gz: 03a87fdc09be2d0a66995b2ee1abcf053c16c179d616a1b7bb680c15241aa5c58485512fdfa6452e8aba1dec7016bca350ad291709c967a4e8ad8ae917e120aa
7
+ data.tar.gz: 3ae631a58bb8de68e6a8b4dac32cbf143204f99476701464a7eda552f60bd1fa93518226eaae0b6da9e18d14bfd83c5d14c3484e6a527bf26b1c4e0228ad5458
data/.eslintrc CHANGED
@@ -1,24 +1,4 @@
1
1
  {
2
- "plugins": ["patternfly-react"],
3
- "extends": [
4
- "plugin:patternfly-react/recommended",
5
- "./node_modules/@theforeman/vendor-dev/eslint.extends.js"
6
- ],
7
- "rules": {
8
- "prettier/prettier": ["error", {
9
- "singleQuote": true,
10
- "trailingComma": "es5"
11
- }],
12
- "import/no-unresolved": ["error", {
13
- "ignore": ['foremanReact/.*']
14
- }],
15
- "import/extensions": ["error", {
16
- "ignore": ['foremanReact/.*']
17
- }]
18
- },
19
- "settings": {
20
- "import/resolver": {
21
- "babel-module": {}
22
- }
23
- }
2
+ "plugins": ["@theforeman/foreman"],
3
+ "extends": ["plugin:@theforeman/foreman/core", "plugin:@theforeman/foreman/plugins"]
24
4
  }
@@ -1,8 +1,9 @@
1
- require: rubocop-rails
1
+ require:
2
+ - rubocop-minitest
3
+ - rubocop-performance
4
+ - rubocop-rails
2
5
 
3
- # TODO: remove this file by either moving cops here or fixing code
4
- inherit_from:
5
- - .rubocop_todo.yml
6
+ inherit_from: .rubocop_todo.yml
6
7
 
7
8
  AllCops:
8
9
  Include:
@@ -55,12 +56,11 @@ Rails/FilePath:
55
56
  Rails/ReversibleMigration:
56
57
  Enabled: false
57
58
 
58
- Metrics/BlockLength:
59
- Exclude:
60
- - config/routes.rb
61
- - lib/foreman_tasks/engine.rb
62
- - test/**/*
63
- - lib/foreman_tasks/tasks/**/*
59
+ Metrics:
60
+ Enabled: false
61
+
62
+ Layout/LineLength:
63
+ Enabled: false
64
64
 
65
65
  Naming/FileName:
66
66
  Exclude:
@@ -69,7 +69,7 @@ Naming/FileName:
69
69
  - db/seeds.d/*
70
70
  - lib/foreman-tasks.rb
71
71
 
72
- Layout/IndentHeredoc:
72
+ Layout/HeredocIndentation:
73
73
  Exclude:
74
74
  - '*.gemspec'
75
75
  - bin/*
@@ -101,7 +101,7 @@ Style/FormatStringToken:
101
101
  Style/RegexpLiteral:
102
102
  Enabled: false
103
103
 
104
- Layout/AlignHash:
104
+ Layout/HashAlignment:
105
105
  Enabled: false
106
106
 
107
107
  Metrics/ClassLength:
@@ -1,113 +1,49 @@
1
- # This configuration was generated by
2
- # `rubocop --auto-gen-config`
3
- # on 2018-04-02 18:15:37 +0200 using RuboCop version 0.54.0.
4
- # The point is for the user to remove these configuration records
5
- # one by one as the offenses are removed from the code base.
6
- # Note that changes in the inspected code, or installation of new
7
- # versions of RuboCop, may require this file to be generated again.
8
-
9
- # Offense count: 3
10
- # Cop supports --auto-correct.
11
- # Configuration parameters: Include, TreatCommentsAsGroupSeparators.
12
- # Include: **/*.gemspec
13
- Gemspec/OrderedDependencies:
14
- Exclude:
15
- - 'foreman-tasks.gemspec'
16
-
17
- # Offense count: 1
18
- # Cop supports --auto-correct.
19
- # Configuration parameters: EnforcedStyle.
20
- # SupportedStyles: final_newline, final_blank_line
21
- Layout/TrailingBlankLines:
22
- Exclude:
23
- - 'locale/action_names.rb'
24
-
25
1
  # Offense count: 1
26
2
  Lint/EmptyWhen:
27
3
  Exclude:
28
4
  - 'app/lib/actions/proxy_action.rb'
29
5
 
30
- # Offense count: 2
6
+ # Offense count: 1
31
7
  Lint/UselessAssignment:
32
8
  Exclude:
33
9
  - 'lib/foreman_tasks/tasks/export_tasks.rake'
34
10
 
35
- # Offense count: 32
36
- Metrics/AbcSize:
37
- Max: 41
38
-
39
- # Offense count: 2
40
- # Configuration parameters: CountComments, ExcludedMethods.
41
- Metrics/BlockLength:
42
- Max: 32
43
-
44
- # Offense count: 13
45
- # Configuration parameters: CountComments.
46
- Metrics/ClassLength:
47
- Max: 230
48
-
49
- # Offense count: 9
50
- Metrics/CyclomaticComplexity:
51
- Max: 9
52
-
53
- # Offense count: 482
54
- # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
55
- # URISchemes: http, https
56
- Metrics/LineLength:
57
- Max: 211
58
-
59
- # Offense count: 54
60
- # Configuration parameters: CountComments.
61
- Metrics/MethodLength:
62
- Max: 29
63
-
64
- # Offense count: 2
65
- # Configuration parameters: CountComments.
66
- Metrics/ModuleLength:
67
- Max: 167
11
+ Minitest/AssertEmpty:
12
+ Enabled: false
68
13
 
69
- # Offense count: 1
70
- # Configuration parameters: CountKeywordArgs.
71
- Metrics/ParameterLists:
72
- Max: 6
14
+ Minitest/AssertEqual:
15
+ Enabled: false
73
16
 
74
- # Offense count: 4
75
- Metrics/PerceivedComplexity:
76
- Max: 9
17
+ Minitest/GlobalExpectations:
18
+ Enabled: false
77
19
 
78
20
  # Offense count: 3
21
+ # Configuration parameters: EnforcedStyleForLeadingUnderscores.
22
+ # SupportedStylesForLeadingUnderscores: disallowed, required, optional
79
23
  Naming/MemoizedInstanceVariableName:
80
24
  Exclude:
81
25
  - 'app/controllers/foreman_tasks/recurring_logics_controller.rb'
82
26
  - 'app/lib/actions/recurring_action.rb'
83
27
  - 'lib/foreman_tasks_core/otp_manager.rb'
84
28
 
29
+ # Offense count: 11
30
+ # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
31
+ # AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp
32
+ Naming/MethodParameterName:
33
+ Exclude:
34
+ - 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
35
+
85
36
  # Offense count: 1
86
- # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros.
37
+ # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
87
38
  # NamePrefix: is_, has_, have_
88
- # NamePrefixBlacklist: is_, has_, have_
89
- # NameWhitelist: is_a?
39
+ # ForbiddenPrefixes: is_, has_, have_
40
+ # AllowedMethods: is_a?
90
41
  # MethodDefinitionMacros: define_method, define_singleton_method
91
42
  Naming/PredicateName:
92
43
  Exclude:
93
44
  - 'spec/**/*'
94
45
  - 'app/models/foreman_tasks/task/status_explicator.rb'
95
46
 
96
- # Offense count: 12
97
- # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
98
- # AllowedNames: io, id, to
99
- Naming/UncommunicativeMethodParamName:
100
- Exclude:
101
- - 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
102
- - 'app/models/foreman_tasks/recurring_logic.rb'
103
-
104
- # Offense count: 3
105
- # Cop supports --auto-correct.
106
- Rails/ActiveRecordAliases:
107
- Exclude:
108
- - 'app/models/foreman_tasks/task/dynflow_task.rb'
109
- - 'test/factories/task_factory.rb'
110
-
111
47
  # Offense count: 6
112
48
  # Configuration parameters: Include.
113
49
  # Include: db/migrate/*.rb
@@ -119,14 +55,6 @@ Rails/CreateTableWithTimestamps:
119
55
  - 'db/migrate/20150907131503_create_task_groups.rb'
120
56
  - 'db/migrate/20151112152108_create_triggerings.rb'
121
57
 
122
- # Offense count: 1
123
- # Cop supports --auto-correct.
124
- # Configuration parameters: EnforcedStyle.
125
- # SupportedStyles: numeric, symbolic
126
- Rails/HttpStatus:
127
- Exclude:
128
- - 'app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb'
129
-
130
58
  # Offense count: 1
131
59
  # Configuration parameters: Include.
132
60
  # Include: app/**/*.rb, config/**/*.rb, db/**/*.rb, lib/**/*.rb
@@ -139,7 +67,14 @@ Rails/OutputSafety:
139
67
  Exclude:
140
68
  - 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
141
69
 
142
- # Offense count: 11
70
+ # Offense count: 1
71
+ # Configuration parameters: Include.
72
+ # Include: **/Rakefile, **/*.rake
73
+ Rails/RakeEnvironment:
74
+ Exclude:
75
+ - 'lib/foreman_tasks/tasks/test.rake'
76
+
77
+ # Offense count: 12
143
78
  # Cop supports --auto-correct.
144
79
  # Configuration parameters: AutoCorrect, EnforcedStyle.
145
80
  # SupportedStyles: nested, compact
@@ -163,33 +98,16 @@ Style/DoubleNegation:
163
98
  - 'app/models/foreman_tasks/lock.rb'
164
99
  - 'app/models/foreman_tasks/recurring_logic.rb'
165
100
 
166
- # Offense count: 2
167
- # Cop supports --auto-correct.
168
- Style/Encoding:
169
- Exclude:
170
- - 'foreman-tasks-core.gemspec'
171
- - 'foreman-tasks.gemspec'
172
-
173
- # Offense count: 6
174
- # Cop supports --auto-correct.
175
- Style/ExpandPathArguments:
176
- Exclude:
177
- - 'foreman-tasks-core.gemspec'
178
- - 'foreman-tasks.gemspec'
179
- - 'lib/foreman_tasks/engine.rb'
180
- - 'script/rails'
181
-
182
- # Offense count: 32
101
+ # Offense count: 36
183
102
  # Configuration parameters: MinBodyLength.
184
103
  Style/GuardClause:
185
104
  Enabled: false
186
105
 
187
- # Offense count: 1
188
- # Cop supports --auto-correct.
189
- # Configuration parameters: AllowMultipleReturnValues.
190
- Style/RedundantReturn:
191
- Exclude:
192
- - 'app/models/foreman_tasks/concerns/action_triggering.rb'
106
+ Style/HashEachMethods:
107
+ Enabled: false
108
+
109
+ Style/HashTransformKeys:
110
+ Enabled: false
193
111
 
194
- Lint/SendWithMixinArgument:
112
+ Style/HashTransformValues:
195
113
  Enabled: false
@@ -1,5 +1,5 @@
1
1
  language: node_js
2
2
  node_js:
3
- - '8' # current LTS
4
- - '10' # future LTS
3
+ - '10'
4
+ - '12'
5
5
  script: ./script/travis_run_js_tests.sh
@@ -10,6 +10,12 @@ module ForemanTasks
10
10
  api_base_url '/foreman_tasks/api'
11
11
  end
12
12
 
13
+ # Foreman right now doesn't have mechanism to
14
+ # cause general BadRequest handling, resuing the Apipie::ParamError
15
+ # for now http://projects.theforeman.org/issues/3957
16
+ class BadRequest < Apipie::ParamError
17
+ end
18
+
13
19
  before_action :find_resource, :only => %w[show cancel update]
14
20
 
15
21
  api :GET, '/recurring_logics', N_('List recurring logics')
@@ -39,9 +45,22 @@ module ForemanTasks
39
45
  ForemanTasks::RecurringLogic
40
46
  end
41
47
 
48
+ api :POST, '/recurring_logics/bulk_destroy', N_('Delete recurring logics by search query')
49
+ param :search, String, :desc => N_('Search query'), :required => true
50
+ def bulk_destroy
51
+ if params[:search].blank?
52
+ raise BadRequest, _('Please provide a search parameter in the request')
53
+ end
54
+ scope = resource_scope.search_for(params[:search])
55
+ scope.each(&:destroy!)
56
+ render json: { destroyed: scope }
57
+ rescue ActiveRecord::RecordNotDestroyed => error
58
+ render json: { error: error, scope: scope }, status: :bad_request
59
+ end
60
+
42
61
  def action_permission
43
62
  case params[:action]
44
- when 'cancel'
63
+ when 'cancel', 'bulk_destroy'
45
64
  'edit'
46
65
  else
47
66
  super
@@ -89,19 +89,14 @@ module ForemanTasks
89
89
  param :search, String, :desc => N_('Resume tasks matching search string')
90
90
  param :task_ids, Array, :desc => N_('Resume specific tasks by ID')
91
91
  def bulk_resume
92
- scope = resource_scope
93
- scope = scope.search_for(params[:search]) if params[:search]
94
- scope = scope.select('DISTINCT foreman_tasks_tasks.*')
95
92
  if params[:search].nil? && params[:task_ids].nil?
96
- scope = scope.where(:state => :paused)
97
- scope = scope.where(:result => :error)
93
+ raise BadRequest, _('Please provide at least one of search or task_ids parameters in the request')
98
94
  end
99
- scope = scope.where(:id => params[:task_ids]) if params[:task_ids]
100
-
101
95
  resumed = []
102
96
  failed = []
103
97
  skipped = []
104
- scope.each do |task|
98
+ filtered_scope = bulk_scope
99
+ filtered_scope.each do |task|
105
100
  if task.resumable?
106
101
  begin
107
102
  ForemanTasks.dynflow.world.execute(task.execution_plan.id)
@@ -113,7 +108,10 @@ module ForemanTasks
113
108
  skipped << task_hash(task)
114
109
  end
115
110
  end
116
-
111
+ if params[:search]
112
+ notification = UINotifications::Tasks::TaskBulkResume.new(filtered_scope.first, resumed.length, failed.length, skipped.length)
113
+ notification.deliver!
114
+ end
117
115
  render :json => {
118
116
  total: resumed.length + failed.length + skipped.length,
119
117
  resumed: resumed,
@@ -122,6 +120,55 @@ module ForemanTasks
122
120
  }
123
121
  end
124
122
 
123
+ api :POST, '/tasks/bulk_cancel', N_('Cancel all cancellable tasks')
124
+ param :search, String, :desc => N_('Cancel tasks matching search string')
125
+ param :task_ids, Array, :desc => N_('Cancel specific tasks by ID')
126
+ def bulk_cancel
127
+ if params[:search].nil? && params[:task_ids].nil?
128
+ raise BadRequest, _('Please provide at least one of search or task_ids parameters in the request')
129
+ end
130
+ filtered_scope = bulk_scope
131
+ cancelled, skipped = filtered_scope.partition(&:cancellable?)
132
+ cancelled.each(&:cancel)
133
+ if params[:search]
134
+ notification = UINotifications::Tasks::TaskBulkCancel.new(filtered_scope.first, cancelled.length, skipped.length)
135
+ notification.deliver!
136
+ end
137
+ render :json => {
138
+ total: cancelled.length + skipped.length,
139
+ cancelled: cancelled,
140
+ skipped: skipped
141
+ }
142
+ end
143
+
144
+ api :POST, '/tasks/bulk_stop', N_('Stop all stoppable tasks')
145
+ param :search, String, :desc => N_('Stop tasks matching search string')
146
+ param :task_ids, Array, :desc => N_('Stop specific tasks by ID')
147
+ def bulk_stop
148
+ if params[:search].nil? && params[:task_ids].nil?
149
+ raise BadRequest, _('Please provide at least one of search or task_ids parameters in the request')
150
+ end
151
+
152
+ filtered_scope = bulk_scope
153
+ total_length = filtered_scope.count
154
+ to_stop = filtered_scope.where.not(state: :stopped)
155
+ to_stop_length = to_stop.count
156
+ skipped_length = total_length - to_stop_length
157
+
158
+ to_stop.find_each { |task| task.update(state: :stopped) }
159
+
160
+ if params[:search]
161
+ notification = UINotifications::Tasks::TaskBulkStop.new(filtered_scope.first, to_stop_length, skipped_length)
162
+ notification.deliver!
163
+ end
164
+
165
+ render :json => {
166
+ total: total_length,
167
+ stopped_length: to_stop_length,
168
+ skipped_length: skipped_length
169
+ }
170
+ end
171
+
125
172
  api :GET, '/tasks', N_('List tasks')
126
173
  param :search, String, :desc => N_('Search string')
127
174
  param :page, :number, :desc => N_('Page number, starting at 1')
@@ -240,7 +287,7 @@ module ForemanTasks
240
287
  sort_by = ordering_params[:sort_by] || 'started_at'
241
288
  sort_by = 'foreman_tasks_tasks.' + sort_by if sort_by == 'started_at'
242
289
  sort_order = ordering_params[:sort_order] || 'DESC'
243
- scope = scope.select("*, coalesce(ended_at, current_timestamp) - coalesce(coalesce(started_at, ended_at), current_timestamp) as duration")
290
+ scope = scope.select("foreman_tasks_tasks.*, coalesce(ended_at, current_timestamp) - coalesce(coalesce(started_at, ended_at), current_timestamp) as duration")
244
291
  scope.order("#{sort_by} #{sort_order}")
245
292
  end
246
293
 
@@ -272,7 +319,7 @@ module ForemanTasks
272
319
  case params[:action]
273
320
  when 'bulk_search', 'summary', 'details', 'sub_tasks'
274
321
  :view
275
- when 'bulk_resume'
322
+ when 'bulk_resume', 'bulk_cancel', 'bulk_stop'
276
323
  :edit
277
324
  else
278
325
  super
@@ -311,6 +358,14 @@ module ForemanTasks
311
358
  results: results
312
359
  }
313
360
  end
361
+
362
+ def bulk_scope
363
+ scope = resource_scope
364
+ scope = scope.search_for(params[:search]) if params[:search]
365
+ scope = scope.select('DISTINCT foreman_tasks_tasks.*')
366
+ scope = scope.where(:id => params[:task_ids]) if params[:task_ids]
367
+ scope
368
+ end
314
369
  end
315
370
  end
316
371
  end