foreman-tasks 4.1.0 → 4.1.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/app/controllers/concerns/foreman_tasks/find_tasks_common.rb +14 -0
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +4 -3
- data/app/controllers/foreman_tasks/tasks_controller.rb +3 -10
- data/app/lib/actions/middleware/load_setting_values.rb +35 -0
- data/app/lib/actions/middleware/watch_delegated_proxy_sub_tasks.rb +2 -6
- data/app/lib/actions/proxy_action.rb +1 -1
- data/app/models/foreman_tasks/task/dynflow_task.rb +8 -3
- data/lib/foreman_tasks/engine.rb +1 -0
- data/lib/foreman_tasks/tasks/export_tasks.rake +90 -46
- data/lib/foreman_tasks/version.rb +1 -1
- data/locale/action_names.rb +3 -2
- data/locale/en/foreman_tasks.po +60 -27
- data/locale/foreman_tasks.pot +180 -132
- data/locale/fr/foreman_tasks.po +61 -28
- data/locale/ja/foreman_tasks.po +61 -28
- data/locale/zh_CN/foreman_tasks.po +61 -28
- data/test/controllers/api/tasks_controller_test.rb +15 -0
- data/test/unit/actions/proxy_action_test.rb +3 -0
- data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.js +11 -4
- data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.test.js +27 -5
- data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +8 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +6 -1
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +2 -1
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +22 -11
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +10 -2
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +3 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableHelpers.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +12 -2
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableReducer.test.js.snap +3 -0
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/__snapshots__/selectionHeaderCellFormatter.test.js.snap +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/formatters/__test__/selectionHeaderCellFormatter.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/formatters/selectionHeaderCellFormatter.js +1 -0
- data/webpack/ForemanTasks/Components/TasksTable/index.js +2 -0
- metadata +4 -5
- data/app/services/foreman_tasks/dashboard_table_filter.rb +0 -56
- data/test/unit/dashboard_table_filter_test.rb +0 -77
@@ -19,8 +19,13 @@ const initialState = Immutable({
|
|
19
19
|
|
20
20
|
export const TasksTableQueryReducer = (state = initialState, action) => {
|
21
21
|
const { type, payload, response } = action;
|
22
|
-
const {
|
23
|
-
|
22
|
+
const {
|
23
|
+
subtotal,
|
24
|
+
page,
|
25
|
+
per_page: perPageString,
|
26
|
+
action_name: actionName,
|
27
|
+
can_edit: canEdit,
|
28
|
+
} = response || {};
|
24
29
|
const ACTION_TYPES = createTableActionTypes(TASKS_TABLE_ID);
|
25
30
|
switch (type) {
|
26
31
|
case SELECT_ALL_ROWS:
|
@@ -34,6 +39,9 @@ export const TasksTableQueryReducer = (state = initialState, action) => {
|
|
34
39
|
perPage: Number(perPageString),
|
35
40
|
},
|
36
41
|
selectedRows: [],
|
42
|
+
permissions: {
|
43
|
+
edit: canEdit,
|
44
|
+
},
|
37
45
|
});
|
38
46
|
case SELECT_ROWS:
|
39
47
|
return state.set('selectedRows', union(payload, state.selectedRows));
|
@@ -24,6 +24,9 @@ export const selectActionName = state =>
|
|
24
24
|
export const selectSelectedRows = state =>
|
25
25
|
selectTasksTableQuery(state).selectedRows || [];
|
26
26
|
|
27
|
+
export const selectPermissions = state =>
|
28
|
+
selectTasksTableQuery(state).permissions || { edit: false };
|
29
|
+
|
27
30
|
export const selectResults = createSelector(
|
28
31
|
selectTasksTableContent,
|
29
32
|
({ results }) =>
|
@@ -32,7 +32,7 @@ describe('getCSVurl', () => {
|
|
32
32
|
const url = '/foreman_tasks/tasks';
|
33
33
|
const query = { state: 'stopped' };
|
34
34
|
expect(getCSVurl(url, query)).toEqual(
|
35
|
-
'/foreman_tasks/tasks.csv?
|
35
|
+
'/foreman_tasks/tasks.csv?search=%28state%3Dstopped%29'
|
36
36
|
);
|
37
37
|
});
|
38
38
|
it('should return currect url for subtasks', () => {
|
data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap
CHANGED
@@ -92,7 +92,7 @@ exports[`TasksTablePage rendering render with Breadcrubs and edit permissions 1`
|
|
92
92
|
/>
|
93
93
|
<ExportButton
|
94
94
|
title="Export All"
|
95
|
-
url="/foreman_tasks/tasks.csv?
|
95
|
+
url="/foreman_tasks/tasks.csv?search=%28state%3Dstopped%29"
|
96
96
|
/>
|
97
97
|
<ActionSelectButton
|
98
98
|
disabled={true}
|
@@ -126,6 +126,11 @@ exports[`TasksTablePage rendering render with Breadcrubs and edit permissions 1`
|
|
126
126
|
}
|
127
127
|
}
|
128
128
|
parentTaskID={null}
|
129
|
+
permissions={
|
130
|
+
Object {
|
131
|
+
"edit": false,
|
132
|
+
}
|
133
|
+
}
|
129
134
|
reloadPage={[MockFunction]}
|
130
135
|
results={
|
131
136
|
Array [
|
@@ -227,7 +232,7 @@ exports[`TasksTablePage rendering render with minimal props 1`] = `
|
|
227
232
|
/>
|
228
233
|
<ExportButton
|
229
234
|
title="Export All"
|
230
|
-
url="/foreman_tasks/tasks.csv?
|
235
|
+
url="/foreman_tasks/tasks.csv?search=%28state%3Dstopped%29"
|
231
236
|
/>
|
232
237
|
<ActionSelectButton
|
233
238
|
disabled={true}
|
@@ -261,6 +266,11 @@ exports[`TasksTablePage rendering render with minimal props 1`] = `
|
|
261
266
|
}
|
262
267
|
}
|
263
268
|
parentTaskID={null}
|
269
|
+
permissions={
|
270
|
+
Object {
|
271
|
+
"edit": false,
|
272
|
+
}
|
273
|
+
}
|
264
274
|
reloadPage={[MockFunction]}
|
265
275
|
results={
|
266
276
|
Array [
|
@@ -16,6 +16,7 @@ import {
|
|
16
16
|
selectAllRowsSelected,
|
17
17
|
selectShowSelectAll,
|
18
18
|
selectModalID,
|
19
|
+
selectPermissions,
|
19
20
|
} from './TasksTableSelectors';
|
20
21
|
|
21
22
|
const mapStateToProps = state => ({
|
@@ -30,6 +31,7 @@ const mapStateToProps = state => ({
|
|
30
31
|
allRowsSelected: selectAllRowsSelected(state),
|
31
32
|
showSelectAll: selectShowSelectAll(state),
|
32
33
|
modalID: selectModalID(state),
|
34
|
+
permissions: selectPermissions(state),
|
33
35
|
});
|
34
36
|
|
35
37
|
const mapDispatchToProps = dispatch =>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Nečas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dynflow
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- app/assets/javascripts/foreman_tasks/trigger_form.js
|
139
139
|
- app/assets/stylesheets/foreman_tasks/foreman_tasks.css
|
140
140
|
- app/assets/stylesheets/foreman_tasks/trigger_form.css
|
141
|
+
- app/controllers/concerns/foreman_tasks/find_tasks_common.rb
|
141
142
|
- app/controllers/foreman_tasks/api/recurring_logics_controller.rb
|
142
143
|
- app/controllers/foreman_tasks/api/tasks_controller.rb
|
143
144
|
- app/controllers/foreman_tasks/concerns/hosts_controller_extension.rb
|
@@ -166,6 +167,7 @@ files:
|
|
166
167
|
- app/lib/actions/middleware/keep_current_taxonomies.rb
|
167
168
|
- app/lib/actions/middleware/keep_current_timezone.rb
|
168
169
|
- app/lib/actions/middleware/keep_current_user.rb
|
170
|
+
- app/lib/actions/middleware/load_setting_values.rb
|
169
171
|
- app/lib/actions/middleware/proxy_batch_triggering.rb
|
170
172
|
- app/lib/actions/middleware/rails_executor_wrap.rb
|
171
173
|
- app/lib/actions/middleware/recurring_logic.rb
|
@@ -196,7 +198,6 @@ files:
|
|
196
198
|
- app/models/foreman_tasks/task_groups/recurring_logic_task_group.rb
|
197
199
|
- app/models/foreman_tasks/triggering.rb
|
198
200
|
- app/models/setting/foreman_tasks.rb
|
199
|
-
- app/services/foreman_tasks/dashboard_table_filter.rb
|
200
201
|
- app/services/foreman_tasks/proxy_selector.rb
|
201
202
|
- app/services/foreman_tasks/troubleshooting_help_generator.rb
|
202
203
|
- app/services/ui_notifications/tasks.rb
|
@@ -333,7 +334,6 @@ files:
|
|
333
334
|
- test/unit/actions/recurring_action_test.rb
|
334
335
|
- test/unit/cleaner_test.rb
|
335
336
|
- test/unit/config/environment.rb
|
336
|
-
- test/unit/dashboard_table_filter_test.rb
|
337
337
|
- test/unit/dynflow_console_authorizer_test.rb
|
338
338
|
- test/unit/locking_test.rb
|
339
339
|
- test/unit/otp_manager_test.rb
|
@@ -648,7 +648,6 @@ test_files:
|
|
648
648
|
- test/unit/actions/recurring_action_test.rb
|
649
649
|
- test/unit/cleaner_test.rb
|
650
650
|
- test/unit/config/environment.rb
|
651
|
-
- test/unit/dashboard_table_filter_test.rb
|
652
651
|
- test/unit/dynflow_console_authorizer_test.rb
|
653
652
|
- test/unit/locking_test.rb
|
654
653
|
- test/unit/otp_manager_test.rb
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module ForemanTasks
|
2
|
-
# narrows the scope for the tasks table based on params coming from tasks dashboard
|
3
|
-
#
|
4
|
-
# Supported filters:
|
5
|
-
#
|
6
|
-
# * :result
|
7
|
-
# * :state
|
8
|
-
# * :time_horizon - expected format of Hxy, where the xy is the time horizon in hours we're interested in
|
9
|
-
# :time_mode can be set to 'recent' to filter the recent tasks, or 'older' (default) to filter earlier ones
|
10
|
-
class DashboardTableFilter
|
11
|
-
def initialize(scope, params)
|
12
|
-
@scope = scope
|
13
|
-
@params = params
|
14
|
-
end
|
15
|
-
|
16
|
-
def scope
|
17
|
-
@new_scope = @scope
|
18
|
-
scope_by(:result)
|
19
|
-
scope_by(:state)
|
20
|
-
scope_by_time
|
21
|
-
@new_scope
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def scope_by(field)
|
27
|
-
if (field == :result) && (@params[field] == 'other')
|
28
|
-
@new_scope = @new_scope.where(:result => ['cancelled', 'pending'])
|
29
|
-
elsif @params[field].present?
|
30
|
-
@new_scope = @new_scope.where(field => @params[field])
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def scope_by_time
|
35
|
-
return if @params[:time_horizon].blank?
|
36
|
-
hours = if @params[:time_horizon].casecmp('week') == 0
|
37
|
-
24 * 7
|
38
|
-
else
|
39
|
-
@params[:time_horizon][/\AH(\d{1,2})$/i, 1]
|
40
|
-
end
|
41
|
-
|
42
|
-
unless hours
|
43
|
-
raise Foreman::Exception, 'Unexpected format of time: should be in form of "H24" or equal to "week"'
|
44
|
-
end
|
45
|
-
timestamp = Time.now.utc - hours.to_i.hours
|
46
|
-
case @params[:time_mode]
|
47
|
-
when 'recent'
|
48
|
-
operator = '>'
|
49
|
-
else
|
50
|
-
operator = '<'
|
51
|
-
search_suffix = 'OR state_updated_at IS NULL'
|
52
|
-
end
|
53
|
-
@new_scope = @new_scope.where("state_updated_at #{operator} ? #{search_suffix}", timestamp)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'foreman_tasks_test_helper'
|
2
|
-
|
3
|
-
class DashboardTableFilterTest < ActiveSupport::TestCase
|
4
|
-
before do
|
5
|
-
::ForemanTasks::Task.delete_all
|
6
|
-
end
|
7
|
-
|
8
|
-
describe ForemanTasks::DashboardTableFilter do
|
9
|
-
before do
|
10
|
-
@tasks_builder = HistoryTasksBuilder.new
|
11
|
-
@scope = ForemanTasks::Task.all
|
12
|
-
@tasks_builder.build
|
13
|
-
end
|
14
|
-
|
15
|
-
let :subject do
|
16
|
-
ForemanTasks::DashboardTableFilter.new(@scope, params)
|
17
|
-
end
|
18
|
-
|
19
|
-
let :filtered_scope do
|
20
|
-
subject.scope
|
21
|
-
end
|
22
|
-
|
23
|
-
describe 'by result' do
|
24
|
-
let(:params) { { result: 'warning' } }
|
25
|
-
|
26
|
-
it 'filters' do
|
27
|
-
_(filtered_scope.count).must_equal @tasks_builder.distribution['stopped'][:by_result]['warning'][:total]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe 'by state' do
|
32
|
-
let(:params) { { state: 'running' } }
|
33
|
-
|
34
|
-
it 'filters' do
|
35
|
-
_(filtered_scope.count).must_equal @tasks_builder.distribution['running'][:total]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe 'recent' do
|
40
|
-
let(:params) do
|
41
|
-
{ state: 'running',
|
42
|
-
time_horizon: 'H24',
|
43
|
-
time_mode: 'recent' }
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'filters' do
|
47
|
-
_(filtered_scope.count).must_equal @tasks_builder.distribution['running'][:recent]
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe 'recent week time horizon' do
|
52
|
-
let(:params) do
|
53
|
-
{ state: 'running',
|
54
|
-
time_horizon: 'week',
|
55
|
-
time_mode: 'recent' }
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'filters' do
|
59
|
-
_(filtered_scope.count).must_equal @tasks_builder.distribution['running'][:recent]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe 'older' do
|
64
|
-
let(:params) do
|
65
|
-
{ state: 'running',
|
66
|
-
time_horizon: 'H24',
|
67
|
-
time_mode: 'older' }
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'filters' do
|
71
|
-
old_tasks_count = @tasks_builder.distribution['running'][:total] -
|
72
|
-
@tasks_builder.distribution['running'][:recent]
|
73
|
-
_(filtered_scope.count).must_equal old_tasks_count
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|