foreman_templates 10.0.2 → 10.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/foreman_templates/locale/cs_CZ/foreman_templates.js +34 -4
  3. data/app/assets/javascripts/foreman_templates/locale/de/foreman_templates.js +34 -4
  4. data/app/assets/javascripts/foreman_templates/locale/en_GB/foreman_templates.js +34 -4
  5. data/app/assets/javascripts/foreman_templates/locale/es/foreman_templates.js +34 -4
  6. data/app/assets/javascripts/foreman_templates/locale/fr/foreman_templates.js +34 -4
  7. data/app/assets/javascripts/foreman_templates/locale/gl/foreman_templates.js +34 -4
  8. data/app/assets/javascripts/foreman_templates/locale/it/foreman_templates.js +34 -4
  9. data/app/assets/javascripts/foreman_templates/locale/ja/foreman_templates.js +34 -4
  10. data/app/assets/javascripts/foreman_templates/locale/ka/foreman_templates.js +34 -4
  11. data/app/assets/javascripts/foreman_templates/locale/ko/foreman_templates.js +79 -49
  12. data/app/assets/javascripts/foreman_templates/locale/pt_BR/foreman_templates.js +34 -4
  13. data/app/assets/javascripts/foreman_templates/locale/ru/foreman_templates.js +34 -4
  14. data/app/assets/javascripts/foreman_templates/locale/sv_SE/foreman_templates.js +34 -4
  15. data/app/assets/javascripts/foreman_templates/locale/zh_CN/foreman_templates.js +34 -4
  16. data/app/assets/javascripts/foreman_templates/locale/zh_TW/foreman_templates.js +34 -4
  17. data/app/controllers/api/v2/template_controller.rb +3 -1
  18. data/app/controllers/concerns/foreman/controller/parameters/template_params.rb +1 -1
  19. data/app/controllers/ui_template_syncs_controller.rb +21 -1
  20. data/app/services/foreman_templates/action.rb +32 -1
  21. data/app/services/foreman_templates/template_exporter.rb +2 -2
  22. data/app/services/foreman_templates/template_importer.rb +3 -3
  23. data/lib/foreman_templates/engine.rb +6 -0
  24. data/lib/foreman_templates/version.rb +1 -1
  25. data/lib/foreman_templates.rb +4 -0
  26. data/locale/cs_CZ/LC_MESSAGES/foreman_templates.mo +0 -0
  27. data/locale/cs_CZ/foreman_templates.po +34 -4
  28. data/locale/de/LC_MESSAGES/foreman_templates.mo +0 -0
  29. data/locale/de/foreman_templates.po +34 -4
  30. data/locale/en_GB/LC_MESSAGES/foreman_templates.mo +0 -0
  31. data/locale/en_GB/foreman_templates.po +34 -4
  32. data/locale/es/LC_MESSAGES/foreman_templates.mo +0 -0
  33. data/locale/es/foreman_templates.po +34 -4
  34. data/locale/fr/LC_MESSAGES/foreman_templates.mo +0 -0
  35. data/locale/fr/foreman_templates.po +34 -4
  36. data/locale/gl/LC_MESSAGES/foreman_templates.mo +0 -0
  37. data/locale/gl/foreman_templates.po +34 -4
  38. data/locale/it/LC_MESSAGES/foreman_templates.mo +0 -0
  39. data/locale/it/foreman_templates.po +34 -4
  40. data/locale/ja/LC_MESSAGES/foreman_templates.mo +0 -0
  41. data/locale/ja/foreman_templates.po +34 -4
  42. data/locale/ka/LC_MESSAGES/foreman_templates.mo +0 -0
  43. data/locale/ka/foreman_templates.po +34 -4
  44. data/locale/ko/LC_MESSAGES/foreman_templates.mo +0 -0
  45. data/locale/ko/foreman_templates.po +81 -49
  46. data/locale/pt_BR/LC_MESSAGES/foreman_templates.mo +0 -0
  47. data/locale/pt_BR/foreman_templates.po +34 -4
  48. data/locale/ru/LC_MESSAGES/foreman_templates.mo +0 -0
  49. data/locale/ru/foreman_templates.po +34 -4
  50. data/locale/sv_SE/LC_MESSAGES/foreman_templates.mo +0 -0
  51. data/locale/sv_SE/foreman_templates.po +34 -4
  52. data/locale/zh_CN/LC_MESSAGES/foreman_templates.mo +0 -0
  53. data/locale/zh_CN/foreman_templates.po +34 -4
  54. data/locale/zh_TW/LC_MESSAGES/foreman_templates.mo +0 -0
  55. data/locale/zh_TW/foreman_templates.po +34 -4
  56. data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/NewTemplateSyncFormHelpers.js +15 -3
  57. data/webpack/components/NewTemplateSync/components/ProxySettingField.js +44 -0
  58. data/webpack/components/NewTemplateSync/components/ProxySettingFields.js +82 -0
  59. data/webpack/components/NewTemplateSync/components/SyncSettingField.js +5 -12
  60. data/webpack/components/NewTemplateSync/components/SyncSettingFields.js +18 -0
  61. data/webpack/components/NewTemplateSync/components/__tests__/__snapshots__/SyncSettingField.test.js.snap +3 -3
  62. data/webpack/components/NewTemplateSync/components/__tests__/__snapshots__/SyncSettingFields.test.js.snap +14 -0
  63. metadata +4 -2
