foreman-tasks 1.0.0 → 1.1.3
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/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 +1 -3
- 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/foreman_tasks/troubleshooting_help_generator.rb +0 -4
- 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/{.babelrc.js → babel.config.js} +0 -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 +18 -71
- 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 +3 -12
- 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 +3 -9
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.stories.js +6 -2
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +4 -1
- 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 +23 -9
- 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 +158 -32
- 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/.storybook/addons.js +0 -2
- data/.storybook/config.js +0 -7
- data/.storybook/webpack.config.js +0 -84
- 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 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2763cf62835dc3d4375a83b6fdff446ef0f50b0229c732a0e6b17e681b45935b
|
4
|
+
data.tar.gz: 8845f763b8d400ed8e8dcf267798e4891234f7eada43ae3f38292409d0ca50fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7aba491ebd02b8361ea237d588b256c8d4e6bc8e7d1b0d30872acc6267fce59cbaa46695c20c4099c897081cde81ae363de22c69456a97ddbb059a0be83303df
|
7
|
+
data.tar.gz: fa79277831760d12364f69f7390664e391531e98451e50861ffc174210be91073deae4bcb697b0d8adc944bc7cc3a3e28b092812e0186da5782a6ac554bc6869
|
data/.eslintrc
CHANGED
@@ -1,24 +1,4 @@
|
|
1
1
|
{
|
2
|
-
"plugins": ["
|
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
|
}
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require:
|
1
|
+
require:
|
2
|
+
- rubocop-minitest
|
3
|
+
- rubocop-performance
|
4
|
+
- rubocop-rails
|
2
5
|
|
3
|
-
|
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
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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/
|
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/
|
104
|
+
Layout/HashAlignment:
|
105
105
|
Enabled: false
|
106
106
|
|
107
107
|
Metrics/ClassLength:
|
data/.rubocop_todo.yml
CHANGED
@@ -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:
|
6
|
+
# Offense count: 1
|
31
7
|
Lint/UselessAssignment:
|
32
8
|
Exclude:
|
33
9
|
- 'lib/foreman_tasks/tasks/export_tasks.rake'
|
34
10
|
|
35
|
-
|
36
|
-
|
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
|
-
|
70
|
-
|
71
|
-
Metrics/ParameterLists:
|
72
|
-
Max: 6
|
14
|
+
Minitest/AssertEqual:
|
15
|
+
Enabled: false
|
73
16
|
|
74
|
-
|
75
|
-
|
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,
|
37
|
+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros.
|
87
38
|
# NamePrefix: is_, has_, have_
|
88
|
-
#
|
89
|
-
#
|
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:
|
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:
|
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
|
-
|
188
|
-
|
189
|
-
|
190
|
-
Style/
|
191
|
-
|
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
|
-
|
112
|
+
Style/HashTransformValues:
|
195
113
|
Enabled: false
|
@@ -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
|
-
|
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
|
-
|
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,27 @@ 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
|
+
|
125
144
|
api :GET, '/tasks', N_('List tasks')
|
126
145
|
param :search, String, :desc => N_('Search string')
|
127
146
|
param :page, :number, :desc => N_('Page number, starting at 1')
|
@@ -240,7 +259,7 @@ module ForemanTasks
|
|
240
259
|
sort_by = ordering_params[:sort_by] || 'started_at'
|
241
260
|
sort_by = 'foreman_tasks_tasks.' + sort_by if sort_by == 'started_at'
|
242
261
|
sort_order = ordering_params[:sort_order] || 'DESC'
|
243
|
-
scope = scope.select("
|
262
|
+
scope = scope.select("foreman_tasks_tasks.*, coalesce(ended_at, current_timestamp) - coalesce(coalesce(started_at, ended_at), current_timestamp) as duration")
|
244
263
|
scope.order("#{sort_by} #{sort_order}")
|
245
264
|
end
|
246
265
|
|
@@ -272,7 +291,7 @@ module ForemanTasks
|
|
272
291
|
case params[:action]
|
273
292
|
when 'bulk_search', 'summary', 'details', 'sub_tasks'
|
274
293
|
:view
|
275
|
-
when 'bulk_resume'
|
294
|
+
when 'bulk_resume', 'bulk_cancel'
|
276
295
|
:edit
|
277
296
|
else
|
278
297
|
super
|
@@ -311,6 +330,14 @@ module ForemanTasks
|
|
311
330
|
results: results
|
312
331
|
}
|
313
332
|
end
|
333
|
+
|
334
|
+
def bulk_scope
|
335
|
+
scope = resource_scope
|
336
|
+
scope = scope.search_for(params[:search]) if params[:search]
|
337
|
+
scope = scope.select('DISTINCT foreman_tasks_tasks.*')
|
338
|
+
scope = scope.where(:id => params[:task_ids]) if params[:task_ids]
|
339
|
+
scope
|
340
|
+
end
|
314
341
|
end
|
315
342
|
end
|
316
343
|
end
|
@@ -9,7 +9,7 @@ module ForemanTasks
|
|
9
9
|
params[:certname],
|
10
10
|
detected_proxy.try(:id))
|
11
11
|
|
12
|
-
render :json => { :task_id => task.id }, :status =>
|
12
|
+
render :json => { :task_id => task.id }, :status => :accepted
|
13
13
|
rescue ::Foreman::Exception => e
|
14
14
|
render :json => { 'message' => e.to_s }, :status => :unprocessable_entity
|
15
15
|
end
|
@@ -22,6 +22,12 @@ module ForemanTasks
|
|
22
22
|
redirect_to :action => :index
|
23
23
|
end
|
24
24
|
|
25
|
+
def clear_cancelled
|
26
|
+
scope = resource_base.search_for('state=cancelled')
|
27
|
+
scope.destroy_all
|
28
|
+
redirect_to :action => :index
|
29
|
+
end
|
30
|
+
|
25
31
|
def controller_name
|
26
32
|
'foreman_tasks_recurring_logics'
|
27
33
|
end
|
@@ -49,5 +55,18 @@ module ForemanTasks
|
|
49
55
|
scope.search_for(params[:search])
|
50
56
|
.paginate(:page => params[:page], :per_page => params[:per_page])
|
51
57
|
end
|
58
|
+
|
59
|
+
def action_permission
|
60
|
+
case params[:action]
|
61
|
+
when 'clear_cancelled'
|
62
|
+
'edit'
|
63
|
+
else
|
64
|
+
super
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def controller_permission
|
69
|
+
'recurring_logics'
|
70
|
+
end
|
52
71
|
end
|
53
72
|
end
|