foreman-tasks 2.0.0 → 3.0.2
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 +36 -60
- data/app/controllers/foreman_tasks/concerns/parameters/triggering.rb +1 -1
- data/app/controllers/foreman_tasks/recurring_logics_controller.rb +7 -0
- data/app/controllers/foreman_tasks/tasks_controller.rb +6 -3
- data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +3 -3
- data/app/lib/actions/proxy_action.rb +1 -1
- 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 +29 -33
- 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/api/tasks/show.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/show.html.erb +1 -6
- data/config/routes.rb +2 -1
- data/db/migrate/20200517215015_rename_bookmarks_controller.rb +2 -2
- 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 +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 -7
- data/lib/foreman_tasks/tasks/cleanup.rake +2 -2
- data/lib/foreman_tasks/tasks/dynflow.rake +6 -0
- data/lib/foreman_tasks/tasks/export_tasks.rake +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/locale/en/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/en/foreman_tasks.po +50 -20
- data/locale/foreman_tasks.pot +173 -126
- data/locale/fr/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/fr/foreman_tasks.po +817 -0
- data/locale/ja/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/ja/foreman_tasks.po +817 -0
- data/locale/zh_CN/LC_MESSAGES/foreman_tasks.mo +0 -0
- data/locale/zh_CN/foreman_tasks.po +816 -0
- data/package.json +1 -1
- data/script/npm_link_foreman_js.sh +26 -0
- 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 +18 -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/TaskActions/TaskAction.test.js +2 -2
- data/webpack/ForemanTasks/Components/TaskActions/index.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/RunningSteps.js +17 -3
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +8 -153
- 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 +8 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +13 -70
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskButtons.test.js +95 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/RunningSteps.test.js.snap +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +78 -208
- 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 +100 -53
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.scss +13 -14
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +57 -95
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +3 -12
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +57 -28
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.fixtures.js +8 -0
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +8 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetailsActions.test.js +6 -6
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetails.test.js.snap +84 -12
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/__snapshots__/TaskDetailsActions.test.js.snap +25 -21
- data/webpack/ForemanTasks/Components/TaskDetails/index.js +8 -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/TasksDashboardActions.js +1 -1
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardConstants.js +2 -0
- data/webpack/ForemanTasks/Components/TasksDashboard/TasksDashboardSelectors.js +17 -11
- data/webpack/ForemanTasks/Components/TasksDashboard/__tests__/TasksDashboardActions.test.js +2 -2
- 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/Components/ConfirmModal/ConfirmModalSelectors.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +2 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksBulkActions.js +25 -8
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +3 -3
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +6 -3
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.scss +0 -10
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +15 -2
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTablePage.test.js +2 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/SubTasksPage.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +48 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +39 -7
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/actionCellFormatter.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/selectionCellFormatter.test.js.snap +2 -0
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/actionCellFormatter.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionCellFormatter.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/formatters/actionCellFormatter.js +10 -7
- data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionCellFormatter.js +7 -0
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.js +39 -31
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +17 -8
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +8 -0
- 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 +35 -17
- data/.travis.yml +0 -5
- 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 -67
- data/webpack/__mocks__/foremanReact/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: c51f734a6c321d30bd6c3aa93499d9924b93435cadfd48bf129452758ed88338
|
|
4
|
+
data.tar.gz: ffd67ecf17550277bf7bcbc86f8fb98a1ac566c1d386350ff4ed1aa97ffad9e3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 68b31fa072fbf39a1bd93184dfd6a0588270f897ba4a546d79a4f25be2e5815473eedf9a2975eb57c5344a024f7581e8427f39219af00cf6478ce0697b9fb403
|
|
7
|
+
data.tar.gz: b531f627380fc77b93c930b6b22051b60e4adad8861cc137cbedfee30237e05fa70a1226b1651b4e7268bd618816a3256ba8b2993a27b5bf04771c3f73c776da
|
|
@@ -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
|
|
@@ -116,7 +105,7 @@ module ForemanTasks
|
|
|
116
105
|
total: resumed.length + failed.length + skipped.length,
|
|
117
106
|
resumed: resumed,
|
|
118
107
|
failed: failed,
|
|
119
|
-
skipped: skipped
|
|
108
|
+
skipped: skipped,
|
|
120
109
|
}
|
|
121
110
|
end
|
|
122
111
|
|
|
@@ -137,7 +126,7 @@ module ForemanTasks
|
|
|
137
126
|
render :json => {
|
|
138
127
|
total: cancelled.length + skipped.length,
|
|
139
128
|
cancelled: cancelled,
|
|
140
|
-
skipped: skipped
|
|
129
|
+
skipped: skipped,
|
|
141
130
|
}
|
|
142
131
|
end
|
|
143
132
|
|
|
@@ -165,22 +154,33 @@ module ForemanTasks
|
|
|
165
154
|
render :json => {
|
|
166
155
|
total: total_length,
|
|
167
156
|
stopped_length: to_stop_length,
|
|
168
|
-
skipped_length: skipped_length
|
|
157
|
+
skipped_length: skipped_length,
|
|
169
158
|
}
|
|
170
159
|
end
|
|
171
160
|
|
|
172
161
|
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
|
|
162
|
+
api :GET, '/tasks/:parent_task_id/sub_tasks', 'Show sub_tasks details'
|
|
163
|
+
param :parent_task_id, :identifier, desc: 'UUID of the task'
|
|
164
|
+
param_group :search_and_pagination, ::Api::V2::BaseController
|
|
181
165
|
def index
|
|
182
|
-
|
|
183
|
-
|
|
166
|
+
if params[:sort_by] || params[:sort_order]
|
|
167
|
+
Foreman::Deprecation.api_deprecation_warning(
|
|
168
|
+
"The sort params sort_by and sort_order are deprecated.
|
|
169
|
+
Please use the order param instead as one string 'order=started_at desc'"
|
|
170
|
+
)
|
|
171
|
+
|
|
172
|
+
ordering_params = {
|
|
173
|
+
sort_by: params[:sort_by] || 'started_at',
|
|
174
|
+
sort_order: params[:sort_order] || 'DESC',
|
|
175
|
+
}
|
|
176
|
+
params[:order] = "#{ordering_params[:sort_by]} #{ordering_params[:sort_order]}"
|
|
177
|
+
end
|
|
178
|
+
params[:order] ||= 'started_at DESC'
|
|
179
|
+
@tasks = DashboardTableFilter.new(resource_scope_for_index, params).scope.order(params[:order].to_s)
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def search_options
|
|
183
|
+
[params[:search], {}]
|
|
184
184
|
end
|
|
185
185
|
|
|
186
186
|
def_param_group :callback_target do
|
|
@@ -221,7 +221,7 @@ module ForemanTasks
|
|
|
221
221
|
end
|
|
222
222
|
|
|
223
223
|
def search_tasks(search_params)
|
|
224
|
-
scope = resource_scope_for_index
|
|
224
|
+
scope = resource_scope_for_index
|
|
225
225
|
scope = ordering_scope(scope, search_params)
|
|
226
226
|
scope = search_scope(scope, search_params)
|
|
227
227
|
scope = active_scope(scope, search_params)
|
|
@@ -287,7 +287,6 @@ module ForemanTasks
|
|
|
287
287
|
sort_by = ordering_params[:sort_by] || 'started_at'
|
|
288
288
|
sort_by = 'foreman_tasks_tasks.' + sort_by if sort_by == 'started_at'
|
|
289
289
|
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
290
|
scope.order("#{sort_by} #{sort_order}")
|
|
292
291
|
end
|
|
293
292
|
|
|
@@ -312,7 +311,17 @@ module ForemanTasks
|
|
|
312
311
|
end
|
|
313
312
|
|
|
314
313
|
def resource_scope(_options = {})
|
|
315
|
-
|
|
314
|
+
scope = ForemanTasks::Task.authorized("#{action_permission}_foreman_tasks")
|
|
315
|
+
scope = scope.where(:parent_task_id => params[:parent_task_id]) if params[:parent_task_id]
|
|
316
|
+
scope
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
def resource_scope_for_index(*args)
|
|
320
|
+
super.select("DISTINCT foreman_tasks_tasks.*, coalesce(ended_at, current_timestamp) - coalesce(coalesce(started_at, ended_at), current_timestamp) as duration")
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
def controller_permission
|
|
324
|
+
'foreman_tasks'
|
|
316
325
|
end
|
|
317
326
|
|
|
318
327
|
def action_permission
|
|
@@ -326,39 +335,6 @@ module ForemanTasks
|
|
|
326
335
|
end
|
|
327
336
|
end
|
|
328
337
|
|
|
329
|
-
def tasks_list(filtered_scope)
|
|
330
|
-
total = resource_scope.count
|
|
331
|
-
|
|
332
|
-
search_scope = filtered_scope.search_for(params[:search])
|
|
333
|
-
subtotal = search_scope.select('DISTINCT foreman_tasks_tasks.id').count
|
|
334
|
-
filtered_scope = search_scope.select('DISTINCT foreman_tasks_tasks.*')
|
|
335
|
-
|
|
336
|
-
ordering_params = {
|
|
337
|
-
sort_by: params[:sort_by] || 'started_at',
|
|
338
|
-
sort_order: params[:sort_order] || 'DESC'
|
|
339
|
-
}
|
|
340
|
-
filtered_scope = ordering_scope(filtered_scope, ordering_params)
|
|
341
|
-
|
|
342
|
-
pagination_params = {
|
|
343
|
-
page: params[:page] || 1,
|
|
344
|
-
per_page: params[:per_page] || Setting[:entries_per_page] || 20
|
|
345
|
-
}
|
|
346
|
-
filtered_scope = pagination_scope(filtered_scope, pagination_params)
|
|
347
|
-
results = filtered_scope.map { |task| task_hash(task) }
|
|
348
|
-
|
|
349
|
-
{
|
|
350
|
-
total: total,
|
|
351
|
-
subtotal: subtotal,
|
|
352
|
-
page: pagination_params[:page],
|
|
353
|
-
per_page: pagination_params[:per_page],
|
|
354
|
-
sort: {
|
|
355
|
-
by: ordering_params[:sort_by],
|
|
356
|
-
order: ordering_params[:sort_order]
|
|
357
|
-
},
|
|
358
|
-
results: results
|
|
359
|
-
}
|
|
360
|
-
end
|
|
361
|
-
|
|
362
338
|
def bulk_scope
|
|
363
339
|
scope = resource_scope
|
|
364
340
|
scope = scope.search_for(params[:search]) if params[:search]
|
|
@@ -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
|
|
@@ -31,9 +31,12 @@ module ForemanTasks
|
|
|
31
31
|
|
|
32
32
|
def cancel_step
|
|
33
33
|
task = find_dynflow_task
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
result = ForemanTasks.dynflow.world.event(task.external_id, params[:step_id].to_i, ::Dynflow::Action::Cancellable::Cancel).wait
|
|
35
|
+
if result.rejected?
|
|
36
|
+
render json: { error: result.reason }, status: :bad_request
|
|
37
|
+
else
|
|
38
|
+
render json: { statusText: 'OK' }
|
|
39
|
+
end
|
|
37
40
|
end
|
|
38
41
|
|
|
39
42
|
def cancel
|