foreman_templates 7.0.7 → 8.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/api/v2/template_controller.rb +6 -1
  3. data/app/controllers/concerns/foreman/controller/parameters/template_params.rb +22 -2
  4. data/app/models/setting/template_sync.rb +12 -2
  5. data/app/services/foreman_templates/template_exporter.rb +2 -2
  6. data/app/services/foreman_templates/template_importer.rb +20 -4
  7. data/app/views/template_syncs/index.html.erb +2 -6
  8. data/db/migrate/20180627134929_change_lock_setting.rb +5 -0
  9. data/lib/foreman_templates/engine.rb +6 -0
  10. data/lib/foreman_templates/version.rb +1 -1
  11. data/package.json +15 -21
  12. data/webpack/__mocks__/foremanReact/components/common/forms/ForemanForm.js +2 -0
  13. data/webpack/components/NewTemplateSync/__fixtures__/templateSyncSettings.fixtures.js +4 -4
  14. data/webpack/components/NewTemplateSync/__tests__/__snapshots__/NewTemplateSync.test.js.snap +2 -2
  15. data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/NewTemplateSyncForm.js +68 -71
  16. data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/NewTemplateSyncFormSelectors.js +10 -13
  17. data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/__tests__/NewTemplateSyncFormSelectors.test.js +1 -19
  18. data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/__tests__/__snapshots__/NewTemplateSyncFormSelectors.test.js.snap +7 -36
  19. data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/index.js +3 -20
  20. data/webpack/components/NewTemplateSync/components/SyncSettingField.js +5 -11
  21. data/webpack/components/NewTemplateSync/components/SyncSettingFields.js +8 -25
  22. data/webpack/components/NewTemplateSync/components/TextButtonField/index.js +27 -20
  23. data/webpack/components/NewTemplateSync/components/__tests__/SyncSettingField.test.js +2 -1
  24. data/webpack/components/NewTemplateSync/components/__tests__/SyncSettingFields.test.js +1 -0
  25. data/webpack/components/NewTemplateSync/components/__tests__/TextButtonField.test.js +4 -4
  26. data/webpack/components/NewTemplateSync/components/__tests__/__snapshots__/SyncSettingField.test.js.snap +18 -27
  27. data/webpack/components/NewTemplateSync/components/__tests__/__snapshots__/SyncSettingFields.test.js.snap +5 -3
  28. data/webpack/components/NewTemplateSync/components/__tests__/__snapshots__/TextButtonField.test.js.snap +8 -91
  29. data/webpack/components/TemplateSyncResult/__fixtures__/templateSyncResult.fixtures.js +2 -2
  30. data/webpack/components/TemplateSyncResult/__tests__/__snapshots__/TemplateSyncResult.test.js.snap +3 -1
  31. data/webpack/components/TemplateSyncResult/__tests__/__snapshots__/TemplateSyncResultReducer.test.js.snap +3 -1
  32. data/webpack/components/TemplateSyncResult/components/SyncedTemplate/helpers.js +19 -9
  33. data/webpack/components/TemplateSyncResult/components/__tests__/__snapshots__/SyncResultList.test.js.snap +3 -1
  34. data/webpack/components/TemplateSyncResult/components/__tests__/__snapshots__/SyncedTemplate.test.js.snap +39 -15
  35. data/webpack/testSetup.js +2 -1
  36. metadata +4 -7
  37. data/webpack/__mocks__/foremanReact/components/Layout/LayoutSelectors.js +0 -4
  38. data/webpack/__mocks__/foremanReact/components/common/forms/Form.js +0 -2
  39. data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/NewTemplateSyncFormConstants.js +0 -1
  40. data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/__tests__/NewTemplateSyncForm.test.js +0 -42
  41. data/webpack/components/NewTemplateSync/components/NewTemplateSyncForm/__tests__/__snapshots__/NewTemplateSyncForm.test.js.snap +0 -186
