foreman-tasks 0.17.6 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintrc +2 -22
- data/.rubocop.yml +12 -12
- data/.rubocop_todo.yml +34 -116
- data/.travis.yml +2 -2
- data/app/controllers/foreman_tasks/api/recurring_logics_controller.rb +20 -1
- data/app/controllers/foreman_tasks/api/tasks_controller.rb +66 -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/controllers/foreman_tasks/tasks_controller.rb +3 -11
- data/app/helpers/foreman_tasks/foreman_tasks_helper.rb +0 -2
- 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 +8 -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 +7 -2
- 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/services/ui_notifications/tasks/task_bulk_stop.rb +36 -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 -1
- 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/babel.config.js +3 -0
- data/config/routes.rb +8 -0
- data/db/migrate/20200517215015_rename_bookmarks_controller.rb +35 -0
- data/db/migrate/20200519093217_drop_dynflow_allow_dangerous_actions_setting.foreman_tasks.rb +5 -0
- data/db/seeds.d/30-notification_blueprints.rb +21 -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 +1 -1
- data/lib/foreman_tasks/tasks/export_tasks.rake +2 -2
- data/lib/foreman_tasks/test_extensions.rb +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/locale/action_names.rb +2 -2
- data/locale/en/foreman_tasks.po +227 -41
- data/locale/foreman_tasks.pot +579 -288
- data/package.json +19 -79
- 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/TaskActions/TaskAction.test.js +60 -0
- data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.js +67 -0
- data/webpack/ForemanTasks/Components/TaskActions/TaskActionHelpers.test.js +46 -0
- data/webpack/ForemanTasks/Components/TaskActions/TaskActionsConstants.js +16 -0
- data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.js +60 -0
- data/webpack/ForemanTasks/Components/TaskActions/UnlockModals.test.js +14 -0
- data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/TaskAction.test.js.snap +233 -0
- data/webpack/ForemanTasks/Components/TaskActions/__snapshots__/UnlockModals.test.js.snap +25 -0
- data/webpack/ForemanTasks/Components/TaskActions/index.js +115 -0
- data/webpack/ForemanTasks/Components/TaskDetails/Components/Task.js +132 -150
- data/webpack/ForemanTasks/Components/TaskDetails/Components/TaskInfo.js +1 -4
- 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 +68 -3
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskInfo.test.js +1 -2
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +104 -71
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/TaskInfo.test.js.snap +9 -15
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.stories.js +6 -2
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +2 -17
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsConstants.js +0 -5
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsReducer.js +0 -6
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +3 -9
- data/webpack/ForemanTasks/Components/TaskDetails/TasksDetailsHelper.js +6 -1
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +6 -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 +3 -7
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +5 -1
- data/webpack/ForemanTasks/Components/TaskDetails/index.js +6 -8
- 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/ActionSelectButton.js +14 -1
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModal.js +83 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js +106 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js +38 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalSelectors.js +45 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModal.test.js +36 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalActions.test.js +205 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalReducer.test.js +27 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/ConfirmModalSelectors.test.js +54 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModal.test.js.snap +41 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalReducer.test.js.snap +19 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/__test__/__snapshots__/ConfirmModalSelectors.test.js.snap +30 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/index.js +29 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/SelectAllAlert.js +43 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +2 -1
- 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__/ActionSelectButton.test.js.snap +11 -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 +247 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +50 -22
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +62 -101
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +18 -5
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +4 -3
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +65 -38
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +26 -9
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSchema.js +2 -2
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +27 -16
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/SubTasksPage.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +147 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksIndexPage.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +4 -7
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +46 -74
- 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 +5 -7
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +336 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +4 -7
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +22 -158
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +66 -44
- 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 +49 -21
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +61 -14
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +80 -21
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.scss +9 -0
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/ClickConfirmation.test.js +44 -0
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/__snapshots__/ClickConfirmation.test.js.snap +52 -0
- data/webpack/ForemanTasks/Components/common/ClickConfirmation/index.js +59 -66
- data/webpack/ForemanTasks/Components/common/ToastsHelpers/ToastTypesConstants.js +11 -0
- data/webpack/ForemanTasks/Components/common/ToastsHelpers/index.js +15 -0
- data/webpack/ForemanTasks/ForemanTasks.test.js +1 -1
- data/webpack/ForemanTasks/ForemanTasksReducers.js +2 -0
- data/webpack/ForemanTasks/Routes/ForemanTasksRouter.test.js +1 -1
- data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +4 -4
- 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 +18 -0
- data/webpack/__mocks__/foremanReact/components/common/ActionButtons/ActionButtons.js +3 -0
- metadata +71 -30
- data/.babelrc +0 -35
- data/.storybook/addons.js +0 -2
- data/.storybook/config.js +0 -7
- data/.storybook/webpack.config.js +0 -63
- 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/ForemanTasks/Components/common/ActionButtons/CancelButton.js +0 -23
- data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.test.js +0 -27
- data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.js +0 -23
- data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.test.js +0 -27
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/CancelButton.test.js.snap +0 -15
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ResumeButton.test.js.snap +0 -15
- data/webpack/stories/index.js +0 -10
- data/webpack/stories/index.scss +0 -7
- data/webpack/test_setup.js +0 -6
@@ -1,9 +1,26 @@
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
2
|
|
3
|
+
exports[`TasksTableReducer reducer should handle OPEN_SELECT_ALL 1`] = `
|
4
|
+
Object {
|
5
|
+
"tasksTableQuery": Object {
|
6
|
+
"selectedRows": Array [],
|
7
|
+
"showSelectAll": true,
|
8
|
+
},
|
9
|
+
}
|
10
|
+
`;
|
11
|
+
|
12
|
+
exports[`TasksTableReducer reducer should handle SELECT_ALL_ROWS 1`] = `
|
13
|
+
Object {
|
14
|
+
"tasksTableQuery": Object {
|
15
|
+
"allRowsSelected": true,
|
16
|
+
"selectedRows": Array [],
|
17
|
+
},
|
18
|
+
}
|
19
|
+
`;
|
20
|
+
|
3
21
|
exports[`TasksTableReducer reducer should handle SELECT_ROWS 1`] = `
|
4
22
|
Object {
|
5
23
|
"tasksTableQuery": Object {
|
6
|
-
"modalStatus": "CLOSED",
|
7
24
|
"selectedRows": Array [
|
8
25
|
1,
|
9
26
|
2,
|
@@ -17,19 +34,9 @@ Object {
|
|
17
34
|
}
|
18
35
|
`;
|
19
36
|
|
20
|
-
exports[`TasksTableReducer reducer should handle TASKS_TABLE_SELECTED_MODAL 1`] = `
|
21
|
-
Object {
|
22
|
-
"tasksTableQuery": Object {
|
23
|
-
"modalStatus": "RESUME",
|
24
|
-
"selectedRows": Array [],
|
25
|
-
},
|
26
|
-
}
|
27
|
-
`;
|
28
|
-
|
29
37
|
exports[`TasksTableReducer reducer should handle TASKS_TABLE_SET_PAGINATION 1`] = `
|
30
38
|
Object {
|
31
39
|
"tasksTableQuery": Object {
|
32
|
-
"modalStatus": "CLOSED",
|
33
40
|
"selectedRows": Array [],
|
34
41
|
},
|
35
42
|
}
|
@@ -38,7 +45,6 @@ Object {
|
|
38
45
|
exports[`TasksTableReducer reducer should handle TASKS_TABLE_SET_SORT 1`] = `
|
39
46
|
Object {
|
40
47
|
"tasksTableQuery": Object {
|
41
|
-
"modalStatus": "CLOSED",
|
42
48
|
"selectedRows": Array [],
|
43
49
|
},
|
44
50
|
}
|
@@ -49,7 +55,6 @@ Object {
|
|
49
55
|
"tasksTableQuery": Object {
|
50
56
|
"actionName": undefined,
|
51
57
|
"itemCount": 120,
|
52
|
-
"modalStatus": "CLOSED",
|
53
58
|
"pagination": Object {
|
54
59
|
"page": 3,
|
55
60
|
"perPage": 12,
|
@@ -62,8 +67,9 @@ Object {
|
|
62
67
|
exports[`TasksTableReducer reducer should handle UNSELECT_ALL_ROWS 1`] = `
|
63
68
|
Object {
|
64
69
|
"tasksTableQuery": Object {
|
65
|
-
"
|
70
|
+
"allRowsSelected": false,
|
66
71
|
"selectedRows": Array [],
|
72
|
+
"showSelectAll": false,
|
67
73
|
},
|
68
74
|
}
|
69
75
|
`;
|
@@ -71,7 +77,29 @@ Object {
|
|
71
77
|
exports[`TasksTableReducer reducer should handle UNSELECT_ROWS 1`] = `
|
72
78
|
Object {
|
73
79
|
"tasksTableQuery": Object {
|
74
|
-
"
|
80
|
+
"selectedRows": Array [],
|
81
|
+
},
|
82
|
+
}
|
83
|
+
`;
|
84
|
+
|
85
|
+
exports[`TasksTableReducer reducer should handle UNSELECT_ROWS with all rows selected 1`] = `
|
86
|
+
Object {
|
87
|
+
"tasksTableQuery": Object {
|
88
|
+
"allRowsSelected": false,
|
89
|
+
"selectedRows": Array [
|
90
|
+
3,
|
91
|
+
4,
|
92
|
+
5,
|
93
|
+
],
|
94
|
+
"showSelectAll": false,
|
95
|
+
},
|
96
|
+
}
|
97
|
+
`;
|
98
|
+
|
99
|
+
exports[`TasksTableReducer reducer should handle UPDATE_CLICKED 1`] = `
|
100
|
+
Object {
|
101
|
+
"tasksTableQuery": Object {
|
102
|
+
"clicked": "task",
|
75
103
|
"selectedRows": Array [],
|
76
104
|
},
|
77
105
|
}
|
@@ -80,7 +108,6 @@ Object {
|
|
80
108
|
exports[`TasksTableReducer reducer should return the initial state 1`] = `
|
81
109
|
Object {
|
82
110
|
"tasksTableQuery": Object {
|
83
|
-
"modalStatus": "CLOSED",
|
84
111
|
"selectedRows": Array [],
|
85
112
|
},
|
86
113
|
}
|
@@ -4,7 +4,7 @@ import TableSelectionHeaderCell from '../Components/TableSelectionHeaderCell';
|
|
4
4
|
export default (selectionController, label) => (
|
5
5
|
<TableSelectionHeaderCell
|
6
6
|
label={label}
|
7
|
-
checked={selectionController.
|
8
|
-
onChange={
|
7
|
+
checked={selectionController.allPageSelected()}
|
8
|
+
onChange={selectionController.selectPage}
|
9
9
|
/>
|
10
10
|
);
|
@@ -2,7 +2,8 @@ import { connect } from 'react-redux';
|
|
2
2
|
import { bindActionCreators } from 'redux';
|
3
3
|
import TasksTablePage from './TasksTablePage';
|
4
4
|
import reducer from './TasksTableReducer';
|
5
|
-
import * as
|
5
|
+
import * as tableActions from './TasksTableActions';
|
6
|
+
import * as bulkActions from './TasksBulkActions';
|
6
7
|
import {
|
7
8
|
selectStatus,
|
8
9
|
selectError,
|
@@ -12,7 +13,9 @@ import {
|
|
12
13
|
selectSort,
|
13
14
|
selectActionName,
|
14
15
|
selectSelectedRows,
|
15
|
-
|
16
|
+
selectAllRowsSelected,
|
17
|
+
selectShowSelectAll,
|
18
|
+
selectModalID,
|
16
19
|
} from './TasksTableSelectors';
|
17
20
|
|
18
21
|
const mapStateToProps = state => ({
|
@@ -24,9 +27,13 @@ const mapStateToProps = state => ({
|
|
24
27
|
itemCount: selectItemCount(state),
|
25
28
|
actionName: selectActionName(state),
|
26
29
|
selectedRows: selectSelectedRows(state),
|
27
|
-
|
30
|
+
allRowsSelected: selectAllRowsSelected(state),
|
31
|
+
showSelectAll: selectShowSelectAll(state),
|
32
|
+
modalID: selectModalID(state),
|
28
33
|
});
|
29
|
-
|
34
|
+
|
35
|
+
const mapDispatchToProps = dispatch =>
|
36
|
+
bindActionCreators({ ...tableActions, ...bulkActions }, dispatch);
|
30
37
|
|
31
38
|
export const reducers = { tasksTable: reducer };
|
32
39
|
|
@@ -1,27 +1,53 @@
|
|
1
1
|
import React from 'react';
|
2
2
|
import PropTypes from 'prop-types';
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
4
|
+
import { ActionButtons } from 'foremanReact/components/common/ActionButtons/ActionButtons';
|
5
5
|
|
6
|
-
export const ActionButton = ({
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
6
|
+
export const ActionButton = ({
|
7
|
+
id,
|
8
|
+
name,
|
9
|
+
availableActions: { resumable, cancellable, stoppable },
|
10
|
+
taskActions,
|
11
|
+
}) => {
|
12
|
+
const buttons = [];
|
13
|
+
const isTitle = !(resumable || cancellable || stoppable);
|
14
|
+
const title = isTitle ? __('Task cannot be canceled') : undefined;
|
15
|
+
if (resumable) {
|
16
|
+
buttons.push({
|
17
|
+
title: __('Resume'),
|
18
|
+
action: {
|
19
|
+
disabled: !resumable,
|
20
|
+
onClick: () => taskActions.resumeTask(id, name),
|
21
|
+
id: `task-resume-button-${id}`,
|
22
|
+
},
|
23
|
+
});
|
24
|
+
}
|
25
|
+
if (cancellable || (!stoppable && !resumable)) {
|
26
|
+
// Cancel is the default button that should be shown if no task action can be done
|
27
|
+
buttons.push({
|
28
|
+
title: __('Cancel'),
|
29
|
+
action: {
|
30
|
+
disabled: !cancellable,
|
31
|
+
onClick: () => taskActions.cancelTask(id, name),
|
32
|
+
id: `task-cancel-button-${id}`,
|
33
|
+
},
|
34
|
+
});
|
35
|
+
}
|
36
|
+
|
37
|
+
if (stoppable) {
|
38
|
+
buttons.push({
|
39
|
+
title: __('Force Cancel'),
|
40
|
+
action: {
|
41
|
+
disabled: !stoppable,
|
42
|
+
onClick: () => taskActions.forceCancelTask(id, name),
|
43
|
+
id: `task-force-cancel-button-${id}`,
|
44
|
+
},
|
45
|
+
});
|
17
46
|
}
|
18
47
|
return (
|
19
|
-
<
|
20
|
-
|
21
|
-
|
22
|
-
disabled={!availableActions.cancellable}
|
23
|
-
onClick={taskActions.cancel}
|
24
|
-
/>
|
48
|
+
<span title={title}>
|
49
|
+
<ActionButtons buttons={buttons} />
|
50
|
+
</span>
|
25
51
|
);
|
26
52
|
};
|
27
53
|
|
@@ -31,9 +57,11 @@ ActionButton.propTypes = {
|
|
31
57
|
availableActions: PropTypes.shape({
|
32
58
|
cancellable: PropTypes.bool,
|
33
59
|
resumable: PropTypes.bool,
|
60
|
+
stoppable: PropTypes.bool,
|
34
61
|
}).isRequired,
|
35
62
|
taskActions: PropTypes.shape({
|
36
|
-
|
37
|
-
|
63
|
+
cancelTask: PropTypes.func,
|
64
|
+
resumeTask: PropTypes.func,
|
65
|
+
forceCancelTask: PropTypes.func,
|
38
66
|
}).isRequired,
|
39
67
|
};
|
@@ -1,17 +1,19 @@
|
|
1
|
-
import
|
1
|
+
import React from 'react';
|
2
|
+
import { testComponentSnapshotsWithFixtures, shallow } from '@theforeman/test';
|
2
3
|
|
3
4
|
import { ActionButton } from './ActionButton';
|
4
5
|
|
6
|
+
const resumeTask = jest.fn();
|
7
|
+
const cancelTask = jest.fn();
|
8
|
+
const forceCancelTask = jest.fn();
|
9
|
+
const taskActions = { resumeTask, cancelTask, forceCancelTask };
|
5
10
|
const fixtures = {
|
6
11
|
'render with cancellable true props': {
|
7
12
|
availableActions: {
|
8
13
|
cancellable: true,
|
9
14
|
resumable: false,
|
10
15
|
},
|
11
|
-
taskActions
|
12
|
-
cancel: jest.fn(),
|
13
|
-
resume: jest.fn(),
|
14
|
-
},
|
16
|
+
taskActions,
|
15
17
|
id: 'id',
|
16
18
|
name: 'some-name',
|
17
19
|
},
|
@@ -20,10 +22,16 @@ const fixtures = {
|
|
20
22
|
cancellable: false,
|
21
23
|
resumable: true,
|
22
24
|
},
|
23
|
-
taskActions
|
24
|
-
|
25
|
-
|
25
|
+
taskActions,
|
26
|
+
id: 'id',
|
27
|
+
name: 'some-name',
|
28
|
+
},
|
29
|
+
'render with stoppable and cancellable true props': {
|
30
|
+
availableActions: {
|
31
|
+
cancellable: true,
|
32
|
+
stoppable: true,
|
26
33
|
},
|
34
|
+
taskActions,
|
27
35
|
id: 'id',
|
28
36
|
name: 'some-name',
|
29
37
|
},
|
@@ -32,14 +40,53 @@ const fixtures = {
|
|
32
40
|
cancellable: false,
|
33
41
|
resumable: false,
|
34
42
|
},
|
35
|
-
taskActions
|
36
|
-
cancel: jest.fn(),
|
37
|
-
resume: jest.fn(),
|
38
|
-
},
|
43
|
+
taskActions,
|
39
44
|
id: 'id',
|
40
45
|
name: 'some-name',
|
41
46
|
},
|
42
47
|
};
|
43
48
|
|
44
|
-
describe('ActionButton', () =>
|
45
|
-
|
49
|
+
describe('ActionButton', () => {
|
50
|
+
describe('snapshot test', () =>
|
51
|
+
testComponentSnapshotsWithFixtures(ActionButton, fixtures));
|
52
|
+
describe('click test', () => {
|
53
|
+
const id = 'some-id';
|
54
|
+
const name = 'some-name';
|
55
|
+
it('cancel', () => {
|
56
|
+
const component = shallow(
|
57
|
+
<ActionButton
|
58
|
+
id={id}
|
59
|
+
name={name}
|
60
|
+
availableActions={{ cancellable: true }}
|
61
|
+
taskActions={taskActions}
|
62
|
+
/>
|
63
|
+
).children();
|
64
|
+
component.props().buttons[0].action.onClick();
|
65
|
+
expect(cancelTask).toHaveBeenCalledWith(id, name);
|
66
|
+
});
|
67
|
+
it('resume', () => {
|
68
|
+
const component = shallow(
|
69
|
+
<ActionButton
|
70
|
+
id={id}
|
71
|
+
name={name}
|
72
|
+
availableActions={{ resumable: true }}
|
73
|
+
taskActions={taskActions}
|
74
|
+
/>
|
75
|
+
).children();
|
76
|
+
component.props().buttons[0].action.onClick();
|
77
|
+
expect(resumeTask).toHaveBeenCalledWith(id, name);
|
78
|
+
});
|
79
|
+
it('force cancel', () => {
|
80
|
+
const component = shallow(
|
81
|
+
<ActionButton
|
82
|
+
id={id}
|
83
|
+
name={name}
|
84
|
+
availableActions={{ stoppable: true }}
|
85
|
+
taskActions={taskActions}
|
86
|
+
/>
|
87
|
+
).children();
|
88
|
+
component.props().buttons[0].action.onClick();
|
89
|
+
expect(cancelTask).toHaveBeenCalledWith(id, name);
|
90
|
+
});
|
91
|
+
});
|
92
|
+
});
|
data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap
CHANGED
@@ -1,28 +1,87 @@
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
2
|
|
3
|
-
exports[`ActionButton render with cancellable false props 1`] = `
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
exports[`ActionButton snapshot test render with cancellable false props 1`] = `
|
4
|
+
<span
|
5
|
+
title="Task cannot be canceled"
|
6
|
+
>
|
7
|
+
<ActionButtons
|
8
|
+
buttons={
|
9
|
+
Array [
|
10
|
+
Object {
|
11
|
+
"action": Object {
|
12
|
+
"disabled": true,
|
13
|
+
"id": "task-cancel-button-id",
|
14
|
+
"onClick": [Function],
|
15
|
+
},
|
16
|
+
"title": "Cancel",
|
17
|
+
},
|
18
|
+
]
|
19
|
+
}
|
20
|
+
/>
|
21
|
+
</span>
|
10
22
|
`;
|
11
23
|
|
12
|
-
exports[`ActionButton render with cancellable true props 1`] = `
|
13
|
-
<
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
24
|
+
exports[`ActionButton snapshot test render with cancellable true props 1`] = `
|
25
|
+
<span>
|
26
|
+
<ActionButtons
|
27
|
+
buttons={
|
28
|
+
Array [
|
29
|
+
Object {
|
30
|
+
"action": Object {
|
31
|
+
"disabled": false,
|
32
|
+
"id": "task-cancel-button-id",
|
33
|
+
"onClick": [Function],
|
34
|
+
},
|
35
|
+
"title": "Cancel",
|
36
|
+
},
|
37
|
+
]
|
38
|
+
}
|
39
|
+
/>
|
40
|
+
</span>
|
19
41
|
`;
|
20
42
|
|
21
|
-
exports[`ActionButton render with resumable true props 1`] = `
|
22
|
-
<
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
43
|
+
exports[`ActionButton snapshot test render with resumable true props 1`] = `
|
44
|
+
<span>
|
45
|
+
<ActionButtons
|
46
|
+
buttons={
|
47
|
+
Array [
|
48
|
+
Object {
|
49
|
+
"action": Object {
|
50
|
+
"disabled": false,
|
51
|
+
"id": "task-resume-button-id",
|
52
|
+
"onClick": [Function],
|
53
|
+
},
|
54
|
+
"title": "Resume",
|
55
|
+
},
|
56
|
+
]
|
57
|
+
}
|
58
|
+
/>
|
59
|
+
</span>
|
60
|
+
`;
|
61
|
+
|
62
|
+
exports[`ActionButton snapshot test render with stoppable and cancellable true props 1`] = `
|
63
|
+
<span>
|
64
|
+
<ActionButtons
|
65
|
+
buttons={
|
66
|
+
Array [
|
67
|
+
Object {
|
68
|
+
"action": Object {
|
69
|
+
"disabled": false,
|
70
|
+
"id": "task-cancel-button-id",
|
71
|
+
"onClick": [Function],
|
72
|
+
},
|
73
|
+
"title": "Cancel",
|
74
|
+
},
|
75
|
+
Object {
|
76
|
+
"action": Object {
|
77
|
+
"disabled": false,
|
78
|
+
"id": "task-force-cancel-button-id",
|
79
|
+
"onClick": [Function],
|
80
|
+
},
|
81
|
+
"title": "Force Cancel",
|
82
|
+
},
|
83
|
+
]
|
84
|
+
}
|
85
|
+
/>
|
86
|
+
</span>
|
28
87
|
`;
|