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.
- checksums.yaml +4 -4
- data/.github/workflows/js_tests.yml +31 -0
- data/.github/workflows/ruby_tests.yml +74 -0
- data/.rubocop.yml +12 -4
- data/.rubocop_todo.yml +32 -25
- data/Gemfile +5 -0
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +50 -63
- data/app/controllers/foreman_tasks/concerns/parameters/triggering.rb +1 -1
- data/app/controllers/foreman_tasks/recurring_logics_controller.rb +7 -0
- data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +3 -3
- data/app/models/foreman_tasks/recurring_logic.rb +1 -1
- data/app/models/foreman_tasks/task.rb +11 -0
- data/app/models/foreman_tasks/task/dynflow_task.rb +27 -33
- data/app/models/foreman_tasks/task/search.rb +1 -1
- data/app/models/foreman_tasks/task/status_explicator.rb +1 -1
- data/app/models/foreman_tasks/triggering.rb +1 -1
- data/app/models/setting/foreman_tasks.rb +9 -9
- data/app/services/foreman_tasks/dashboard_table_filter.rb +5 -1
- data/app/views/foreman_tasks/api/tasks/index.json.rabl +2 -0
- data/app/views/foreman_tasks/layouts/react.html.erb +1 -2
- data/app/views/foreman_tasks/recurring_logics/index.html.erb +3 -1
- data/app/views/foreman_tasks/tasks/dashboard/_latest_tasks_in_error_warning.html.erb +1 -1
- data/app/views/foreman_tasks/tasks/dashboard/_tasks_status.html.erb +1 -1
- data/app/views/foreman_tasks/tasks/show.html.erb +1 -6
- data/config/routes.rb +2 -1
- data/db/migrate/20200517215015_rename_bookmarks_controller.rb +2 -2
- data/db/seeds.d/30-notification_blueprints.rb +7 -7
- data/db/seeds.d/61-foreman_tasks_bookmarks.rb +1 -1
- data/foreman-tasks.gemspec +1 -0
- data/lib/foreman_tasks/cleaner.rb +4 -6
- data/lib/foreman_tasks/dynflow/configuration.rb +1 -1
- data/lib/foreman_tasks/dynflow/persistence.rb +4 -6
- data/lib/foreman_tasks/engine.rb +2 -2
- data/lib/foreman_tasks/version.rb +1 -1
- data/package.json +0 -1
- data/test/controllers/api/recurring_logics_controller_test.rb +1 -1
- data/test/controllers/api/tasks_controller_test.rb +17 -7
- data/test/controllers/tasks_controller_test.rb +6 -6
- data/test/core/unit/runner_test.rb +20 -20
- data/test/core/unit/task_launcher_test.rb +8 -8
- data/test/helpers/foreman_tasks/foreman_tasks_helper_test.rb +7 -7
- data/test/helpers/foreman_tasks/tasks_helper_test.rb +3 -3
- data/test/lib/actions/middleware/keep_current_request_id_test.rb +3 -3
- data/test/support/history_tasks_builder.rb +1 -1
- data/test/tasks/generate_task_actions_test.rb +1 -1
- data/test/unit/actions/action_with_sub_plans_test.rb +2 -2
- data/test/unit/actions/bulk_action_test.rb +6 -6
- data/test/unit/actions/proxy_action_test.rb +20 -20
- data/test/unit/actions/recurring_action_test.rb +30 -32
- data/test/unit/cleaner_test.rb +24 -24
- data/test/unit/dashboard_table_filter_test.rb +5 -5
- data/test/unit/otp_manager_test.rb +2 -2
- data/test/unit/proxy_selector_test.rb +9 -9
- data/test/unit/recurring_logic_test.rb +32 -32
- data/test/unit/remote_task_test.rb +2 -2
- data/test/unit/task_groups_test.rb +4 -4
- data/test/unit/task_test.rb +26 -18
- data/test/unit/triggering_test.rb +8 -8
- data/test/unit/troubleshooting_help_generator_test.rb +6 -6
- data/test/unit/ui_notifications_test.rb +11 -11
- data/webpack/ForemanTasks/Components/TaskDetails/Components/RunningSteps.js +3 -3
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +8 -157
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskButtons.js +168 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +6 -7
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskSkeleton.js +48 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +12 -70
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskButtons.test.js +95 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +78 -225
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskButtons.test.js.snap +212 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +8 -4
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.js +87 -70
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.scss +10 -0
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +48 -125
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +3 -16
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +55 -29
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.fixtures.js +2 -2
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +6 -0
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +2 -18
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +77 -27
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap +14 -101
- data/webpack/ForemanTasks/Components/TaskDetails/index.js +6 -3
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/ScheduledTasksCard/ScheduledTasksCard.scss +4 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.js +53 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/OtherInfo.test.js +14 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.js +27 -19
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.scss +14 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCard.test.js +1 -34
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/{StoppedTasksCardHelper.js → StoppedTasksCardTable.js} +28 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/StoppedTasksCardTable.test.js +54 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/OtherInfo.test.js.snap +48 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCard.test.js.snap +60 -1367
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/Components/StoppedTasksCard/__snapshots__/StoppedTasksCardTable.test.js.snap +960 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksCardsGrid/__snapshots__/TasksCardsGrid.test.js.snap +14 -11
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +2 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js +17 -11
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardSelectors.test.js +26 -14
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboard.test.js.snap +14 -11
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/__snapshots__/TasksDashboardSelectors.test.js.snap +38 -22
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +0 -8
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +13 -4
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.scss +0 -10
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +0 -2
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionNameCellFormatter.test.js.snap +3 -1
- data/webpack/ForemanTasks/Components/TasksTable/formatters/actionNameCellFormatter.js +6 -1
- data/webpack/ForemanTasks/Components/common/urlHelpers.js +7 -0
- data/webpack/ForemanTasks/ForemanTasksReducers.js +0 -2
- data/webpack/__mocks__/foremanReact/common/helpers.js +2 -0
- data/webpack/__mocks__/foremanReact/redux/API/APISelectors.js +10 -0
- data/webpack/__mocks__/foremanReact/redux/API/index.js +10 -0
- data/webpack/__mocks__/foremanReact/redux/middlewares/IntervalMiddleware.js +5 -0
- metadata +21 -13
- data/.travis.yml +0 -7
- data/app/assets/stylesheets/foreman_tasks/tasks.scss +0 -9
- data/script/travis_run_js_tests.sh +0 -7
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -38
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsReducer.test.js +0 -33
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsReducer.test.js.snap +0 -26
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/integration.test.js.snap +0 -122
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +0 -72
- data/webpack/__mocks__/foremanReact/redux/API.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: '09cfa50efbe1f8e34246268b386aa7f2cdc0e6f723beda8aedf60a6edf372cbb'
|
|
4
|
+
data.tar.gz: 6124d140e2ddd581ff85c7d4c44bb6c3fed01a9e64050e39bf595bff485ca7bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5ee3cd1aee581db4ab76b9278624d00b28271965655cc9c154d2cd18ac3d9284244886d74bd6f6654847d5ae19f9dc8245eb517227ee1b4c8b88281066f43a19
|
|
7
|
+
data.tar.gz: 67c6b3edfd673e60489884f2dbb18fec2a03c7a2a33a04933f1a087686c2b18324038ca2f283a3c07608cae8d335b1f4e441ceffa92dad094468a3ac77cccaaa
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: JavaScript Testing
|
|
2
|
+
on:
|
|
3
|
+
pull_request:
|
|
4
|
+
paths:
|
|
5
|
+
- 'webpack/**'
|
|
6
|
+
- 'package.json'
|
|
7
|
+
- '.github/workflows/js_tests.yml'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test_js:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [10, 12]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v2
|
|
18
|
+
- name: Setup Node
|
|
19
|
+
uses: actions/setup-node@v1
|
|
20
|
+
with:
|
|
21
|
+
node-version: ${{ matrix.node-version }}
|
|
22
|
+
- name: Npm install
|
|
23
|
+
run: npm install
|
|
24
|
+
- name: Run plugin linter
|
|
25
|
+
run: npm run lint
|
|
26
|
+
- name: Run plugin tests
|
|
27
|
+
run: npm run test
|
|
28
|
+
- name: Publish Coveralls
|
|
29
|
+
uses: coverallsapp/github-action@master
|
|
30
|
+
with:
|
|
31
|
+
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
name: Ruby Testing
|
|
2
|
+
on: [pull_request]
|
|
3
|
+
env:
|
|
4
|
+
RAILS_ENV: test
|
|
5
|
+
DATABASE_URL: postgresql://postgres:@localhost/test
|
|
6
|
+
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: true
|
|
7
|
+
jobs:
|
|
8
|
+
rubocop:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v2
|
|
12
|
+
- name: Setup Ruby
|
|
13
|
+
uses: ruby/setup-ruby@v1
|
|
14
|
+
with:
|
|
15
|
+
ruby-version: 2.6
|
|
16
|
+
- name: Setup
|
|
17
|
+
run: |
|
|
18
|
+
gem install bundler
|
|
19
|
+
bundle install --jobs=3 --retry=3
|
|
20
|
+
- name: Run rubocop
|
|
21
|
+
run: bundle exec rubocop
|
|
22
|
+
test_ruby:
|
|
23
|
+
runs-on: ubuntu-latest
|
|
24
|
+
needs: rubocop
|
|
25
|
+
services:
|
|
26
|
+
postgres:
|
|
27
|
+
image: postgres:12.1
|
|
28
|
+
ports: ['5432:5432']
|
|
29
|
+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
|
|
30
|
+
strategy:
|
|
31
|
+
fail-fast: false
|
|
32
|
+
matrix:
|
|
33
|
+
foreman-core-branch: [develop]
|
|
34
|
+
ruby-version: [2.5, 2.6]
|
|
35
|
+
node-version: [12]
|
|
36
|
+
steps:
|
|
37
|
+
- run: sudo apt-get update
|
|
38
|
+
- run: sudo apt-get install build-essential libcurl4-openssl-dev zlib1g-dev libpq-dev
|
|
39
|
+
- uses: actions/checkout@v2
|
|
40
|
+
with:
|
|
41
|
+
repository: theforeman/foreman
|
|
42
|
+
ref: ${{ matrix.foreman-core-branch }}
|
|
43
|
+
- uses: actions/checkout@v2
|
|
44
|
+
with:
|
|
45
|
+
path: foreman-tasks
|
|
46
|
+
- name: Setup Ruby
|
|
47
|
+
uses: ruby/setup-ruby@v1
|
|
48
|
+
with:
|
|
49
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
50
|
+
- name: Setup Node
|
|
51
|
+
uses: actions/setup-node@v1
|
|
52
|
+
with:
|
|
53
|
+
node-version: ${{ matrix.node-version }}
|
|
54
|
+
- uses: actions/cache@v2
|
|
55
|
+
with:
|
|
56
|
+
path: vendor/bundle
|
|
57
|
+
key: ${{ runner.os }}-fgems-${{ matrix.ruby-version }}-${{ hashFiles('Gemfile.lock') }}
|
|
58
|
+
restore-keys: |
|
|
59
|
+
${{ runner.os }}-fgems-${{ matrix.ruby-version }}-
|
|
60
|
+
- name: Setup Bundler
|
|
61
|
+
run: |
|
|
62
|
+
echo "gem 'foreman-tasks', path: './foreman-tasks'" > bundler.d/foreman-tasks.local.rb
|
|
63
|
+
gem install bundler
|
|
64
|
+
bundle config set without journald development console libvirt
|
|
65
|
+
bundle config set path vendor/bundle
|
|
66
|
+
- name: Prepare test env
|
|
67
|
+
run: |
|
|
68
|
+
bundle install --jobs=3 --retry=3
|
|
69
|
+
bundle exec rake db:create
|
|
70
|
+
bundle exec rake db:migrate
|
|
71
|
+
- name: Run plugin tests
|
|
72
|
+
run: |
|
|
73
|
+
bundle exec rake test:foreman-tasks
|
|
74
|
+
bundle exec rake test TEST="test/unit/foreman/access_permissions_test.rb"
|
data/.rubocop.yml
CHANGED
|
@@ -6,10 +6,10 @@ require:
|
|
|
6
6
|
inherit_from: .rubocop_todo.yml
|
|
7
7
|
|
|
8
8
|
AllCops:
|
|
9
|
-
|
|
10
|
-
- '
|
|
11
|
-
- '
|
|
12
|
-
|
|
9
|
+
Exclude:
|
|
10
|
+
- 'node_modules/**/*'
|
|
11
|
+
- 'locale/*'
|
|
12
|
+
TargetRubyVersion: 2.5
|
|
13
13
|
|
|
14
14
|
Lint/ShadowingOuterLocalVariable:
|
|
15
15
|
Enabled: false
|
|
@@ -68,6 +68,8 @@ Naming/FileName:
|
|
|
68
68
|
- Gemfile
|
|
69
69
|
- db/seeds.d/*
|
|
70
70
|
- lib/foreman-tasks.rb
|
|
71
|
+
- gemfile.d/foreman-tasks.rb
|
|
72
|
+
|
|
71
73
|
|
|
72
74
|
Layout/HeredocIndentation:
|
|
73
75
|
Exclude:
|
|
@@ -115,3 +117,9 @@ Naming/RescuedExceptionsVariableName:
|
|
|
115
117
|
|
|
116
118
|
Style/WordArray:
|
|
117
119
|
Enabled: false
|
|
120
|
+
|
|
121
|
+
Style/TrailingCommaInArrayLiteral:
|
|
122
|
+
EnforcedStyleForMultiline: comma
|
|
123
|
+
|
|
124
|
+
Style/TrailingCommaInHashLiteral:
|
|
125
|
+
EnforcedStyleForMultiline: comma
|
data/.rubocop_todo.yml
CHANGED
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2020-08-07 08:31:32 UTC using RuboCop version 0.89.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: 2
|
|
10
|
+
# Configuration parameters: Include.
|
|
11
|
+
# Include: **/*.gemspec
|
|
12
|
+
Gemspec/RequiredRubyVersion:
|
|
3
13
|
Exclude:
|
|
4
|
-
- '
|
|
14
|
+
- 'foreman-tasks-core.gemspec'
|
|
15
|
+
- 'foreman-tasks.gemspec'
|
|
5
16
|
|
|
6
17
|
# Offense count: 1
|
|
7
18
|
Lint/UselessAssignment:
|
|
8
19
|
Exclude:
|
|
9
20
|
- 'lib/foreman_tasks/tasks/export_tasks.rake'
|
|
10
21
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
# Offense count: 1
|
|
23
|
+
# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
|
24
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
|
25
|
+
Naming/FileName:
|
|
26
|
+
Exclude:
|
|
27
|
+
- '*.gemspec'
|
|
28
|
+
- 'Gemfile'
|
|
29
|
+
- 'db/seeds.d/*'
|
|
30
|
+
- 'lib/foreman-tasks.rb'
|
|
31
|
+
- 'gemfile.d/foreman-tasks.rb'
|
|
19
32
|
|
|
20
33
|
# Offense count: 3
|
|
21
34
|
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
|
|
@@ -28,7 +41,7 @@ Naming/MemoizedInstanceVariableName:
|
|
|
28
41
|
|
|
29
42
|
# Offense count: 11
|
|
30
43
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
|
31
|
-
# AllowedNames:
|
|
44
|
+
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
|
|
32
45
|
Naming/MethodParameterName:
|
|
33
46
|
Exclude:
|
|
34
47
|
- 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
|
|
@@ -67,11 +80,13 @@ Rails/OutputSafety:
|
|
|
67
80
|
Exclude:
|
|
68
81
|
- 'app/helpers/foreman_tasks/foreman_tasks_helper.rb'
|
|
69
82
|
|
|
70
|
-
# Offense count:
|
|
83
|
+
# Offense count: 2
|
|
71
84
|
# Configuration parameters: Include.
|
|
72
85
|
# Include: **/Rakefile, **/*.rake
|
|
73
86
|
Rails/RakeEnvironment:
|
|
74
87
|
Exclude:
|
|
88
|
+
- 'lib/capistrano/tasks/**/*.rake'
|
|
89
|
+
- 'lib/foreman_tasks/tasks/dynflow.rake'
|
|
75
90
|
- 'lib/foreman_tasks/tasks/test.rake'
|
|
76
91
|
|
|
77
92
|
# Offense count: 12
|
|
@@ -92,22 +107,14 @@ Style/ClassAndModuleChildren:
|
|
|
92
107
|
- 'test/controllers/api/recurring_logics_controller_test.rb'
|
|
93
108
|
- 'test/controllers/api/tasks_controller_test.rb'
|
|
94
109
|
|
|
95
|
-
# Offense count:
|
|
110
|
+
# Offense count: 1
|
|
111
|
+
# Configuration parameters: EnforcedStyle.
|
|
112
|
+
# SupportedStyles: allowed_in_returns, forbidden
|
|
96
113
|
Style/DoubleNegation:
|
|
97
114
|
Exclude:
|
|
98
|
-
- 'app/models/foreman_tasks/lock.rb'
|
|
99
115
|
- 'app/models/foreman_tasks/recurring_logic.rb'
|
|
100
116
|
|
|
101
|
-
# Offense count:
|
|
117
|
+
# Offense count: 35
|
|
102
118
|
# Configuration parameters: MinBodyLength.
|
|
103
119
|
Style/GuardClause:
|
|
104
120
|
Enabled: false
|
|
105
|
-
|
|
106
|
-
Style/HashEachMethods:
|
|
107
|
-
Enabled: false
|
|
108
|
-
|
|
109
|
-
Style/HashTransformKeys:
|
|
110
|
-
Enabled: false
|
|
111
|
-
|
|
112
|
-
Style/HashTransformValues:
|
|
113
|
-
Enabled: false
|
data/Gemfile
CHANGED
|
@@ -31,17 +31,6 @@ module ForemanTasks
|
|
|
31
31
|
param :id, :identifier, desc: 'UUID of the task'
|
|
32
32
|
def details; end
|
|
33
33
|
|
|
34
|
-
api :GET, '/tasks/:id/sub_tasks', 'Show sub_tasks details'
|
|
35
|
-
param :id, :identifier, desc: 'UUID of the task'
|
|
36
|
-
def sub_tasks
|
|
37
|
-
parent_task = resource_scope.find(params[:id])
|
|
38
|
-
filtered_scope = parent_task.sub_tasks
|
|
39
|
-
action_name = { "action_name" => parent_task.action }
|
|
40
|
-
|
|
41
|
-
filtered_scope = DashboardTableFilter.new(filtered_scope, params).scope
|
|
42
|
-
render :json => action_name.merge(tasks_list(filtered_scope))
|
|
43
|
-
end
|
|
44
|
-
|
|
45
34
|
api :POST, '/tasks/bulk_search', 'List dynflow tasks for uuids'
|
|
46
35
|
param :searches, Array, :desc => 'List of uuids to fetch info about' do
|
|
47
36
|
param :search_id, String, :desc => <<-DESC
|
|
@@ -86,11 +75,16 @@ module ForemanTasks
|
|
|
86
75
|
end
|
|
87
76
|
|
|
88
77
|
api :POST, '/tasks/bulk_resume', N_('Resume all paused error tasks')
|
|
78
|
+
desc <<~DOC
|
|
79
|
+
Resumes all selected resumable tasks. If neither a search query nor an
|
|
80
|
+
explicit list of task IDs is provided, it tries to resume all tasks in
|
|
81
|
+
paused state with result error.
|
|
82
|
+
DOC
|
|
89
83
|
param :search, String, :desc => N_('Resume tasks matching search string')
|
|
90
84
|
param :task_ids, Array, :desc => N_('Resume specific tasks by ID')
|
|
91
85
|
def bulk_resume
|
|
92
86
|
if params[:search].nil? && params[:task_ids].nil?
|
|
93
|
-
|
|
87
|
+
params[:search] = 'state = paused and result = error'
|
|
94
88
|
end
|
|
95
89
|
resumed = []
|
|
96
90
|
failed = []
|
|
@@ -116,13 +110,18 @@ module ForemanTasks
|
|
|
116
110
|
total: resumed.length + failed.length + skipped.length,
|
|
117
111
|
resumed: resumed,
|
|
118
112
|
failed: failed,
|
|
119
|
-
skipped: skipped
|
|
113
|
+
skipped: skipped,
|
|
120
114
|
}
|
|
121
115
|
end
|
|
122
116
|
|
|
123
|
-
api :POST, '/tasks/bulk_cancel', N_('Cancel
|
|
117
|
+
api :POST, '/tasks/bulk_cancel', N_('Cancel selected cancellable tasks')
|
|
118
|
+
desc <<~DOC
|
|
119
|
+
Cancels all selected cancellable tasks. Requires a search query or an
|
|
120
|
+
explicit list of task IDs to be provided.
|
|
121
|
+
DOC
|
|
124
122
|
param :search, String, :desc => N_('Cancel tasks matching search string')
|
|
125
123
|
param :task_ids, Array, :desc => N_('Cancel specific tasks by ID')
|
|
124
|
+
error :bad_request, 'Returned if neither search nor task_ids parameter is provided.'
|
|
126
125
|
def bulk_cancel
|
|
127
126
|
if params[:search].nil? && params[:task_ids].nil?
|
|
128
127
|
raise BadRequest, _('Please provide at least one of search or task_ids parameters in the request')
|
|
@@ -137,13 +136,18 @@ module ForemanTasks
|
|
|
137
136
|
render :json => {
|
|
138
137
|
total: cancelled.length + skipped.length,
|
|
139
138
|
cancelled: cancelled,
|
|
140
|
-
skipped: skipped
|
|
139
|
+
skipped: skipped,
|
|
141
140
|
}
|
|
142
141
|
end
|
|
143
142
|
|
|
144
|
-
api :POST, '/tasks/bulk_stop', N_('Stop
|
|
143
|
+
api :POST, '/tasks/bulk_stop', N_('Stop selected stoppable tasks')
|
|
144
|
+
desc <<~DOC
|
|
145
|
+
Stops all selected tasks which are not already stopped. Requires a
|
|
146
|
+
search query or an explicit list of task IDs to be provided.
|
|
147
|
+
DOC
|
|
145
148
|
param :search, String, :desc => N_('Stop tasks matching search string')
|
|
146
149
|
param :task_ids, Array, :desc => N_('Stop specific tasks by ID')
|
|
150
|
+
error :bad_request, 'Returned if neither search nor task_ids parameter is provided.'
|
|
147
151
|
def bulk_stop
|
|
148
152
|
if params[:search].nil? && params[:task_ids].nil?
|
|
149
153
|
raise BadRequest, _('Please provide at least one of search or task_ids parameters in the request')
|
|
@@ -165,22 +169,33 @@ module ForemanTasks
|
|
|
165
169
|
render :json => {
|
|
166
170
|
total: total_length,
|
|
167
171
|
stopped_length: to_stop_length,
|
|
168
|
-
skipped_length: skipped_length
|
|
172
|
+
skipped_length: skipped_length,
|
|
169
173
|
}
|
|
170
174
|
end
|
|
171
175
|
|
|
172
176
|
api :GET, '/tasks', N_('List tasks')
|
|
173
|
-
|
|
174
|
-
param :
|
|
175
|
-
|
|
176
|
-
param :order, String, :desc => N_("Sort field and order, e.g. 'name DESC'")
|
|
177
|
-
param :sort, Hash, :desc => N_("Hash version of 'order' param") do
|
|
178
|
-
param :by, String, :desc => N_('Field to sort the results on')
|
|
179
|
-
param :order, String, :desc => N_('How to order the sorted results (e.g. ASC for ascending)')
|
|
180
|
-
end
|
|
177
|
+
api :GET, '/tasks/:parent_task_id/sub_tasks', 'Show sub_tasks details'
|
|
178
|
+
param :parent_task_id, :identifier, desc: 'UUID of the task'
|
|
179
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
|
181
180
|
def index
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
if params[:sort_by] || params[:sort_order]
|
|
182
|
+
Foreman::Deprecation.api_deprecation_warning(
|
|
183
|
+
"The sort params sort_by and sort_order are deprecated.
|
|
184
|
+
Please use the order param instead as one string 'order=started_at desc'"
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
ordering_params = {
|
|
188
|
+
sort_by: params[:sort_by] || 'started_at',
|
|
189
|
+
sort_order: params[:sort_order] || 'DESC',
|
|
190
|
+
}
|
|
191
|
+
params[:order] = "#{ordering_params[:sort_by]} #{ordering_params[:sort_order]}"
|
|
192
|
+
end
|
|
193
|
+
params[:order] ||= 'started_at DESC'
|
|
194
|
+
@tasks = DashboardTableFilter.new(resource_scope_for_index, params).scope.order(params[:order].to_s)
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def search_options
|
|
198
|
+
[params[:search], {}]
|
|
184
199
|
end
|
|
185
200
|
|
|
186
201
|
def_param_group :callback_target do
|
|
@@ -221,7 +236,7 @@ module ForemanTasks
|
|
|
221
236
|
end
|
|
222
237
|
|
|
223
238
|
def search_tasks(search_params)
|
|
224
|
-
scope = resource_scope_for_index
|
|
239
|
+
scope = resource_scope_for_index
|
|
225
240
|
scope = ordering_scope(scope, search_params)
|
|
226
241
|
scope = search_scope(scope, search_params)
|
|
227
242
|
scope = active_scope(scope, search_params)
|
|
@@ -287,7 +302,6 @@ module ForemanTasks
|
|
|
287
302
|
sort_by = ordering_params[:sort_by] || 'started_at'
|
|
288
303
|
sort_by = 'foreman_tasks_tasks.' + sort_by if sort_by == 'started_at'
|
|
289
304
|
sort_order = ordering_params[:sort_order] || 'DESC'
|
|
290
|
-
scope = scope.select("foreman_tasks_tasks.*, coalesce(ended_at, current_timestamp) - coalesce(coalesce(started_at, ended_at), current_timestamp) as duration")
|
|
291
305
|
scope.order("#{sort_by} #{sort_order}")
|
|
292
306
|
end
|
|
293
307
|
|
|
@@ -312,7 +326,13 @@ module ForemanTasks
|
|
|
312
326
|
end
|
|
313
327
|
|
|
314
328
|
def resource_scope(_options = {})
|
|
315
|
-
|
|
329
|
+
scope = ForemanTasks::Task.authorized("#{action_permission}_foreman_tasks")
|
|
330
|
+
scope = scope.where(:parent_task_id => params[:parent_task_id]) if params[:parent_task_id]
|
|
331
|
+
scope
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
def resource_scope_for_index(*args)
|
|
335
|
+
super.select("DISTINCT foreman_tasks_tasks.*, coalesce(ended_at, current_timestamp) - coalesce(coalesce(started_at, ended_at), current_timestamp) as duration")
|
|
316
336
|
end
|
|
317
337
|
|
|
318
338
|
def controller_permission
|
|
@@ -330,39 +350,6 @@ module ForemanTasks
|
|
|
330
350
|
end
|
|
331
351
|
end
|
|
332
352
|
|
|
333
|
-
def tasks_list(filtered_scope)
|
|
334
|
-
total = resource_scope.count
|
|
335
|
-
|
|
336
|
-
search_scope = filtered_scope.search_for(params[:search])
|
|
337
|
-
subtotal = search_scope.select('DISTINCT foreman_tasks_tasks.id').count
|
|
338
|
-
filtered_scope = search_scope.select('DISTINCT foreman_tasks_tasks.*')
|
|
339
|
-
|
|
340
|
-
ordering_params = {
|
|
341
|
-
sort_by: params[:sort_by] || 'started_at',
|
|
342
|
-
sort_order: params[:sort_order] || 'DESC'
|
|
343
|
-
}
|
|
344
|
-
filtered_scope = ordering_scope(filtered_scope, ordering_params)
|
|
345
|
-
|
|
346
|
-
pagination_params = {
|
|
347
|
-
page: params[:page] || 1,
|
|
348
|
-
per_page: params[:per_page] || Setting[:entries_per_page] || 20
|
|
349
|
-
}
|
|
350
|
-
filtered_scope = pagination_scope(filtered_scope, pagination_params)
|
|
351
|
-
results = filtered_scope.map { |task| task_hash(task) }
|
|
352
|
-
|
|
353
|
-
{
|
|
354
|
-
total: total,
|
|
355
|
-
subtotal: subtotal,
|
|
356
|
-
page: pagination_params[:page],
|
|
357
|
-
per_page: pagination_params[:per_page],
|
|
358
|
-
sort: {
|
|
359
|
-
by: ordering_params[:sort_by],
|
|
360
|
-
order: ordering_params[:sort_order]
|
|
361
|
-
},
|
|
362
|
-
results: results
|
|
363
|
-
}
|
|
364
|
-
end
|
|
365
|
-
|
|
366
353
|
def bulk_scope
|
|
367
354
|
scope = resource_scope
|
|
368
355
|
scope = scope.search_for(params[:search]) if params[:search]
|