foreman-tasks 1.0.0 → 2.0.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/README.md +2 -0
- 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 +1 -3
- data/app/lib/actions/helpers/humanizer.rb +1 -3
- data/app/lib/actions/proxy_action.rb +33 -12
- data/app/lib/foreman_tasks/concerns/polling_action_extensions.rb +12 -0
- data/app/models/foreman_tasks/concerns/action_triggering.rb +1 -1
- data/app/models/foreman_tasks/recurring_logic.rb +1 -0
- data/app/models/foreman_tasks/remote_task.rb +1 -0
- data/app/models/foreman_tasks/task.rb +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/foreman_tasks/troubleshooting_help_generator.rb +0 -4
- data/app/services/ui_notifications/tasks/task_bulk_cancel.rb +36 -0
- data/app/services/ui_notifications/tasks/task_bulk_resume.rb +38 -0
- data/app/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/{.babelrc.js → babel.config.js} +0 -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 +18 -71
- data/script/rails +2 -2
- data/script/travis_run_js_tests.sh +2 -2
- data/test/controllers/api/tasks_controller_test.rb +9 -0
- data/test/factories/task_factory.rb +34 -2
- data/test/foreman_tasks_test_helper.rb +4 -0
- data/test/lib/concerns/polling_action_extensions_test.rb +34 -0
- data/test/unit/actions/action_with_sub_plans_test.rb +1 -1
- data/test/unit/task_test.rb +160 -74
- data/webpack/ForemanTasks/Components/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 +3 -12
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Errors.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Locks.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Raw.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/RunningSteps.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/Task.test.js +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 +3 -9
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetails.stories.js +6 -2
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsActions.js +0 -15
- 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 +4 -10
- 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 +21 -9
- 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 +64 -42
- 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/.storybook/addons.js +0 -2
- data/.storybook/config.js +0 -7
- data/.storybook/webpack.config.js +0 -84
- data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/Components/TimeDropDown/TimeDropDown.stories.js +0 -23
- data/webpack/ForemanTasks/Components/TasksTable/Components/ActionConfirmation.js +0 -49
- data/webpack/ForemanTasks/Components/TasksTable/Components/CancelResumeConfirm.js +0 -51
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionConfirmation.test.js +0 -18
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelResumeConfirm.test.js +0 -28
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ActionConfirmation.test.js.snap +0 -89
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/CancelResumeConfirm.test.js.snap +0 -37
- data/webpack/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 -7
data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksLabelsRow/TasksLabelsRow.test.js
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
import React from 'react';
|
2
|
-
import { testComponentSnapshotsWithFixtures } from '
|
3
|
-
import { shallow } from 'enzyme';
|
2
|
+
import { testComponentSnapshotsWithFixtures, shallow } from '@theforeman/test';
|
4
3
|
|
5
4
|
import { getQueryKeyText, getQueryValueText } from '../../TasksDashboardHelper';
|
6
5
|
import TasksLabelsRow from './TasksLabelsRow';
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { Meta, Story, Preview, Props, action } from '@theforeman/stories';
|
2
|
+
|
3
|
+
import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../../../TasksDashboardConstants';
|
4
|
+
import TimeDropDown from './TimeDropDown';
|
5
|
+
|
6
|
+
<Meta
|
7
|
+
title="TasksDashboard/TasksTimeRow/TimeDropDown"
|
8
|
+
component={TimeDropDown}
|
9
|
+
/>
|
10
|
+
|
11
|
+
# TimeDropDown
|
12
|
+
|
13
|
+
Render a dropdown with the available dashboard times to render.
|
14
|
+
|
15
|
+
<Props of={TimeDropDown} />
|
16
|
+
|
17
|
+
The available-times defined as a constant at `Components/TasksDashboard/TasksDashboardConstants.js`:
|
18
|
+
|
19
|
+
```js
|
20
|
+
import { TASKS_DASHBOARD_AVAILABLE_TIMES } from './Components/TasksDashboard/TasksDashboardConstants';
|
21
|
+
```
|
22
|
+
|
23
|
+
To set the current selected time, set the `selectedTime` prop to `TASKS_DASHBOARD_AVAILABLE_TIMES.H24`.
|
24
|
+
|
25
|
+
<Preview>
|
26
|
+
<Story name="24 hours">
|
27
|
+
<TimeDropDown
|
28
|
+
id="time-period-dropdown"
|
29
|
+
selectedTime={TASKS_DASHBOARD_AVAILABLE_TIMES.H24}
|
30
|
+
onChange={action('onChange')}
|
31
|
+
/>
|
32
|
+
</Story>
|
33
|
+
</Preview>
|
34
|
+
|
35
|
+
To set the current selected time, set the `selectedTime` prop to `TASKS_DASHBOARD_AVAILABLE_TIMES.H12`.
|
36
|
+
|
37
|
+
<Preview>
|
38
|
+
<Story name="12 hours">
|
39
|
+
<TimeDropDown
|
40
|
+
id="time-period-dropdown"
|
41
|
+
selectedTime={TASKS_DASHBOARD_AVAILABLE_TIMES.H12}
|
42
|
+
onChange={action('onChange')}
|
43
|
+
/>
|
44
|
+
</Story>
|
45
|
+
</Preview>
|
46
|
+
|
47
|
+
To set the current selected time, set the `selectedTime` prop to `TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK`.
|
48
|
+
|
49
|
+
<Preview>
|
50
|
+
<Story name="week">
|
51
|
+
<TimeDropDown
|
52
|
+
id="time-period-dropdown"
|
53
|
+
selectedTime={TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK}
|
54
|
+
onChange={action('onChange')}
|
55
|
+
/>
|
56
|
+
</Story>
|
57
|
+
</Preview>
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { testComponentSnapshotsWithFixtures } from '
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
2
2
|
|
3
3
|
import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../../../TasksDashboardConstants';
|
4
4
|
import TimeDropDown from './TimeDropDown';
|
data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.stories.js
CHANGED
@@ -1,22 +1,40 @@
|
|
1
|
-
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import { action } from '@storybook/addon-actions';
|
5
|
-
import { withCardsDecorator } from '../../../../../stories/decorators';
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks */
|
2
|
+
import React, { useState } from 'react';
|
3
|
+
import { select, action } from '@theforeman/stories';
|
6
4
|
|
7
5
|
import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
|
8
6
|
import TasksTimeRow from './TasksTimeRow';
|
9
7
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
8
|
+
export default {
|
9
|
+
title: 'TasksDashboard/TasksTimeRow',
|
10
|
+
component: TasksTimeRow,
|
11
|
+
};
|
12
|
+
|
13
|
+
export const withState = () => {
|
14
|
+
const [time, updateTime] = useState(TASKS_DASHBOARD_AVAILABLE_TIMES.H24);
|
15
|
+
|
16
|
+
return <TasksTimeRow time={time} updateTime={updateTime} />;
|
17
|
+
};
|
18
|
+
|
19
|
+
export const withKnobs = () => (
|
20
|
+
<TasksTimeRow
|
21
|
+
time={select(
|
22
|
+
'time',
|
23
|
+
TASKS_DASHBOARD_AVAILABLE_TIMES,
|
24
|
+
TASKS_DASHBOARD_AVAILABLE_TIMES.H24
|
25
|
+
)}
|
26
|
+
updateTime={action('updateTime')}
|
27
|
+
/>
|
28
|
+
);
|
29
|
+
|
30
|
+
export const with24Hours = () => (
|
31
|
+
<TasksTimeRow time={TASKS_DASHBOARD_AVAILABLE_TIMES.H24} />
|
32
|
+
);
|
33
|
+
|
34
|
+
export const with12Hours = () => (
|
35
|
+
<TasksTimeRow time={TASKS_DASHBOARD_AVAILABLE_TIMES.H12} />
|
36
|
+
);
|
37
|
+
|
38
|
+
export const withWeek = () => (
|
39
|
+
<TasksTimeRow time={TASKS_DASHBOARD_AVAILABLE_TIMES.WEEK} />
|
40
|
+
);
|
data/webpack/ForemanTasks/Components/TasksDashboard/Components/TasksTimeRow/TasksTimeRow.test.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { testComponentSnapshotsWithFixtures } from '
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
2
2
|
|
3
3
|
import { TASKS_DASHBOARD_AVAILABLE_TIMES } from '../../TasksDashboardConstants';
|
4
4
|
import TasksTimeRow from './TasksTimeRow';
|
@@ -18,6 +18,11 @@ export const TASKS_DASHBOARD_AVAILABLE_QUERY_MODES = {
|
|
18
18
|
OLDER: 'older',
|
19
19
|
};
|
20
20
|
|
21
|
+
export const TASKS_DASHBOARD_JS_QUERY_MODES = {
|
22
|
+
RECENT: 'recent',
|
23
|
+
OLDER: 'older',
|
24
|
+
};
|
25
|
+
|
21
26
|
export const TASKS_DASHBOARD_AVAILABLE_TIMES = {
|
22
27
|
H24: 'H24',
|
23
28
|
H12: 'H12',
|
@@ -4,6 +4,7 @@ import {
|
|
4
4
|
TASKS_DASHBOARD_AVAILABLE_TIMES,
|
5
5
|
TASKS_DASHBOARD_QUERY_KEYS_TEXT,
|
6
6
|
TASKS_DASHBOARD_QUERY_VALUES_TEXT,
|
7
|
+
TASKS_DASHBOARD_JS_QUERY_MODES,
|
7
8
|
} from './TasksDashboardConstants';
|
8
9
|
import { updateURlQuery } from '../TasksTable/TasksTableHelpers';
|
9
10
|
|
@@ -39,8 +40,8 @@ const queryFromUriQuery = uriQuery => {
|
|
39
40
|
if (uriQuery[uriField]) query[queryField] = uriQuery[uriField];
|
40
41
|
});
|
41
42
|
|
42
|
-
if (query.mode ===
|
43
|
-
query.mode =
|
43
|
+
if (query.mode === TASKS_DASHBOARD_JS_QUERY_MODES.RECENT) {
|
44
|
+
query.mode = TASKS_DASHBOARD_QUERY_VALUES_TEXT.LAST;
|
44
45
|
}
|
45
46
|
|
46
47
|
return query;
|
@@ -3,7 +3,12 @@ import { DropdownButton, MenuItem } from 'patternfly-react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
4
4
|
import { translate as __ } from 'foremanReact/common/I18n';
|
5
5
|
|
6
|
-
export const ActionSelectButton = ({
|
6
|
+
export const ActionSelectButton = ({
|
7
|
+
onCancel,
|
8
|
+
onResume,
|
9
|
+
onForceCancel,
|
10
|
+
disabled,
|
11
|
+
}) => (
|
7
12
|
<DropdownButton
|
8
13
|
title={__('Select Action')}
|
9
14
|
disabled={disabled}
|
@@ -23,6 +28,13 @@ export const ActionSelectButton = ({ onCancel, onResume, disabled }) => (
|
|
23
28
|
>
|
24
29
|
{__('Resume Selected')}
|
25
30
|
</MenuItem>
|
31
|
+
<MenuItem
|
32
|
+
title={__('Force Cancel selected tasks')}
|
33
|
+
onClick={onForceCancel}
|
34
|
+
eventKey="3"
|
35
|
+
>
|
36
|
+
{__('Force Cancel Selected')}
|
37
|
+
</MenuItem>
|
26
38
|
</DropdownButton>
|
27
39
|
);
|
28
40
|
|
@@ -30,6 +42,7 @@ ActionSelectButton.propTypes = {
|
|
30
42
|
disabled: PropTypes.bool,
|
31
43
|
onCancel: PropTypes.func.isRequired,
|
32
44
|
onResume: PropTypes.func.isRequired,
|
45
|
+
onForceCancel: PropTypes.func.isRequired,
|
33
46
|
};
|
34
47
|
|
35
48
|
ActionSelectButton.defaultProps = {
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { startCase } from 'lodash';
|
4
|
+
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
|
5
|
+
import { Button } from 'patternfly-react';
|
6
|
+
import ForemanModal from 'foremanReact/components/ForemanModal';
|
7
|
+
import { FORCE_UNLOCK_MODAL } from '../../../TaskActions/TaskActionsConstants';
|
8
|
+
import { FORCE_UNLOCK_SELECTED_MODAL } from '../../TasksTableConstants';
|
9
|
+
import { ForceUnlockModal } from '../../../TaskActions/UnlockModals';
|
10
|
+
|
11
|
+
export const ConfirmModal = ({
|
12
|
+
actionText,
|
13
|
+
actionState,
|
14
|
+
actionType,
|
15
|
+
selectedRowsLen,
|
16
|
+
id,
|
17
|
+
parentTaskID,
|
18
|
+
url,
|
19
|
+
uriQuery: query,
|
20
|
+
setModalClosed,
|
21
|
+
...props
|
22
|
+
}) => {
|
23
|
+
if ([FORCE_UNLOCK_MODAL, FORCE_UNLOCK_SELECTED_MODAL].includes(actionType)) {
|
24
|
+
return (
|
25
|
+
<ForceUnlockModal
|
26
|
+
onClick={() => {
|
27
|
+
props[actionType]({ url, query, parentTaskID });
|
28
|
+
setModalClosed();
|
29
|
+
}}
|
30
|
+
id={id}
|
31
|
+
selectedRowsLen={selectedRowsLen}
|
32
|
+
/>
|
33
|
+
);
|
34
|
+
}
|
35
|
+
return (
|
36
|
+
<ForemanModal
|
37
|
+
title={sprintf(__('%s Selected Tasks'), startCase(actionText))}
|
38
|
+
id={id}
|
39
|
+
>
|
40
|
+
{sprintf(
|
41
|
+
__(
|
42
|
+
`This will %(action)s %(number)s task(s), putting them in the %(state)s state. Are you sure?`
|
43
|
+
),
|
44
|
+
{ action: actionText, number: selectedRowsLen, state: actionState }
|
45
|
+
)}
|
46
|
+
<ForemanModal.Footer>
|
47
|
+
<Button onClick={setModalClosed}>{__('No')}</Button>
|
48
|
+
<Button
|
49
|
+
className="confirm-button"
|
50
|
+
bsStyle="primary"
|
51
|
+
onClick={() => {
|
52
|
+
props[actionType]({ url, query, parentTaskID });
|
53
|
+
setModalClosed();
|
54
|
+
}}
|
55
|
+
>
|
56
|
+
{__('Yes')}
|
57
|
+
</Button>
|
58
|
+
</ForemanModal.Footer>
|
59
|
+
</ForemanModal>
|
60
|
+
);
|
61
|
+
};
|
62
|
+
|
63
|
+
ConfirmModal.propTypes = {
|
64
|
+
actionText: PropTypes.string,
|
65
|
+
actionState: PropTypes.string,
|
66
|
+
selectedRowsLen: PropTypes.number.isRequired,
|
67
|
+
actionType: PropTypes.string,
|
68
|
+
id: PropTypes.string.isRequired,
|
69
|
+
parentTaskID: PropTypes.string,
|
70
|
+
url: PropTypes.string.isRequired,
|
71
|
+
uriQuery: PropTypes.object,
|
72
|
+
setModalClosed: PropTypes.func.isRequired,
|
73
|
+
};
|
74
|
+
|
75
|
+
ConfirmModal.defaultProps = {
|
76
|
+
actionType: '',
|
77
|
+
actionText: '',
|
78
|
+
actionState: '',
|
79
|
+
parentTaskID: '',
|
80
|
+
uriQuery: {},
|
81
|
+
};
|
82
|
+
|
83
|
+
export default ConfirmModal;
|
data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalActions.js
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
import {
|
2
|
+
resumeTask,
|
3
|
+
cancelTask,
|
4
|
+
forceCancelTask,
|
5
|
+
} from '../../TasksTableActions';
|
6
|
+
import {
|
7
|
+
bulkCancelBySearch,
|
8
|
+
bulkCancelById,
|
9
|
+
bulkResumeBySearch,
|
10
|
+
bulkResumeById,
|
11
|
+
bulkForceCancelBySearch,
|
12
|
+
bulkForceCancelById,
|
13
|
+
} from '../../TasksBulkActions';
|
14
|
+
import { selectClicked, selectSelectedTasks } from './ConfirmModalSelectors';
|
15
|
+
import { selectAllRowsSelected } from '../../TasksTableSelectors';
|
16
|
+
import {
|
17
|
+
CANCEL_MODAL,
|
18
|
+
RESUME_MODAL,
|
19
|
+
CANCEL_SELECTED_MODAL,
|
20
|
+
RESUME_SELECTED_MODAL,
|
21
|
+
FORCE_UNLOCK_SELECTED_MODAL,
|
22
|
+
} from '../../TasksTableConstants';
|
23
|
+
import { FORCE_UNLOCK_MODAL } from '../../../TaskActions/TaskActionsConstants';
|
24
|
+
|
25
|
+
export default {
|
26
|
+
[CANCEL_SELECTED_MODAL]: ({ url, query, parentTaskID }) => (
|
27
|
+
dispatch,
|
28
|
+
getState
|
29
|
+
) => {
|
30
|
+
if (selectAllRowsSelected(getState())) {
|
31
|
+
return dispatch(bulkCancelBySearch({ query, parentTaskID }));
|
32
|
+
}
|
33
|
+
return dispatch(
|
34
|
+
bulkCancelById({
|
35
|
+
selected: selectSelectedTasks(getState()),
|
36
|
+
url,
|
37
|
+
parentTaskID,
|
38
|
+
})
|
39
|
+
);
|
40
|
+
},
|
41
|
+
[CANCEL_MODAL]: ({ url, parentTaskID }) => (dispatch, getState) => {
|
42
|
+
const { taskId, taskName } = selectClicked(getState());
|
43
|
+
return dispatch(
|
44
|
+
cancelTask({
|
45
|
+
taskId,
|
46
|
+
taskName,
|
47
|
+
url,
|
48
|
+
parentTaskID,
|
49
|
+
})
|
50
|
+
);
|
51
|
+
},
|
52
|
+
[RESUME_SELECTED_MODAL]: ({ url, query, parentTaskID }) => (
|
53
|
+
dispatch,
|
54
|
+
getState
|
55
|
+
) => {
|
56
|
+
if (selectAllRowsSelected(getState())) {
|
57
|
+
return dispatch(bulkResumeBySearch({ query, parentTaskID }));
|
58
|
+
}
|
59
|
+
return dispatch(
|
60
|
+
bulkResumeById({
|
61
|
+
selected: selectSelectedTasks(getState()),
|
62
|
+
url,
|
63
|
+
parentTaskID,
|
64
|
+
})
|
65
|
+
);
|
66
|
+
},
|
67
|
+
|
68
|
+
[RESUME_MODAL]: ({ url, parentTaskID }) => (dispatch, getState) => {
|
69
|
+
const { taskId, taskName } = selectClicked(getState());
|
70
|
+
return dispatch(
|
71
|
+
resumeTask({
|
72
|
+
taskId,
|
73
|
+
taskName,
|
74
|
+
url,
|
75
|
+
parentTaskID,
|
76
|
+
})
|
77
|
+
);
|
78
|
+
},
|
79
|
+
|
80
|
+
[FORCE_UNLOCK_MODAL]: ({ url, parentTaskID }) => (dispatch, getState) => {
|
81
|
+
const { taskId, taskName } = selectClicked(getState());
|
82
|
+
return dispatch(
|
83
|
+
forceCancelTask({
|
84
|
+
taskId,
|
85
|
+
taskName,
|
86
|
+
url,
|
87
|
+
parentTaskID,
|
88
|
+
})
|
89
|
+
);
|
90
|
+
},
|
91
|
+
[FORCE_UNLOCK_SELECTED_MODAL]: ({ url, query, parentTaskID }) => (
|
92
|
+
dispatch,
|
93
|
+
getState
|
94
|
+
) => {
|
95
|
+
if (selectAllRowsSelected(getState())) {
|
96
|
+
return dispatch(bulkForceCancelBySearch({ query, parentTaskID }));
|
97
|
+
}
|
98
|
+
return dispatch(
|
99
|
+
bulkForceCancelById({
|
100
|
+
selected: selectSelectedTasks(getState()),
|
101
|
+
url,
|
102
|
+
parentTaskID,
|
103
|
+
})
|
104
|
+
);
|
105
|
+
},
|
106
|
+
};
|
data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmModal/ConfirmModalReducer.js
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
import Immutable from 'seamless-immutable';
|
2
|
+
import {
|
3
|
+
UPDATE_MODAL,
|
4
|
+
CANCEL_SELECTED_MODAL,
|
5
|
+
RESUME_SELECTED_MODAL,
|
6
|
+
RESUME_MODAL,
|
7
|
+
CANCEL_MODAL,
|
8
|
+
} from '../../TasksTableConstants';
|
9
|
+
|
10
|
+
const initialState = Immutable({});
|
11
|
+
|
12
|
+
export const ConfirmModalReducer = (state = initialState, action) => {
|
13
|
+
const { type, payload } = action;
|
14
|
+
switch (type) {
|
15
|
+
case UPDATE_MODAL:
|
16
|
+
switch (payload.modalID) {
|
17
|
+
case CANCEL_SELECTED_MODAL:
|
18
|
+
case CANCEL_MODAL:
|
19
|
+
return state.merge({
|
20
|
+
actionText: 'cancel',
|
21
|
+
actionState: 'stopped',
|
22
|
+
actionType: payload.modalID,
|
23
|
+
});
|
24
|
+
case RESUME_SELECTED_MODAL:
|
25
|
+
case RESUME_MODAL:
|
26
|
+
return state.merge({
|
27
|
+
actionText: 'resume',
|
28
|
+
actionState: 'running',
|
29
|
+
actionType: payload.modalID,
|
30
|
+
});
|
31
|
+
default:
|
32
|
+
return state.set('actionType', payload.modalID);
|
33
|
+
}
|
34
|
+
default:
|
35
|
+
return state;
|
36
|
+
}
|
37
|
+
};
|
38
|
+
export default ConfirmModalReducer;
|