foreman_remote_execution 9.0.1 → 9.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/job_invocations_controller.rb +1 -0
  3. data/app/controllers/job_invocations_controller.rb +10 -0
  4. data/app/controllers/ui_job_wizard_controller.rb +6 -1
  5. data/app/helpers/remote_execution_helper.rb +1 -1
  6. data/app/lib/actions/remote_execution/run_hosts_job.rb +28 -2
  7. data/app/models/remote_execution_feature.rb +11 -8
  8. data/app/views/api/v2/job_invocations/base.json.rabl +1 -1
  9. data/app/views/job_invocations/show.html.erb +1 -1
  10. data/app/views/job_invocations/welcome.html.erb +1 -1
  11. data/config/routes.rb +1 -0
  12. data/db/migrate/20210816100932_rex_setting_category_to_dsl.rb +1 -1
  13. data/db/migrate/20220426145007_add_unique_feature_label_index.rb +14 -0
  14. data/lib/foreman_remote_execution/engine.rb +1 -1
  15. data/lib/foreman_remote_execution/version.rb +1 -1
  16. data/locale/action_names.rb +1 -1
  17. data/locale/de/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  18. data/locale/de/foreman_remote_execution.po +15 -12
  19. data/locale/en/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  20. data/locale/en/foreman_remote_execution.po +4 -1
  21. data/locale/en_GB/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  22. data/locale/en_GB/foreman_remote_execution.po +6 -3
  23. data/locale/es/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  24. data/locale/es/foreman_remote_execution.po +16 -13
  25. data/locale/foreman_remote_execution.pot +25 -17
  26. data/locale/fr/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  27. data/locale/fr/foreman_remote_execution.po +51 -48
  28. data/locale/ja/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  29. data/locale/ja/foreman_remote_execution.po +17 -14
  30. data/locale/ko/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  31. data/locale/ko/foreman_remote_execution.po +12 -9
  32. data/locale/pt_BR/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  33. data/locale/pt_BR/foreman_remote_execution.po +13 -10
  34. data/locale/ru/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  35. data/locale/ru/foreman_remote_execution.po +12 -9
  36. data/locale/zh_CN/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  37. data/locale/zh_CN/foreman_remote_execution.po +16 -13
  38. data/locale/zh_TW/LC_MESSAGES/foreman_remote_execution.mo +0 -0
  39. data/locale/zh_TW/foreman_remote_execution.po +12 -9
  40. data/package.json +6 -6
  41. data/webpack/JobWizard/JobWizard.js +97 -32
  42. data/webpack/JobWizard/StartsBeforeErrorAlert.js +17 -0
  43. data/webpack/JobWizard/__tests__/__snapshots__/integration.test.js.snap +8 -0
  44. data/webpack/JobWizard/__tests__/fixtures.js +5 -0
  45. data/webpack/JobWizard/__tests__/integration.test.js +15 -0
  46. data/webpack/JobWizard/__tests__/validation.test.js +27 -0
  47. data/webpack/JobWizard/autofill.js +1 -0
  48. data/webpack/JobWizard/steps/AdvancedFields/__tests__/AdvancedFields.test.js +29 -10
  49. data/webpack/JobWizard/steps/AdvancedFields/__tests__/__snapshots__/AdvancedFields.test.js.snap +8 -0
  50. data/webpack/JobWizard/steps/HostsAndInputs/HostPreviewModal.js +3 -0
  51. data/webpack/JobWizard/steps/HostsAndInputs/__tests__/HostsAndInputs.test.js +38 -1
  52. data/webpack/JobWizard/steps/HostsAndInputs/buildHostQuery.js +16 -10
  53. data/webpack/JobWizard/steps/HostsAndInputs/index.js +51 -3
  54. data/webpack/JobWizard/steps/Schedule/__tests__/Schedule.test.js +33 -13
  55. data/webpack/JobWizard/steps/form/DateTimePicker.js +1 -1
  56. data/webpack/JobWizard/submit.js +14 -3
  57. metadata +4 -2
@@ -39,15 +39,35 @@ api.get.mockImplementation(({ handleSuccess, ...action }) => {
39
39
  handleSuccess({
40
40
  data: { results: [jobTemplateResponse.job_template] },
41
41
  });
42
+ } else if (action.key === 'HOST_IDS') {
43
+ handleSuccess &&
44
+ handleSuccess({
45
+ data: { results: [{ name: 'host1' }, { name: 'host3' }] },
46
+ });
42
47
  }
43
48
  return { type: 'get', ...action };
44
49
  });
45
50
 
46
51
  const mockStore = configureMockStore([]);
47
- const store = mockStore({});
52
+ const store = mockStore({
53
+ HOSTS_API: {
54
+ response: {
55
+ subtotal: 3,
56
+ },
57
+ },
58
+ });
48
59
  jest.useFakeTimers();
