foreman_templates 8.0.0 → 9.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0dbc6a618a7c30af0547757f78e6548ae69c5b61112d14ae51dcdad8195d3ae
4
- data.tar.gz: 8660614fbc2a7ba17f5f778bf9e6f65a2f3ce5fe3a01bbb83212762d6c07afa3
3
+ metadata.gz: 20a8db347037219c9d8b4c09906b703e7c9370a1c5fd9775ce7d2261f82f690f
4
+ data.tar.gz: 5bea2c74fb7d677dca8d203607ef51ade2de42e26b8e458c739e80240c3cd7bf
5
5
  SHA512:
6
- metadata.gz: d1f7dabefd106226e7a11fa7bcf0d7314945c7955b50476c466d7cd21fdb5d562f2b4eff1977cb418d0f0e2a86c10889a4c2df81aedd8919b948558ad080aef1
7
- data.tar.gz: 0bdb20444ed985d3862de5785d14a542cd294fe2365d137f9c4030be725db6642aee70f4e0c60df091bcb37599a2c956bf828e85f431994d4169c37d9a325729
6
+ metadata.gz: 40eab594f513b94c2deec58e35c4f03030379598db6a482bc201838b227bcfafd6f85e5c16eefab830da3d4950109b09d67a9a9032971a7059a1fcb87f3b0fee
7
+ data.tar.gz: 4ca1502b153c698da0461087a1e8976ac1429def1d5532012639abf5724a6c010682161b0c1d8606f6d21eebd9df997dc0e1288abc4f3638f60edbd37124666b
@@ -1,5 +1,9 @@
1
- <%= webpacked_plugins_js_for :foreman_templates %>
2
- <%= webpacked_plugins_css_for :foreman_templates %>
1
+ <% content_for(:javascripts) do %>
2
+ <%= webpacked_plugins_js_for :foreman_templates %>
3
+ <% end %>
4
+ <% content_for(:stylesheets) do %>
5
+ <%= webpacked_plugins_css_for :foreman_templates %>
6
+ <% end %>
3
7
 
4
8
  <div id="foreman-templates"/>
5
9
 
@@ -1,3 +1,3 @@
1
1
  module ForemanTemplates
2
- VERSION = '8.0.0'.freeze
2
+ VERSION = '9.0.0'.freeze
3
3
  end
@@ -0,0 +1,4 @@
1
+ export const selectLayout = jest.fn(() => ({
2
+ currentOrganization: {},
3
+ currentLocation: {},
4
+ }));
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
+ import { compose } from 'redux';
3
4
 
4
5
  import ForemanForm from 'foremanReact/components/common/forms/ForemanForm';
5
6
  import * as Yup from 'yup';
@@ -96,8 +97,20 @@ class NewTemplateSyncForm extends React.Component {
96
97
  importUrl,
97
98
  exportUrl,
98
99
  initialValues,
100
+ currentLocation,
101
+ currentOrganization,
99
102
  } = this.props;
100
103
 
104
+ const addTaxParams = (key, currentTax) => params => {
105
+ if (currentTax.id) {
106
+ params[key] = [currentTax.id];
107
+ }
108
+ return params;
109
+ };
110
+
111
+ const addOrgParams = addTaxParams('organization_ids', currentOrganization);
112
+ const addLocParams = addTaxParams('location_ids', currentLocation);
113
+
101
114
  const resetToDefault = (fieldName, fieldValue) => resetFn =>
102
115
  resetFn(fieldName, fieldValue);
103
116
 
