foreman-tasks 0.17.6 → 1.1.2
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 +38 -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/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 +4 -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 +6 -1
- 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/views/foreman_tasks/api/recurring_logics/base.json.rabl +2 -1
- data/app/views/foreman_tasks/api/tasks/details.json.rabl +1 -0
- 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 +7 -0
- 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 +14 -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 +3 -3
- data/lib/foreman_tasks/tasks/dynflow.rake +6 -0
- data/lib/foreman_tasks/tasks/export_tasks.rake +3 -3
- data/lib/foreman_tasks/test_extensions.rb +1 -1
- data/lib/foreman_tasks/version.rb +1 -1
- data/locale/action_names.rb +1 -1
- 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/TaskDetails/Components/Task.js +4 -0
- 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 +2 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/TaskInfo.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/Components/__tests__/__snapshots__/Task.test.js.snap +3 -1
- 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 -2
- data/webpack/ForemanTasks/Components/TaskDetails/TaskDetailsSelectors.js +3 -0
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/TaskDetails.test.js +1 -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 +1 -0
- data/webpack/ForemanTasks/Components/TaskDetails/__tests__/integration.test.js +1 -1
- data/webpack/ForemanTasks/Components/TaskDetails/index.js +2 -0
- 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/CancelConfirm.js +53 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ConfirmationModals.js +56 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/ResumeConfirm.js +52 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/SelectAllAlert.js +43 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ActionSelectButton.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/CancelConfirm.test.js +26 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ConfirmationModals.test.js +24 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ResumeConfirm.test.js +26 -0
- 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__/CancelConfirm.test.js.snap +65 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ConfirmationModals.test.js.snap +30 -0
- data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/__snapshots__/ResumeConfirm.test.js.snap +63 -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 +164 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTable.js +46 -22
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActionHelpers.js +52 -0
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableActions.js +88 -87
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableConstants.js +20 -5
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableHelpers.js +4 -3
- data/webpack/ForemanTasks/Components/TasksTable/TasksTablePage.js +128 -31
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableReducer.js +26 -9
- data/webpack/ForemanTasks/Components/TasksTable/TasksTableSelectors.js +24 -16
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/SubTasksPage.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksBulkActions.test.js +112 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksIndexPage.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.fixtures.js +12 -5
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTable.test.js +1 -1
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActionHelpers.test.js +46 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/TasksTableActions.test.js +28 -52
- 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 +15 -5
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksBulkActions.test.js.snap +229 -0
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksIndexPage.test.js.snap +14 -5
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTableActions.test.js.snap +56 -85
- data/webpack/ForemanTasks/Components/TasksTable/__tests__/__snapshots__/TasksTablePage.test.js.snap +160 -34
- 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 +4 -4
- data/webpack/ForemanTasks/Components/common/ActionButtons/ActionButton.test.js +1 -1
- data/webpack/ForemanTasks/Components/common/ActionButtons/CancelButton.test.js +1 -2
- data/webpack/ForemanTasks/Components/common/ActionButtons/ResumeButton.test.js +2 -2
- data/webpack/ForemanTasks/Components/common/ActionButtons/__snapshots__/ActionButton.test.js.snap +3 -3
- data/webpack/ForemanTasks/Components/common/ToastTypesConstants.js +11 -0
- data/webpack/ForemanTasks/ForemanTasks.test.js +1 -1
- data/webpack/ForemanTasks/Routes/ForemanTasksRouter.test.js +1 -1
- data/webpack/ForemanTasks/Routes/ForemanTasksRoutes.test.js +2 -3
- 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 +4 -0
- metadata +55 -24
- 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/stories/index.js +0 -10
- data/webpack/stories/index.scss +0 -7
- data/webpack/test_setup.js +0 -6
@@ -0,0 +1,53 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
|
4
|
+
import { Button } from 'patternfly-react';
|
5
|
+
import ForemanModal from 'foremanReact/components/ForemanModal';
|
6
|
+
import {
|
7
|
+
CANCEL_CONFIRM_MODAL_ID,
|
8
|
+
RESUME_CONFIRM_MODAL_ID,
|
9
|
+
CANCEL_SELECTED_CONFIRM_MODAL_ID,
|
10
|
+
RESUME_SELECTED_CONFIRM_MODAL_ID,
|
11
|
+
} from '../TasksTableConstants';
|
12
|
+
|
13
|
+
export const CancelConfirm = ({ closeModal, action, selectedRowsLen, id }) => (
|
14
|
+
<ForemanModal title={__('Cancel Selected Tasks')} id={id}>
|
15
|
+
<ForemanModal.Header />
|
16
|
+
{sprintf(
|
17
|
+
__(
|
18
|
+
`This will cancel %s task(s), putting them in the stopped state. Are you sure?`
|
19
|
+
),
|
20
|
+
selectedRowsLen
|
21
|
+
)}
|
22
|
+
<ForemanModal.Footer>
|
23
|
+
<Button onClick={closeModal}>{__('No')}</Button>
|
24
|
+
<Button
|
25
|
+
bsStyle="primary"
|
26
|
+
onClick={() => {
|
27
|
+
action();
|
28
|
+
closeModal();
|
29
|
+
}}
|
30
|
+
>
|
31
|
+
{__('Yes')}
|
32
|
+
</Button>
|
33
|
+
</ForemanModal.Footer>
|
34
|
+
</ForemanModal>
|
35
|
+
);
|
36
|
+
|
37
|
+
CancelConfirm.propTypes = {
|
38
|
+
closeModal: PropTypes.func.isRequired,
|
39
|
+
selectedRowsLen: PropTypes.number.isRequired,
|
40
|
+
action: PropTypes.func,
|
41
|
+
id: PropTypes.oneOf([
|
42
|
+
CANCEL_CONFIRM_MODAL_ID,
|
43
|
+
RESUME_CONFIRM_MODAL_ID,
|
44
|
+
CANCEL_SELECTED_CONFIRM_MODAL_ID,
|
45
|
+
RESUME_SELECTED_CONFIRM_MODAL_ID,
|
46
|
+
]).isRequired,
|
47
|
+
};
|
48
|
+
|
49
|
+
CancelConfirm.defaultProps = {
|
50
|
+
action: () => null,
|
51
|
+
};
|
52
|
+
|
53
|
+
export default CancelConfirm;
|
@@ -0,0 +1,56 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import {
|
4
|
+
CANCEL_CONFIRM_MODAL_ID,
|
5
|
+
RESUME_CONFIRM_MODAL_ID,
|
6
|
+
CANCEL_SELECTED_CONFIRM_MODAL_ID,
|
7
|
+
RESUME_SELECTED_CONFIRM_MODAL_ID,
|
8
|
+
} from '../TasksTableConstants';
|
9
|
+
import { CancelConfirm } from './CancelConfirm';
|
10
|
+
import { ResumeConfirm } from './ResumeConfirm';
|
11
|
+
|
12
|
+
export const ConfirmationModals = ({
|
13
|
+
modalProps,
|
14
|
+
tasksActions,
|
15
|
+
selectedRowsLen,
|
16
|
+
}) => (
|
17
|
+
<React.Fragment>
|
18
|
+
<CancelConfirm
|
19
|
+
closeModal={modalProps.cancelModal.setModalClosed}
|
20
|
+
action={tasksActions.cancelTask}
|
21
|
+
selectedRowsLen={1}
|
22
|
+
id={CANCEL_CONFIRM_MODAL_ID}
|
23
|
+
/>
|
24
|
+
<ResumeConfirm
|
25
|
+
closeModal={modalProps.resumeModal.setModalClosed}
|
26
|
+
action={tasksActions.resumeTask}
|
27
|
+
selectedRowsLen={1}
|
28
|
+
id={RESUME_CONFIRM_MODAL_ID}
|
29
|
+
/>
|
30
|
+
<CancelConfirm
|
31
|
+
closeModal={modalProps.cancelSelectedModal.setModalClosed}
|
32
|
+
action={tasksActions.cancelSelectedTasks}
|
33
|
+
selectedRowsLen={selectedRowsLen}
|
34
|
+
id={CANCEL_SELECTED_CONFIRM_MODAL_ID}
|
35
|
+
/>
|
36
|
+
<ResumeConfirm
|
37
|
+
closeModal={modalProps.resumeSelectedModal.setModalClosed}
|
38
|
+
action={tasksActions.resumeSelectedTasks}
|
39
|
+
selectedRowsLen={selectedRowsLen}
|
40
|
+
id={RESUME_SELECTED_CONFIRM_MODAL_ID}
|
41
|
+
/>
|
42
|
+
</React.Fragment>
|
43
|
+
);
|
44
|
+
|
45
|
+
ConfirmationModals.propTypes = {
|
46
|
+
modalProps: PropTypes.object.isRequired,
|
47
|
+
selectedRowsLen: PropTypes.number.isRequired,
|
48
|
+
tasksActions: PropTypes.shape({
|
49
|
+
cancelTask: PropTypes.func,
|
50
|
+
resumeTask: PropTypes.func,
|
51
|
+
cancelSelectedTasks: PropTypes.func,
|
52
|
+
resumeSelectedTasks: PropTypes.func,
|
53
|
+
}).isRequired,
|
54
|
+
};
|
55
|
+
|
56
|
+
export default ConfirmationModals;
|
@@ -0,0 +1,52 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
|
4
|
+
import { Button } from 'patternfly-react';
|
5
|
+
import ForemanModal from 'foremanReact/components/ForemanModal';
|
6
|
+
import {
|
7
|
+
CANCEL_CONFIRM_MODAL_ID,
|
8
|
+
RESUME_CONFIRM_MODAL_ID,
|
9
|
+
CANCEL_SELECTED_CONFIRM_MODAL_ID,
|
10
|
+
RESUME_SELECTED_CONFIRM_MODAL_ID,
|
11
|
+
} from '../TasksTableConstants';
|
12
|
+
|
13
|
+
export const ResumeConfirm = ({ closeModal, action, selectedRowsLen, id }) => (
|
14
|
+
<ForemanModal title={__('Resume Selected Tasks')} id={id}>
|
15
|
+
{sprintf(
|
16
|
+
__(
|
17
|
+
`This will resume %s task(s), putting them in the running state. Are you sure?`
|
18
|
+
),
|
19
|
+
selectedRowsLen
|
20
|
+
)}
|
21
|
+
<ForemanModal.Footer>
|
22
|
+
<Button onClick={closeModal}>{__('No')}</Button>
|
23
|
+
<Button
|
24
|
+
bsStyle="primary"
|
25
|
+
onClick={() => {
|
26
|
+
action();
|
27
|
+
closeModal();
|
28
|
+
}}
|
29
|
+
>
|
30
|
+
{__('Yes')}
|
31
|
+
</Button>
|
32
|
+
</ForemanModal.Footer>
|
33
|
+
</ForemanModal>
|
34
|
+
);
|
35
|
+
|
36
|
+
ResumeConfirm.propTypes = {
|
37
|
+
closeModal: PropTypes.func.isRequired,
|
38
|
+
selectedRowsLen: PropTypes.number.isRequired,
|
39
|
+
action: PropTypes.func,
|
40
|
+
id: PropTypes.oneOf([
|
41
|
+
CANCEL_CONFIRM_MODAL_ID,
|
42
|
+
RESUME_CONFIRM_MODAL_ID,
|
43
|
+
CANCEL_SELECTED_CONFIRM_MODAL_ID,
|
44
|
+
RESUME_SELECTED_CONFIRM_MODAL_ID,
|
45
|
+
]).isRequired,
|
46
|
+
};
|
47
|
+
|
48
|
+
ResumeConfirm.defaultProps = {
|
49
|
+
action: () => null,
|
50
|
+
};
|
51
|
+
|
52
|
+
export default ResumeConfirm;
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { Alert, Button } from 'patternfly-react';
|
4
|
+
import { sprintf, translate as __ } from 'foremanReact/common/I18n';
|
5
|
+
|
6
|
+
export const SelectAllAlert = ({
|
7
|
+
itemCount,
|
8
|
+
perPage,
|
9
|
+
selectAllRows,
|
10
|
+
unselectAllRows,
|
11
|
+
allRowsSelected,
|
12
|
+
}) => {
|
13
|
+
const selectAllText = (
|
14
|
+
<React.Fragment>
|
15
|
+
{sprintf(
|
16
|
+
'All %s tasks on this page are selected',
|
17
|
+
Math.min(itemCount, perPage)
|
18
|
+
)}
|
19
|
+
<Button bsStyle="link" onClick={selectAllRows}>
|
20
|
+
{__('Select All')}
|
21
|
+
<b> {itemCount} </b> {__('tasks.')}
|
22
|
+
</Button>
|
23
|
+
</React.Fragment>
|
24
|
+
);
|
25
|
+
const undoSelectText = (
|
26
|
+
<React.Fragment>
|
27
|
+
{sprintf(__(`All %s tasks are selected. `), itemCount)}
|
28
|
+
<Button bsStyle="link" onClick={unselectAllRows}>
|
29
|
+
{__('Undo selection')}
|
30
|
+
</Button>
|
31
|
+
</React.Fragment>
|
32
|
+
);
|
33
|
+
const selectAlertText = allRowsSelected ? undoSelectText : selectAllText;
|
34
|
+
return <Alert type="info">{selectAlertText}</Alert>;
|
35
|
+
};
|
36
|
+
|
37
|
+
SelectAllAlert.propTypes = {
|
38
|
+
allRowsSelected: PropTypes.bool.isRequired,
|
39
|
+
itemCount: PropTypes.number.isRequired,
|
40
|
+
perPage: PropTypes.number.isRequired,
|
41
|
+
selectAllRows: PropTypes.func.isRequired,
|
42
|
+
unselectAllRows: PropTypes.func.isRequired,
|
43
|
+
};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
2
|
+
|
3
|
+
import { CancelConfirm } from '../CancelConfirm';
|
4
|
+
import {
|
5
|
+
CANCEL_CONFIRM_MODAL_ID,
|
6
|
+
CANCEL_SELECTED_CONFIRM_MODAL_ID,
|
7
|
+
} from '../../TasksTableConstants';
|
8
|
+
|
9
|
+
const baseProps = {
|
10
|
+
closeModal: () => null,
|
11
|
+
selectedRowsLen: 1,
|
12
|
+
action: () => null,
|
13
|
+
};
|
14
|
+
const fixtures = {
|
15
|
+
'renders CANCEL modal': {
|
16
|
+
...baseProps,
|
17
|
+
id: CANCEL_CONFIRM_MODAL_ID,
|
18
|
+
},
|
19
|
+
'renders CANCEL_SELECTED modal': {
|
20
|
+
...baseProps,
|
21
|
+
id: CANCEL_SELECTED_CONFIRM_MODAL_ID,
|
22
|
+
},
|
23
|
+
};
|
24
|
+
|
25
|
+
describe('CancelConfirm', () =>
|
26
|
+
testComponentSnapshotsWithFixtures(CancelConfirm, fixtures));
|
data/webpack/ForemanTasks/Components/TasksTable/Components/__test__/ConfirmationModals.test.js
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
2
|
+
|
3
|
+
import { ConfirmationModals } from '../ConfirmationModals';
|
4
|
+
|
5
|
+
const fixtures = {
|
6
|
+
'renders ConfirmationModals': {
|
7
|
+
modalProps: {
|
8
|
+
cancelSelectedModal: { setModalClosed: jest.fn() },
|
9
|
+
resumeSelectedModal: { setModalClosed: jest.fn() },
|
10
|
+
cancelModal: { setModalClosed: jest.fn() },
|
11
|
+
resumeModal: { setModalClosed: jest.fn() },
|
12
|
+
},
|
13
|
+
selectedRowsLen: 7,
|
14
|
+
tasksActions: {
|
15
|
+
cancelTask: jest.fn(),
|
16
|
+
resumeTask: jest.fn(),
|
17
|
+
cancelSelectedTasks: jest.fn(),
|
18
|
+
resumeSelectedTasks: jest.fn(),
|
19
|
+
},
|
20
|
+
},
|
21
|
+
};
|
22
|
+
|
23
|
+
describe('ConfirmationModals', () =>
|
24
|
+
testComponentSnapshotsWithFixtures(ConfirmationModals, fixtures));
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
2
|
+
|
3
|
+
import { ResumeConfirm } from '../ResumeConfirm';
|
4
|
+
import {
|
5
|
+
RESUME_CONFIRM_MODAL_ID,
|
6
|
+
RESUME_SELECTED_CONFIRM_MODAL_ID,
|
7
|
+
} from '../../TasksTableConstants';
|
8
|
+
|
9
|
+
const baseProps = {
|
10
|
+
closeModal: () => null,
|
11
|
+
selectedRowsLen: 3,
|
12
|
+
action: () => null,
|
13
|
+
};
|
14
|
+
const fixtures = {
|
15
|
+
'renders RESUME modal': {
|
16
|
+
...baseProps,
|
17
|
+
id: RESUME_CONFIRM_MODAL_ID,
|
18
|
+
},
|
19
|
+
'renders RESUME_SELECTED modal': {
|
20
|
+
...baseProps,
|
21
|
+
id: RESUME_SELECTED_CONFIRM_MODAL_ID,
|
22
|
+
},
|
23
|
+
};
|
24
|
+
|
25
|
+
describe('ResumeConfirm', () =>
|
26
|
+
testComponentSnapshotsWithFixtures(ResumeConfirm, fixtures));
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { testComponentSnapshotsWithFixtures } from '@theforeman/test';
|
2
|
+
|
3
|
+
import { SelectAllAlert } from '../SelectAllAlert';
|
4
|
+
|
5
|
+
const baseProps = {
|
6
|
+
itemCount: 7,
|
7
|
+
perPage: 5,
|
8
|
+
selectAllRows: jest.fn(),
|
9
|
+
unselectAllRows: jest.fn(),
|
10
|
+
};
|
11
|
+
const fixtures = {
|
12
|
+
'renders SelectAllAlert with perPage > itemCout': {
|
13
|
+
allRowsSelected: false,
|
14
|
+
itemCount: 7,
|
15
|
+
perPage: 10,
|
16
|
+
...baseProps,
|
17
|
+
},
|
18
|
+
'renders SelectAllAlert without all rows selected': {
|
19
|
+
allRowsSelected: false,
|
20
|
+
...baseProps,
|
21
|
+
},
|
22
|
+
'renders SelectAllAlert with all rows selected': {
|
23
|
+
allRowsSelected: true,
|
24
|
+
...baseProps,
|
25
|
+
},
|
26
|
+
};
|
27
|
+
|
28
|
+
describe('SelectAllAlert', () =>
|
29
|
+
testComponentSnapshotsWithFixtures(SelectAllAlert, fixtures));
|
@@ -0,0 +1,65 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`CancelConfirm renders CANCEL modal 1`] = `
|
4
|
+
<ForemanModal
|
5
|
+
id="cancelConfirmModal"
|
6
|
+
title="Cancel Selected Tasks"
|
7
|
+
>
|
8
|
+
<Component />
|
9
|
+
This will cancel 1 task(s), putting them in the stopped state. Are you sure?
|
10
|
+
<Component>
|
11
|
+
<Button
|
12
|
+
active={false}
|
13
|
+
block={false}
|
14
|
+
bsClass="btn"
|
15
|
+
bsStyle="default"
|
16
|
+
disabled={false}
|
17
|
+
onClick={[Function]}
|
18
|
+
>
|
19
|
+
No
|
20
|
+
</Button>
|
21
|
+
<Button
|
22
|
+
active={false}
|
23
|
+
block={false}
|
24
|
+
bsClass="btn"
|
25
|
+
bsStyle="primary"
|
26
|
+
disabled={false}
|
27
|
+
onClick={[Function]}
|
28
|
+
>
|
29
|
+
Yes
|
30
|
+
</Button>
|
31
|
+
</Component>
|
32
|
+
</ForemanModal>
|
33
|
+
`;
|
34
|
+
|
35
|
+
exports[`CancelConfirm renders CANCEL_SELECTED modal 1`] = `
|
36
|
+
<ForemanModal
|
37
|
+
id="cancelSelectedConfirmModal"
|
38
|
+
title="Cancel Selected Tasks"
|
39
|
+
>
|
40
|
+
<Component />
|
41
|
+
This will cancel 1 task(s), putting them in the stopped state. Are you sure?
|
42
|
+
<Component>
|
43
|
+
<Button
|
44
|
+
active={false}
|
45
|
+
block={false}
|
46
|
+
bsClass="btn"
|
47
|
+
bsStyle="default"
|
48
|
+
disabled={false}
|
49
|
+
onClick={[Function]}
|
50
|
+
>
|
51
|
+
No
|
52
|
+
</Button>
|
53
|
+
<Button
|
54
|
+
active={false}
|
55
|
+
block={false}
|
56
|
+
bsClass="btn"
|
57
|
+
bsStyle="primary"
|
58
|
+
disabled={false}
|
59
|
+
onClick={[Function]}
|
60
|
+
>
|
61
|
+
Yes
|
62
|
+
</Button>
|
63
|
+
</Component>
|
64
|
+
</ForemanModal>
|
65
|
+
`;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
2
|
+
|
3
|
+
exports[`ConfirmationModals renders ConfirmationModals 1`] = `
|
4
|
+
<Fragment>
|
5
|
+
<CancelConfirm
|
6
|
+
action={[MockFunction]}
|
7
|
+
closeModal={[MockFunction]}
|
8
|
+
id="cancelConfirmModal"
|
9
|
+
selectedRowsLen={1}
|
10
|
+
/>
|
11
|
+
<ResumeConfirm
|
12
|
+
action={[MockFunction]}
|
13
|
+
closeModal={[MockFunction]}
|
14
|
+
id="resumeConfirmModal"
|
15
|
+
selectedRowsLen={1}
|
16
|
+
/>
|
17
|
+
<CancelConfirm
|
18
|
+
action={[MockFunction]}
|
19
|
+
closeModal={[MockFunction]}
|
20
|
+
id="cancelSelectedConfirmModal"
|
21
|
+
selectedRowsLen={7}
|
22
|
+
/>
|
23
|
+
<ResumeConfirm
|
24
|
+
action={[MockFunction]}
|
25
|
+
closeModal={[MockFunction]}
|
26
|
+
id="resumeSelectedConfirmModal"
|
27
|
+
selectedRowsLen={7}
|
28
|
+
/>
|
29
|
+
</Fragment>
|
30
|
+
`;
|