49
60
 
50
61
  describe('Schedule', () => {
62
+ beforeEach(() => {
63
+ jest.spyOn(selectors, 'selectRouterSearch');
64
+ selectors.selectRouterSearch.mockImplementation(() => ({
65
+ 'host_ids[]': ['105', '37'],
66
+ }));
67
+ });
68
+ afterEach(() => {
69
+ selectors.selectRouterSearch.mockRestore();
70
+ });
51
71
  it('sub steps appear', () => {
52
72
  render(
53
73
  <Provider store={store}>
@@ -85,7 +105,7 @@ describe('Schedule', () => {
85
105
  });
86
106
  act(() => {
87
107
  fireEvent.click(screen.getByRole('button', { name: 'Future execution' }));
88
- jest.runAllTimers(); // to handle pf4 date picker popover useTimer
108
+ jest.advanceTimersByTime(1000); // to handle pf4 date picker popover useTimer
89
109
  });
90
110
 
91
111
  const newStartAtDate = '2030/03/12';
@@ -115,7 +135,7 @@ describe('Schedule', () => {
115
135
  fireEvent.change(startsBeforeTimeField(), {
116
136
  target: { value: newStartBeforeTime },
117
137
  });
118
- jest.runOnlyPendingTimers();
138
+ jest.advanceTimersByTime(1000);
119
139
  });
120
140
 
121
141
  act(() => {
@@ -123,7 +143,7 @@ describe('Schedule', () => {
123
143
  });
124
144
  act(() => {
125
145
  fireEvent.click(screen.getByRole('button', { name: 'Future execution' }));
126
- jest.runAllTimers(); // to handle pf4 date picker popover useTimer
146
+ jest.advanceTimersByTime(1000); // to handle pf4 date picker popover useTimer
127
147
  });
128
148
  expect(startsAtDateField().value).toBe(newStartAtDate);
129
149
  expect(startsAtTimeField().value).toBe(newStartAtTime);
@@ -140,7 +160,7 @@ describe('Schedule', () => {
140
160
  target: { value: '2030/03/11' },
141
161
  });
142
162
  await fireEvent.click(startsBeforeTimeField());
143
- await jest.runOnlyPendingTimers();
163
+ await jest.advanceTimersByTime(1000);
144
164
  });
145
165
  expect(startsBeforeDateField().value).toBe('2030/03/11');
146
166
  expect(
@@ -157,13 +177,13 @@ describe('Schedule', () => {
157
177
  await fireEvent.change(startsAtDateField(), {
158
178
  target: { value: '' },
159
179
  });
160
- jest.runOnlyPendingTimers();
180
+ jest.advanceTimersByTime(1000);
161
181
  });
162
182
 
163
183
  expect(startsBeforeDateField().value).toBe('2019/03/11');
164
184
  expect(
165
185
  screen.getAllByText("'Starts before' date must in the future")
166
- ).toHaveLength(1);
186
+ ).toHaveLength(2);
167
187
  });
168
188
 
169
189
  it('Recurring execution - date pickers', async () => {
@@ -182,7 +202,7 @@ describe('Schedule', () => {
182
202
  fireEvent.click(
183
203
  screen.getByRole('button', { name: 'Recurring execution' })
184
204
  );
185
- jest.runAllTimers(); // to handle pf4 date picker popover useTimer
205
+ jest.advanceTimersByTime(1000); // to handle pf4 date picker popover useTimer
186
206
  });
187
207
 
188
208
  const newStartAtDate = '2030/03/12';
@@ -207,7 +227,7 @@ describe('Schedule', () => {
207
227
  fireEvent.change(startsAtTimeField(), {
208
228
  target: { value: newStartAtTime },
209
229
  });
210
- jest.runOnlyPendingTimers();
230
+ jest.advanceTimersByTime(1000);
211
231
  });
212
232
 
213
233
  expect(endsAtDateField().disabled).toBeTruthy();
@@ -222,7 +242,7 @@ describe('Schedule', () => {
222
242
  fireEvent.change(endsAtTimeField(), {
223
243
  target: { value: newStartAtTime },
224
244
  });
225
- jest.runOnlyPendingTimers();
245
+ jest.advanceTimersByTime(1000);
226
246
  });
227
247
 
228
248
  act(() => {
@@ -232,7 +252,7 @@ describe('Schedule', () => {
232
252
  fireEvent.click(
233
253
  screen.getByRole('button', { name: 'Recurring execution' })
234
254
  );
235
- jest.runAllTimers(); // to handle pf4 date picker popover useTimer
255
+ jest.advanceTimersByTime(1000); // to handle pf4 date picker popover useTimer
236
256
  });
237
257
  expect(startsAtDateField().value).toBe(newStartAtDate);
238
258
  expect(startsAtTimeField().value).toBe(newStartAtTime);
@@ -266,7 +286,7 @@ describe('Schedule', () => {
266
286
  fireEvent.click(
267
287
  screen.getByRole('button', { name: 'Recurring execution' })
268
288
  );
269
- jest.runAllTimers(); // to handle pf4 date picker popover useTimer
289
+ jest.advanceTimersByTime(1000); // to handle pf4 date picker popover useTimer
270
290
  });
271
291
  await act(async () => {
272
292
  fireEvent.click(screen.getByLabelText('Daily', { selector: 'button' }));
@@ -294,7 +314,7 @@ describe('Schedule', () => {
294
314
  fireEvent.click(
295
315
  screen.getByRole('button', { name: 'Recurring execution' })
296
316
  );
297
- jest.runAllTimers();
317
+ jest.advanceTimersByTime(1000);
298
318
  });
299
319
  expect(screen.queryAllByText('Recurring execution')).toHaveLength(3);
300
320
  expect(cronline.value).toBe(newCronline);
@@ -59,7 +59,7 @@ export const DateTimePicker = ({
59
59
  return false;
60
60
  };
61
61
 
62
- const onDateChange = newDate => {
62
+ const onDateChange = (e, newDate) => {
63
63
  const parsedNewDate = new Date(newDate);
64
64
  if (!newDate.length && allowEmpty) {
65
65
  setDateTime('');
@@ -12,6 +12,8 @@ export const submit = ({
12
12
  location,
13
13
  organization,
14
14
  feature,
15
+ provider,
16
+ advancedInputs,
15
17
  dispatch,
16
18
  }) => {
17
19
  const {
@@ -37,6 +39,13 @@ export const submit = ({
37
39
  keyPassphrase,
38
40
  timeToPickup,
39
41
  } = advancedValues;
42
+ const providerInputs = advancedInputs.filter(v => v.provider_input);
43
+ const providerValues = {};
44
+ providerInputs.forEach(({ name }) => {
45
+ providerValues[name] = advancedTemplateValues[name];
46
+ delete advancedTemplateValues[name];
47
+ });
48
+
40
49
  const getCronLine = () => {
41
50
  const [hour, minute] = repeatData.at
42
51
  ? repeatData.at.split(':')
@@ -104,14 +113,16 @@ export const submit = ({
104
113
  concurrency_level: concurrencyLevel,
105
114
  },
106
115
  bookmark_id: null,
107
- search_query:
108
- buildHostQuery(selectedTargets, hostsSearchQuery) || 'name ~ *',
116
+ search_query: buildHostQuery(selectedTargets, hostsSearchQuery),
109
117
  description_format: description,
110
118
  execution_timeout_interval: timeoutToKill,
111
119
  feature,
112
120
  time_to_pickup: timeToPickup,
113
121
  },
114
122
  };
123
+ if (Object.keys(providerValues).length) {
124
+ api.job_invocation[provider] = providerValues;
125
+ }
115
126
 
116
127
  dispatch(
117
128
  post({
@@ -122,7 +133,7 @@ export const submit = ({
122
133
  window.location.href = `/job_invocations/${id}`;
123
134
  },
124
135
  errorToast: ({ response }) =>
125
- response?.date?.error?.message ||
136
+ response?.data?.error?.message ||
126
137
  response?.message ||
127
138
  response?.statusText,
128
139
  })
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_remote_execution
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.0.1
4
+ version: 9.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Foreman Remote Execution team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-20 00:00:00.000000000 Z
11
+ date: 2023-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -327,6 +327,7 @@ files:
327
327
  - db/migrate/20210816100932_rex_setting_category_to_dsl.rb
328
328
  - db/migrate/20220321101835_rename_ssh_provider_to_script.rb
329
329
  - db/migrate/20220331112719_add_ssh_user_to_job_invocation.rb
330
+ - db/migrate/20220426145007_add_unique_feature_label_index.rb
330
331
  - db/migrate/20220713095705_create_template_invocation_events.rb
331
332
  - db/migrate/20220822155946_add_time_to_pickup_to_job_invocation.rb
332
333
  - db/migrate/20221129170145_redefine_template_invocation_events_index.rb
@@ -418,6 +419,7 @@ files:
418
419
  - webpack/JobWizard/JobWizardHelpers.js
419
420
  - webpack/JobWizard/JobWizardPageRerun.js
420
421
  - webpack/JobWizard/JobWizardSelectors.js
422
+ - webpack/JobWizard/StartsBeforeErrorAlert.js
421
423
  - webpack/JobWizard/__tests__/JobWizardPageRerun.test.js
422
424
  - webpack/JobWizard/__tests__/__snapshots__/integration.test.js.snap
423
425
  - webpack/JobWizard/__tests__/fixtures.js