@@ -9,7 +9,7 @@
9
9
  #
10
10
  msgid ""
11
11
  msgstr ""
12
- "Project-Id-Version: foreman_templates 10.0.1\n"
12
+ "Project-Id-Version: foreman_templates 10.0.3\n"
13
13
  "Report-Msgid-Bugs-To: \n"
14
14
  "PO-Revision-Date: 2019-10-14 12:27+0000\n"
15
15
  "Last-Translator: Bryan Kearney <bryan.kearney@gmail.com>, 2023\n"
@@ -51,6 +51,9 @@ msgstr ""
51
51
  msgid "Commit message"
52
52
  msgstr ""
53
53
 
54
+ msgid "Custom HTTP proxy"
55
+ msgstr ""
56
+
54
57
  msgid "Custom commit message for templates export"
55
58
  msgstr ""
56
59
 
@@ -60,6 +63,9 @@ msgstr ""
60
63
  msgid "Default metadata export mode, refresh re-renders metadata, keep will keep existing metadata, remove exports template without metadata"
61
64
  msgstr ""
62
65
 
66
+ msgid "Directory within Git repo containing the templates."
67
+ msgstr ""
68
+
63
69
  msgid "Dirname"
64
70
  msgstr ""
65
71
 
@@ -75,9 +81,24 @@ msgstr "篩選器"
75
81
  msgid "Force import"
76
82
  msgstr ""
77
83
 
84
+ msgid "Global default HTTP proxy"
85
+ msgstr ""
86
+
87
+ msgid "HTTP proxy"
88
+ msgstr ""
89
+
90
+ msgid "HTTP proxy policy"
91
+ msgstr ""
92
+
93
+ msgid "HTTP proxy policy for template sync. If you choose 'selected', provide the `http_proxy_id` parameter."
94
+ msgstr ""
95
+
78
96
  msgid "How to handle lock for imported templates?"
79
97
  msgstr ""
80
98
 
99
+ msgid "ID of an HTTP proxy to use for template sync. Use this parameter together with `'http_proxy_policy':'selected'`"
100
+ msgstr ""
101
+
81
102
  msgid "Import"
82
103
  msgstr "匯入"
83
104
 
@@ -93,6 +114,9 @@ msgstr ""
93
114
  msgid "Initiate Import"
94
115
  msgstr ""
95
116
 
117
+ msgid "Invalid repo format, must start with one of: "
118
+ msgstr ""
119
+
96
120
  msgid "Keep"
97
121
  msgstr ""
98
122
 
@@ -129,6 +153,9 @@ msgstr "永不"
129
153
  msgid "New"
130
154
  msgstr "新增"
131
155
 
156
+ msgid "No HTTP proxy"
157
+ msgstr ""
158
+
132
159
  msgid "Override the default repo from settings."
133
160
  msgstr ""
134
161
 
@@ -156,6 +183,12 @@ msgstr "移除"
156
183
  msgid "Repo"
157
184
  msgstr "軟體庫"
158
185
 
186
+ msgid "Select an HTTP proxy to use for template sync. You can add HTTP proxies on the Infrastructure > HTTP proxies page."
187
+ msgstr ""
188
+
189
+ msgid "Should an HTTP proxy be used for template sync? If you select Custom HTTP proxy, you will be prompted to select one."
190
+ msgstr ""
191
+
159
192
  msgid "Should importing overwrite locked templates?"
