foreman_remote_execution 7.2.1 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby_ci.yml +2 -2
  3. data/app/controllers/ui_job_wizard_controller.rb +15 -0
  4. data/app/helpers/remote_execution_helper.rb +1 -1
  5. data/app/models/job_invocation.rb +2 -4
  6. data/app/models/job_invocation_composer.rb +5 -2
  7. data/app/views/templates/script/package_action.erb +8 -3
  8. data/config/routes.rb +3 -1
  9. data/lib/foreman_remote_execution/engine.rb +5 -5
  10. data/lib/foreman_remote_execution/version.rb +1 -1
  11. data/test/functional/api/v2/job_invocations_controller_test.rb +8 -0
  12. data/test/helpers/remote_execution_helper_test.rb +4 -0
  13. data/test/unit/job_invocation_report_template_test.rb +1 -1
  14. data/test/unit/job_invocation_test.rb +1 -2
  15. data/webpack/JobWizard/JobWizard.js +154 -20
  16. data/webpack/JobWizard/JobWizard.scss +43 -1
  17. data/webpack/JobWizard/JobWizardConstants.js +11 -1
  18. data/webpack/JobWizard/JobWizardPageRerun.js +112 -0
  19. data/webpack/JobWizard/__tests__/JobWizardPageRerun.test.js +79 -0
  20. data/webpack/JobWizard/__tests__/fixtures.js +73 -0
  21. data/webpack/JobWizard/__tests__/integration.test.js +17 -3
  22. data/webpack/JobWizard/autofill.js +8 -1
  23. data/webpack/JobWizard/steps/AdvancedFields/__tests__/AdvancedFields.test.js +36 -17
  24. data/webpack/JobWizard/steps/CategoryAndTemplate/index.js +3 -3
  25. data/webpack/JobWizard/steps/ReviewDetails/index.js +1 -3
  26. data/webpack/JobWizard/steps/Schedule/PurposeField.js +1 -3
  27. data/webpack/JobWizard/steps/Schedule/QueryType.js +33 -40
  28. data/webpack/JobWizard/steps/Schedule/RepeatHour.js +55 -16
  29. data/webpack/JobWizard/steps/Schedule/RepeatOn.js +19 -56
  30. data/webpack/JobWizard/steps/Schedule/RepeatWeek.js +1 -1
  31. data/webpack/JobWizard/steps/Schedule/ScheduleFuture.js +126 -0
  32. data/webpack/JobWizard/steps/Schedule/ScheduleRecurring.js +287 -0
  33. data/webpack/JobWizard/steps/Schedule/ScheduleType.js +88 -20
  34. data/webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js +206 -186
  35. data/webpack/JobWizard/steps/form/DateTimePicker.js +23 -6
  36. data/webpack/JobWizard/steps/form/Formatter.js +7 -8
  37. data/webpack/JobWizard/submit.js +8 -3
  38. data/webpack/Routes/routes.js +8 -2
  39. data/webpack/__mocks__/foremanReact/common/hooks/API/APIHooks.js +1 -0
  40. data/webpack/react_app/components/HostKebab/KebabItems.js +0 -1
  41. data/webpack/react_app/components/RecentJobsCard/RecentJobsCard.js +0 -5
  42. data/webpack/react_app/components/RecentJobsCard/RecentJobsTable.js +59 -51
  43. data/webpack/react_app/extend/Fills.js +4 -4
  44. metadata +8 -6
  45. data/webpack/JobWizard/steps/Schedule/StartEndDates.js +0 -106
  46. data/webpack/JobWizard/steps/Schedule/__tests__/StartEndDates.test.js +0 -32
  47. data/webpack/JobWizard/steps/Schedule/index.js +0 -178