@@ -107,7 +120,10 @@ class NewTemplateSyncForm extends React.Component {
107
120
  const url = this.state.syncType === 'import' ? importUrl : exportUrl;
108
121
  return submitForm({
109
122
  url,
110
- values: values[this.state.syncType],
123
+ values: compose(
124
+ addLocParams,
125
+ addOrgParams
126
+ )(values[this.state.syncType]),
111
127
  message: `Templates were ${this.state.syncType}ed.`,
112
128
  item: 'TemplateSync',
113
129
  }).then(args => {
@@ -150,6 +166,8 @@ NewTemplateSyncForm.propTypes = {
150
166
  exportUrl: PropTypes.string.isRequired,
151
167
  importUrl: PropTypes.string.isRequired,
152
168
  submitForm: PropTypes.func.isRequired,
169
+ currentLocation: PropTypes.object.isRequired,
170
+ currentOrganization: PropTypes.object.isRequired,
153
171
  };
154
172
 
155
173
  NewTemplateSyncForm.defaultProps = {
@@ -2,6 +2,8 @@ import { connect } from 'react-redux';
2
2
 
3
3
  import * as FormActions from 'foremanReact/redux/actions/common/forms';
4
4
 
5
+ import { selectLayout } from 'foremanReact/components/Layout/LayoutSelectors';
6
+
5
7
  import NewTemplateSyncForm from './NewTemplateSyncForm';
6
8
 
7
9
  import {
@@ -22,6 +24,8 @@ const mapStateToProps = (state, ownProps) => {
22
24
  initialValues: { ...initialFormValues },
23
25
  importSettings,
24
26
  exportSettings,
27
+ currentOrganization: selectLayout(state).currentOrganization,
28
+ currentLocation: selectLayout(state).currentLocation,
25
29
  };
26
30
  };
27
31
 
@@ -11,10 +11,10 @@ import ListViewHeader from './ListViewHeader';
11
11
  const SyncResultList = ({ pagination, pageChange, templates, editPaths }) => (
12
12
  <ListView>
13
13
  <ListViewHeader />
14
- {templatesPage(templates, pagination).map(template => (
14
+ {templatesPage(templates, pagination).map((template, idx) => (
15
15
  <SyncedTemplate
16
16
  template={template}
17
- key={template.name}
17
+ key={idx}
18
18
  editPath={editPaths[template.className]}
19
19
  />
20
20
  ))}
@@ -0,0 +1,37 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`expandableContent should return additional error 1`] = `
4
+ <ul>
5
+ <li>
6
+ These are additional errors
7
+ </li>
8
+ </ul>
9
+ `;
10
+
11
+ exports[`expandableContent should return additional info 1`] = `
12
+ <ul>
13
+ <li>
14
+ This is additional info
15
+ </li>
16
+ </ul>
17
+ `;
18
+
19
+ exports[`expandableContent should return attribute errors 1`] = `
20
+ <ul>
21
+ <li>
22
+ could not be processed
23
+ </li>
24
+ <li>
25
+ name: can't be blank
26
+ </li>
27
+ <li>
28
+ name: has invalid format
29
+ </li>
30
+ </ul>
31
+ `;
32
+
33
+ exports[`expandableContent should return no errors 1`] = `
34
+ <span>
35
+ There were no errors.
36
+ </span>
37
+ `;
@@ -114,7 +114,7 @@ export const expandableContent = template => {
114
114
  const aggregatedErrors = template => {
115
115
  const err = { ...template.errors } || {};
116
116
  if (template.additionalErrors) {
117
- err.additional = template.additionalErrors;
117
+ err.additional = [template.additionalErrors];
118
118
  }
119
119
 
120
120
  return err;
@@ -123,14 +123,14 @@ const aggregatedErrors = template => {
123
123
  const aggregatedMessages = template => {
124
124
  const errors = aggregatedErrors(template);
125
125
  if (template.additionalInfo) {
126
- errors.info = template.additionalInfo;
126
+ errors.info = [template.additionalInfo];
127
127
  }
128
128
  return errors;
129
129
  };
130
130
 
131
131
  const formatError = (key, value) => {
132
132
  const omitKeys = ['base', 'additional', 'info'];
133
- if (omitKeys.filter(item => key === item)) {
133
+ if (omitKeys.includes(key)) {
134
134
  return value;
135
135
  }
136
136
 
@@ -0,0 +1,21 @@
1
+ import { testSelectorsSnapshotWithFixtures } from 'react-redux-test-utils';
2
+
3
+ import { expandableContent } from './helpers';
4
+
5
+ const fixtures = {
6
+ 'should return no errors': () => expandableContent({}),
7
+ 'should return additional info': () =>
8
+ expandableContent({ additionalInfo: 'This is additional info' }),
9
+ 'should return additional error': () =>
10
+ expandableContent({ additionalErrors: 'These are additional errors' }),
11
+ 'should return attribute errors': () =>
12
+ expandableContent({
13
+ errors: {
14
+ base: ['could not be processed'],
15
+ name: ["can't be blank", 'has invalid format'],
16
+ },
17
+ }),
18
+ };
19
+
20
+ describe('expandableContent', () =>
21
+ testSelectorsSnapshotWithFixtures(fixtures));
@@ -7,7 +7,7 @@ exports[`SyncResultList should render 1`] = `
7
7
  <ListViewHeader />
8
8
  <SyncedTemplate
9
9
  editPath=""
10
- key="null"
10
+ key="0"
11
11
  template={
12
12
  Object {
13
13
  "additionalErrors": Array [
@@ -21,7 +21,7 @@ exports[`SyncResultList should render 1`] = `
21
21
  />
22
22
  <SyncedTemplate
23
23
  editPath=""
24
- key="EPEL"
24
+ key="1"
25
25
  template={
26
26
  Object {
27
27
  "additionalErrors": null,
@@ -42,7 +42,7 @@ exports[`SyncResultList should render 1`] = `
42
42
  />
43
43
  <SyncedTemplate
44
44
  editPath=""
45
- key="CoreOS default"
45
+ key="2"
46
46
  template={
47
47
  Object {
48
48
  "additionalErrors": null,
@@ -58,7 +58,7 @@ exports[`SyncResultList should render 1`] = `
58
58
  />
59
59
  <SyncedTemplate
60
60
  editPath=""
61
- key="null"
61
+ key="3"
62
62
  template={
63
63
  Object {
64
64
  "additionalErrors": "No \\"model\\" found in metadata",
@@ -70,7 +70,7 @@ exports[`SyncResultList should render 1`] = `
70
70
  />
71
71
  <SyncedTemplate
72
72
  editPath=""
73
- key="Kickstart fake"
73
+ key="4"
74
74
  template={
75
75
  Object {
76
76
  "additionalErrors": null,
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: 8.0.0
4
+ version: 9.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Sutcliffe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-20 00:00:00.000000000 Z
11
+ date: 2020-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diffy
@@ -97,6 +97,7 @@ files:
97
97
  - webpack/ForemanTemplates.js
98
98
  - webpack/Routes.js
99
99
  - webpack/__mocks__/foremanReact/common/helpers.js
100
+ - webpack/__mocks__/foremanReact/components/Layout/LayoutSelectors.js
100
101
  - webpack/__mocks__/foremanReact/components/Pagination/PaginationWrapper.js
101
102
  - webpack/__mocks__/foremanReact/components/common/forms/CommonForm.js
102
103
  - webpack/__mocks__/foremanReact/components/common/forms/ForemanForm.js
@@ -164,7 +165,9 @@ files:
164
165
  - webpack/components/TemplateSyncResult/components/SyncedTemplate/InfoItem.js
165
166
  - webpack/components/TemplateSyncResult/components/SyncedTemplate/LinkInfoItem.js
166
167
  - webpack/components/TemplateSyncResult/components/SyncedTemplate/StringInfoItem.js
168
+ - webpack/components/TemplateSyncResult/components/SyncedTemplate/__snapshots__/helpers.test.js.snap
167
169
  - webpack/components/TemplateSyncResult/components/SyncedTemplate/helpers.js
170
+ - webpack/components/TemplateSyncResult/components/SyncedTemplate/helpers.test.js
168
171
  - webpack/components/TemplateSyncResult/components/SyncedTemplate/index.js
169
172
  - webpack/components/TemplateSyncResult/components/__tests__/SyncResultList.test.js
170
173
  - webpack/components/TemplateSyncResult/components/__tests__/SyncedTemplate.test.js
@@ -195,8 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
198
  - !ruby/object:Gem::Version
196
199
  version: '0'
197
200
  requirements: []
198
- rubyforge_project:
199
- rubygems_version: 2.7.6.2
201
+ rubygems_version: 3.0.8
200
202
  signing_key:
201
203
  specification_version: 4
202
204
  summary: Template-syncing engine for Foreman