160
193
  msgstr ""
161
194
 
@@ -174,9 +207,6 @@ msgstr ""
174
207
  msgid "Template Sync"
175
208
  msgstr ""
176
209
 
177
- msgid "The directory within Git repo containing the templates"
178
- msgstr ""
179
-
180
210
  msgid "The directory within the Git repo containing the templates"
181
211
  msgstr ""
182
212
 
@@ -1,4 +1,6 @@
1
1
  import * as Yup from 'yup';
2
+ import React from 'react';
3
+ import { translate as __ } from 'foremanReact/common/I18n';
2
4
 
3
5
  export const redirectToResult = history => () =>
4
6
  history.push({ pathname: '/template_syncs/result' });
@@ -24,9 +26,9 @@ export const syncFormSchema = (syncType, settingsObj, validationData) => {
24
26
  repo: Yup.string()
25
27
  .test(
26
28
  'repo-format',
27
- `Invalid repo format, must start with one of: ${validationData.repo.join(
28
- ', '
29
- )}`,
29
+ `${__(
30
+ 'Invalid repo format, must start with one of: '
31
+ )}${validationData.repo.join(', ')}`,
30
32
  repoFormat(validationData.repo)
31
33
  )
32
34
  .required("can't be blank"),
@@ -41,3 +43,13 @@ export const syncFormSchema = (syncType, settingsObj, validationData) => {
41
43
  [syncType]: Yup.object().shape(schema),
42
44
  });
43
45
  };
46
+
47
+ export const tooltipContent = setting => (
48
+ <div
49
+ dangerouslySetInnerHTML={{
50
+ __html: __(setting.description),
51
+ }}
52
+ />
53
+ );
54
+
55
+ export const label = setting => `${__(setting.fullName)}`;
@@ -0,0 +1,44 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { get } from 'lodash';
4
+
5
+ import { FieldLevelHelp } from 'patternfly-react';
6
+ import RenderField from './TextButtonField/RenderField';
7
+ import ButtonTooltip from './ButtonTooltip';
8
+
9
+ import {
10
+ tooltipContent,
11
+ label,
12
+ } from './NewTemplateSyncForm/NewTemplateSyncFormHelpers';
13
+
14
+ const ProxySettingField = ({ setting, resetField, field, form, fieldName }) => (
15
+ <RenderField
16
+ label={label(setting)}
17
+ fieldSelector={_ => 'select'}
18
+ tooltipHelp={<FieldLevelHelp content={tooltipContent(setting)} />}
19
+ buttonAttrs={{
20
+ buttonText: <ButtonTooltip tooltipId={fieldName} />,
21
+ buttonAction: () =>
22
+ resetField(fieldName, setting.value)(form.setFieldValue),
23
+ }}
24
+ blank={{}}
25
+ item={setting}
26
+ disabled={false}
27
+ fieldRequired
28
+ meta={{
29
+ touched: get(form.touched, fieldName),
30
+ error: get(form.errors, fieldName),
31
+ }}
32
+ input={field}
33
+ />
34
+ );
35
+
36
+ ProxySettingField.propTypes = {
37
+ setting: PropTypes.object.isRequired,
38
+ resetField: PropTypes.func.isRequired,
39
+ field: PropTypes.object.isRequired,
40
+ form: PropTypes.object.isRequired,
41
+ fieldName: PropTypes.string.isRequired,
42
+ };
43
+
44
+ export default ProxySettingField;
@@ -0,0 +1,82 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Field as FormikField } from 'formik';
4
+
5
+ import ProxySettingField from './ProxySettingField';
6
+
7
+ const ProxySettingsFields = ({
8
+ proxyPolicySetting,
9
+ proxyIdSetting,
10
+ syncType,
11
+ resetField,
12
+ formProps: { isSubmitting },
13
+ }) => {
14
+ if (Object.keys(proxyPolicySetting).length === 0) {
15
+ return <></>;
16
+ }
17
+ const proxyPolicyFieldName = `${syncType}.http_proxy_policy`;
18
+ const proxyIdFieldName = `${syncType}.http_proxy_id`;
19
+
20
+ // removes the custom proxy option if no proxy is available
21
+ if (proxyIdSetting.value === '') {
22
+ proxyPolicySetting = proxyPolicySetting.set(
23
+ 'selection',
24
+ proxyPolicySetting.selection.slice(0, 2)
25
+ );
26
+ }
27
+
28
+ return (
29
+ <React.Fragment>
30
+ <FormikField
31
+ name={proxyPolicyFieldName}
32
+ render={({ field, form }) => (
33
+ <ProxySettingField
34
+ setting={proxyPolicySetting}
35
+ resetField={resetField}
36
+ field={field}
37
+ form={form}
38
+ fieldName={proxyPolicyFieldName}
39
+ />
40
+ )}
41
+ />
42
+ <FormikField
43
+ name={proxyIdFieldName}
44
+ render={({ field, form }) => {
45
+ if (
46
+ proxyIdSetting.value !== '' &&
47
+ // Changing name to camel case here would unnecessarily complicate the code
48
+ // eslint-disable-next-line camelcase
49
+ form.values[syncType]?.http_proxy_policy === 'selected'
50
+ ) {
51
+ return (
52
+ <ProxySettingField
53
+ setting={proxyIdSetting}
54
+ resetField={resetField}
55
+ field={field}
56
+ form={form}
57
+ fieldName={proxyIdFieldName}
58
+ />
59
+ );
60
+ }
61
+ return <></>;
62
+ }}
63
+ />
64
+ </React.Fragment>
65
+ );
66
+ };
67
+
68
+ ProxySettingsFields.propTypes = {
69
+ proxyPolicySetting: PropTypes.object,
70
+ proxyIdSetting: PropTypes.object,
71
+ syncType: PropTypes.string.isRequired,
72
+ resetField: PropTypes.func.isRequired,
73
+ formProps: PropTypes.object,
74
+ };
75
+
76
+ ProxySettingsFields.defaultProps = {
77
+ formProps: {},
78
+ proxyPolicySetting: {},
79
+ proxyIdSetting: {},
80
+ };
81
+
82
+ export default ProxySettingsFields;
@@ -1,14 +1,15 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { FieldLevelHelp } from 'patternfly-react';
4
- import { translate as __ } from 'foremanReact/common/I18n';
5
4
 