@@ -1,178 +0,0 @@
1
- import React, { useEffect, useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import { Form } from '@patternfly/react-core';
4
- import { ScheduleType } from './ScheduleType';
5
- import { RepeatOn } from './RepeatOn';
6
- import { QueryType } from './QueryType';
7
- import { StartEndDates } from './StartEndDates';
8
- import { WIZARD_TITLES, repeatTypes } from '../../JobWizardConstants';
9
- import { PurposeField } from './PurposeField';
10
- import { WizardTitle } from '../form/WizardTitle';
11
-
12
- const Schedule = ({ scheduleValue, setScheduleValue, setValid }) => {
13
- const {
14
- repeatType,
15
- repeatAmount,
16
- repeatData,
17
- startsAt,
18
- startsBefore,
19
- ends,
20
- isNeverEnds,
21
- isFuture,
22
- isTypeStatic,
23
- purpose,
24
- } = scheduleValue;
25
- const [validEnd, setValidEnd] = useState(true);
26
- const [repeatValid, setRepeatValid] = useState(true);
27
-
28
- useEffect(() => {
29
- if (!validEnd || !repeatValid) {
30
- setValid(false);
31
- } else if (isFuture && (startsAt.length || startsBefore.length)) {
32
- setValid(true);
33
- } else if (!isFuture) {
34
- setValid(true);
35
- } else {
36
- setValid(false);
37
- }
38
- // eslint-disable-next-line react-hooks/exhaustive-deps
39
- }, [startsAt, startsBefore, isFuture, validEnd, repeatValid]);
40
- return (
41
- <>
42
- <WizardTitle title={WIZARD_TITLES.schedule} />
43
- <Form className="schedule-tab">
44
- <ScheduleType
45
- isFuture={isFuture}
46
- setIsFuture={newValue => {
47
- if (!newValue) {
48
- // if schedule type is execute now
49
- setScheduleValue(current => ({
50
- ...current,
51
- startsAt: '',
52
- startsBefore: '',
53
- isFuture: newValue,
54
- }));
55
- } else {
56
- setScheduleValue(current => ({
57
- ...current,
58
- startsAt: new Date().toISOString(),
59
- isFuture: newValue,
60
- }));
61
- }
62
- }}
63
- />
64
-
65
- <RepeatOn
66
- repeatType={repeatType}
67
- repeatData={repeatData}
68
- setRepeatType={newValue => {
69
- setScheduleValue(current => ({
70
- ...current,
71
- repeatType: newValue,
72
- startsBefore: '',
73
- }));
74
- }}
75
- setRepeatData={newValue => {
76
- setScheduleValue(current => ({
77
- ...current,
78
- repeatData: newValue,
79
- }));
80
- }}
81
- repeatAmount={repeatAmount}
82
- setRepeatAmount={newValue => {
83
- setScheduleValue(current => ({
84
- ...current,
85
- repeatAmount: newValue,
86
- }));
87
- }}
88
- setValid={setRepeatValid}
89
- />
90
- <StartEndDates
91
- startsAt={startsAt}
92
- setStartsAt={newValue => {
93
- if (!isFuture) {
94
- setScheduleValue(current => ({
95
- ...current,
96
- isFuture: true,
97
- }));
98
- }
99
- setScheduleValue(current => ({
100
- ...current,
101
- startsAt: newValue,
102
- }));
103
- }}
104
- startsBefore={startsBefore}
105
- setStartsBefore={newValue => {
106
- if (!isFuture) {
107
- setScheduleValue(current => ({
108
- ...current,
109
- isFuture: true,
110
- }));
111
- }
112
- setScheduleValue(current => ({
113
- ...current,
114
- startsBefore: newValue,
115
- }));
116
- }}
117
- ends={ends}
118
- setEnds={newValue => {
119
- setScheduleValue(current => ({
120
- ...current,
121
- ends: newValue,
122
- }));
123
- }}
124
- isNeverEnds={isNeverEnds}
125
- setIsNeverEnds={newValue => {
126
- setScheduleValue(current => ({
127
- ...current,
128
- isNeverEnds: newValue,
129
- }));
130
- }}
131
- validEnd={validEnd}
132
- setValidEnd={setValidEnd}
133
- isFuture={isFuture}
134
- isStartBeforeDisabled={repeatType !== repeatTypes.noRepeat}
135
- isEndDisabled={repeatType === repeatTypes.noRepeat}
136
- />
137
- <QueryType
138
- isTypeStatic={isTypeStatic}
139
- setIsTypeStatic={newValue => {
140
- setScheduleValue(current => ({
141
- ...current,
142
- isTypeStatic: newValue,
143
- }));
144
- }}
145
- />
146
- <PurposeField
147
- isDisabled={repeatType === repeatTypes.noRepeat}
148
- purpose={purpose}
149
- setPurpose={newValue => {
150
- setScheduleValue(current => ({
151
- ...current,
152
- purpose: newValue,
153
- }));
154
- }}
155
- />
156
- </Form>
157
- </>
158
- );
159
- };
160
-
161
- Schedule.propTypes = {
162
- scheduleValue: PropTypes.shape({
163
- repeatType: PropTypes.string.isRequired,
164
- repeatAmount: PropTypes.string,
165
- repeatData: PropTypes.object,
166
- startsAt: PropTypes.string,
167
- startsBefore: PropTypes.string,
168
- ends: PropTypes.string,
169
- isFuture: PropTypes.bool,
170
- isNeverEnds: PropTypes.bool,
171
- isTypeStatic: PropTypes.bool,
172
- purpose: PropTypes.string,
173
- }).isRequired,
174
- setScheduleValue: PropTypes.func.isRequired,
175
- setValid: PropTypes.func.isRequired,
176
- };
177
-
178
- export default Schedule;