@@ -1,4 +0,0 @@
1
- export const selectLayout = jest.fn(() => ({
2
- currentOrganization: {},
3
- currentLocation: {},
4
- }));
@@ -1,2 +0,0 @@
1
- const Form = () => jest.fn();
2
- export default Form;
@@ -1 +0,0 @@
1
- export const NEW_TEMPLATE_SYNC_FORM_NAME = 'newTemplateSync';
@@ -1,42 +0,0 @@
1
- import { testComponentSnapshotsWithFixtures } from 'react-redux-test-utils';
2
-
3
- import NewTemplateSyncForm from '../NewTemplateSyncForm';
4
-
5
- import {
6
- importSettings,
7
- exportSettings,
8
- } from '../../../__fixtures__/templateSyncSettings.fixtures';
9
-
10
- const noop = () => {};
11
-
12
- const commonFixture = {
13
- importUrl: '/import',
14
- exportUrl: '/export',
15
- validationData: {},
16
- userPermissions: {
17
- import: true,
18
- export: true,
19
- },
20
- handleSubmit: noop,
21
- valid: true,
22
- importSettings,
23
- exportSettings,
24
- };
25
-
26
- const fixtures = {
27
- 'should render when for import settings': {
28
- loadingSettings: false,
29
- ...commonFixture,
30
- },
31
- 'should render for export settings': {
32
- loadingSettings: true,
33
- ...commonFixture,
34
- userPermissions: {
35
- import: false,
36
- export: true,
37
- },
38
- },
39
- };
40
-
41
- describe('NewTemplateSyncForm', () =>
42
- testComponentSnapshotsWithFixtures(NewTemplateSyncForm, fixtures));
@@ -1,186 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`NewTemplateSyncForm should render for export settings 1`] = `
4
- <Form
5
- disabled={false}
6
- errorTitle="Warning! "
7
- onCancel={[Function]}
8
- submitting={false}
9
- >
10
- <SyncTypeRadios
11
- controlLabel="Action type"
12
- disabled={false}
13
- name="syncType"
14
- radios={
15
- Array [
16
- Object {
17
- "checked": true,
18
- "label": "Export",
19
- "onChange": [Function],
20
- "permission": "export",
21
- "value": "export",
22
- },
23
- ]
24
- }
25
- />
26
- <SyncSettingsFields
27
- disabled={false}
28
- exportSettings={
29
- Array [
30
- Object {
31
- "description": "Import or export names matching this regex (case-insensitive; snippets are not filtered)",
32
- "id": 47,
33
- "name": "filter",
34
- "settingsType": "string",
35
- "value": "",
36
- },
37
- Object {
38
- "description": "Negate the filter for import/export",
39
- "id": 48,
40
- "name": "negate",
41
- "settingsType": "bool",
42
- "value": false,
43
- },
44
- Object {
45
- "description": "Target path to import and export. Different protocols can be used, for example /tmp/dir, git://example.com, https://example.com, ssh://example.com. When exporting to /tmp, note that production deployments may be configured to use private tmp.",
46
- "id": 49,
47
- "name": "repo",
48
- "settingsType": "string",
49
- "value": "https://github.com/theforeman/community-templates.git",
50
- },
51
- ]
52
- }
53
- importSettings={
54
- Array [
55
- Object {
56
- "description": "Associate templates to OS, organization and location",
57
- "id": 45,
58
- "name": "associate",
59
- "selection": Array [
60
- Object {
61
- "label": "New",
62
- "value": "new",
63
- },
64
- Object {
65
- "label": "Never",
66
- "value": "never",
67
- },
68
- Object {
69
- "label": "Always",
70
- "value": "always",
71
- },
72
- ],
73
- "settingsType": "string",
74
- "value": "new",
75
- },
76
- Object {
77
- "description": "Should importing overwrite locked templates?",
78
- "id": 46,
79
- "name": "force",
80
- "settingsType": "bool",
81
- "value": false,
82
- },
83
- ]
84
- }
85
- resetField={[Function]}
86
- syncType="export"
87
- validationData={Object {}}
88
- />
89
- </Form>
90
- `;
91
-
92
- exports[`NewTemplateSyncForm should render when for import settings 1`] = `
93
- <Form
94
- disabled={false}
95
- errorTitle="Warning! "
96
- onCancel={[Function]}
97
- submitting={false}
98
- >
99
- <SyncTypeRadios
100
- controlLabel="Action type"
101
- disabled={false}
102
- name="syncType"
103
- radios={
104
- Array [
105
- Object {
106
- "checked": true,
107
- "label": "Import",
108
- "onChange": [Function],
109
- "permission": "import",
110
- "value": "import",
111
- },
112
- Object {
113
- "checked": false,
114
- "label": "Export",
115
- "onChange": [Function],
116
- "permission": "export",
117
- "value": "export",
118
- },
119
- ]
120
- }
121
- />
122
- <SyncSettingsFields
123
- disabled={false}
124
- exportSettings={
125
- Array [
126
- Object {
127
- "description": "Import or export names matching this regex (case-insensitive; snippets are not filtered)",
128
- "id": 47,
129
- "name": "filter",
130
- "settingsType": "string",
131
- "value": "",
132
- },
133
- Object {
134
- "description": "Negate the filter for import/export",
135
- "id": 48,
136
- "name": "negate",
137
- "settingsType": "bool",
138
- "value": false,
139
- },
140
- Object {
141
- "description": "Target path to import and export. Different protocols can be used, for example /tmp/dir, git://example.com, https://example.com, ssh://example.com. When exporting to /tmp, note that production deployments may be configured to use private tmp.",
142
- "id": 49,
143
- "name": "repo",
144
- "settingsType": "string",
145
- "value": "https://github.com/theforeman/community-templates.git",
146
- },
147
- ]
148
- }
149
- importSettings={
150
- Array [
151
- Object {
152
- "description": "Associate templates to OS, organization and location",
153
- "id": 45,
154
- "name": "associate",
155
- "selection": Array [
156
- Object {
157
- "label": "New",
158
- "value": "new",
159
- },
160
- Object {
161
- "label": "Never",
162
- "value": "never",
163
- },
164
- Object {
165
- "label": "Always",
166
- "value": "always",
167
- },
168
- ],
169
- "settingsType": "string",
170
- "value": "new",
171
- },
172
- Object {
173
- "description": "Should importing overwrite locked templates?",
174
- "id": 46,
175
- "name": "force",
176
- "settingsType": "bool",
177
- "value": false,
178
- },
179
- ]
180
- }
181
- resetField={[Function]}
182
- syncType="import"
183
- validationData={Object {}}
184
- />
185
- </Form>
186
- `;