5
+ import {
6
+ tooltipContent,
7
+ label,
8
+ } from './NewTemplateSyncForm/NewTemplateSyncFormHelpers';
6
9
  import TextButtonField from './TextButtonField';
7
10
  import ButtonTooltip from './ButtonTooltip';
8
11
 
9
12
  const SyncSettingField = ({ setting, resetField, disabled, syncType }) => {
10
- const label = settingObj => `${__(settingObj.fullName)} `;
11
-
12
13
  const fieldSelector = settingObj => {
13
14
  if (settingObj.settingsType === 'boolean') {
14
15
  return 'checkbox';
@@ -21,14 +22,6 @@ const SyncSettingField = ({ setting, resetField, disabled, syncType }) => {
21
22
  return 'text';
22
23
  };
23
24
 
24
- const tooltipContent = (
25
- <div
26
- dangerouslySetInnerHTML={{
27
- __html: __(setting.description),
28
- }}
29
- />
30
- );
31
-
32
25
  return (
33
26
  <TextButtonField
34
27
  name={`${syncType}.${setting.name}`}
@@ -40,7 +33,7 @@ const SyncSettingField = ({ setting, resetField, disabled, syncType }) => {
40
33
  fieldSelector={fieldSelector}
41
34
  disabled={disabled}
42
35
  fieldRequired={setting.required}
43
- tooltipHelp={<FieldLevelHelp content={tooltipContent} />}
36
+ tooltipHelp={<FieldLevelHelp content={tooltipContent(setting)} />}
44
37
  >
45
38
  {setting.value}
46
39
  </TextButtonField>
@@ -3,6 +3,7 @@ import { upperFirst } from 'lodash';
3
3
  import PropTypes from 'prop-types';
4
4
 
5
5
  import SyncSettingField from './SyncSettingField';
6
+ import ProxySettingsFields from './ProxySettingFields';
6
7
 
7
8
  const SyncSettingsFields = ({
8
9
  importSettings,
@@ -38,10 +39,21 @@ const SyncSettingsFields = ({
38
39
  );
39
40
 
40
41
  const settingsAry = syncType === 'import' ? importSettings : exportSettings;
42
+ const proxyPolicySetting = settingsAry.find(
43
+ setting => setting.id === 'template_sync_http_proxy_policy'
44
+ );
45
+ const proxyIdSetting = settingsAry.find(
46
+ setting => setting.id === 'template_sync_http_proxy_id'
47
+ );
41
48
 
42
49
  return (
43
50
  <React.Fragment>
44
51
  {settingsAry
52
+ .filter(
53
+ setting =>
54
+ setting.id !== 'template_sync_http_proxy_policy' &&
55
+ setting.id !== 'template_sync_http_proxy_id'
56
+ )
45
57
  .map(addRequiredToSetting)
46
58
  .map(setting => modifyDescription(setting, syncType))
47
59
  .map(setting => specializeDescription(setting, syncType))
@@ -54,6 +66,12 @@ const SyncSettingsFields = ({
54
66
  resetField={resetField}
55
67
  />
56
68
  ))}
69
+ <ProxySettingsFields
70
+ proxyPolicySetting={proxyPolicySetting}
71
+ proxyIdSetting={proxyIdSetting}
72
+ syncType={syncType}
73
+ resetField={resetField}
74
+ />
57
75
  </React.Fragment>
58
76
  );
59
77
  };
@@ -23,7 +23,7 @@ exports[`SyncSettingField should render boolean setting as checkbox 1`] = `
23
23
  "value": false,
24
24
  }
25
25
  }
26
- label="undefined "
26
+ label="undefined"
27
27
  name="import.force"
28
28
  tooltipHelp={
29
29
  <FieldLevelHelp
@@ -67,7 +67,7 @@ exports[`SyncSettingField should render setting with input field 1`] = `
67
67
  "value": "",
68
68
  }
69
69
  }
70
- label="undefined "
70
+ label="undefined"
71
71
  name="import.filter"
72
72
  tooltipHelp={
73
73
  <FieldLevelHelp
@@ -125,7 +125,7 @@ exports[`SyncSettingField should render setting with select choices 1`] = `
125
125
  "value": "new",
126
126
  }
127
127
  }
128
- label="undefined "
128
+ label="undefined"
129
129
  name="import.associate"
130
130
  tooltipHelp={
131
131
  <FieldLevelHelp
@@ -48,6 +48,13 @@ exports[`SyncSettingFields should show export settings 1`] = `
48
48
  }
49
49
  syncType="export"
50
50
  />
51
+ <ProxySettingsFields
52
+ formProps={Object {}}
53
+ proxyIdSetting={Object {}}
54
+ proxyPolicySetting={Object {}}
55
+ resetField={[Function]}
56
+ syncType="export"
57
+ />
51
58
  </Fragment>
52
59
  `;
53
60
 
@@ -97,5 +104,12 @@ exports[`SyncSettingFields should show import settings 1`] = `
97
104
  }
98
105
  syncType="import"
99
106
  />
107
+ <ProxySettingsFields
108
+ formProps={Object {}}
109
+ proxyIdSetting={Object {}}
110
+ proxyPolicySetting={Object {}}
111
+ resetField={[Function]}
112
+ syncType="import"
113
+ />
100
114
  </Fragment>
101
115
  `;
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreman_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.0.2
4
+ version: 10.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Sutcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-08 00:00:00.000000000 Z
11
+ date: 2024-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diffy
@@ -200,6 +200,8 @@ files:
200
200
  - webpack/components/NewTemplateSync/components/NewTemplateSyncForm/__tests__/NewTemplateSyncFormSelectors.test.js
201
201
  - webpack/components/NewTemplateSync/components/NewTemplateSyncForm/__tests__/__snapshots__/NewTemplateSyncFormSelectors.test.js.snap
202
202
  - webpack/components/NewTemplateSync/components/NewTemplateSyncForm/index.js
203
+ - webpack/components/NewTemplateSync/components/ProxySettingField.js
204
+ - webpack/components/NewTemplateSync/components/ProxySettingFields.js
203
205
  - webpack/components/NewTemplateSync/components/SyncSettingField.js
204
206
  - webpack/components/NewTemplateSync/components/SyncSettingFields.js
205
207
  - webpack/components/NewTemplateSync/components/SyncTypeRadios.js